<commit_before># encoding: utf-8

# Base class for Connector Providers
# that use FDW to import data through a foreign table

module CartoDB
  module Importer2
    class Connector
      class Provider
        def initialize(params = {})
          @params = Parameters.new(params, required: required_parameters + [:provider], optional: optional_parameters)
        end

        def errors
          @params.errors
        end

        def valid?
          errors.empty?
        end

        def validate!
          errors = self.errors
          raise InvalidParametersError.new(errors * "\n") if errors.present?
        end

        # Name of the table to be imported
        def table_name
          must_be_defined_in_derived_class
        end

        # SQL code to create the FDW server
        def create_server_command(_server_name)
          must_be_defined_in_derived_class
        end

        # SQL code to create the usermap for the user and postgres roles
        def create_usermap_command(_server_name, _username)
          must_be_defined_in_derived_class
        end

        # SQL code to create the foreign table used for importing
        def create_foreign_table_command(_server_name, _schema_name, _table_name, _foreign_prefix, _username)
          must_be_defined_in_derived_class
        end

        # SQL code to drop the FDW server
        def drop_server_command(server_name)
          fdw_drop_server server_name
        end

        # SQL code to drop the user mapping
        def drop_usermap_command(server_name, user)
          fdw_drop_usermap server_name, user
        end

        # SQL code to drop the foreign table
        def drop_foreign_table_command(schema_name, table_name)
          fdw_drop_foreign_table schema_name, table_name<commit_msg>Fix Provider base class specification<commit_after># encoding: utf-8

# Base class for Connector Providers
# that use FDW to import data through a foreign table

module CartoDB
  module Importer2
    class Connector
      class Provider
        def initialize(params = {})
          @params = Parameters.new(params, required: required_parameters + [:provider], optional: optional_parameters)
        end

        def errors
          @params.errors
        end

        def valid?
          errors.empty?
        end

        def validate!
          errors = self.errors
          raise InvalidParametersError.new(errors * "\n") if errors.present?
        end

        # Name of the table to be imported
        def table_name
          must_be_defined_in_derived_class
        end

        # Name of the foreign table that create_foreign_table_command creates
        def foreign_table_name(_foreign_prefix)
          must_be_defined_in_derived_class
        end

        # SQL code to create the FDW server
        def create_server_command(_server_name)
          must_be_defined_in_derived_class
        end

        # SQL code to create the usermap for the user and postgres roles
        def create_usermap_command(_server_name, _username)
          must_be_defined_in_derived_class
        end

        # SQL code to create the foreign table used for importing
        def create_foreign_table_command(_server_name, _schema_name, _foreign_prefix, _username)
          must_be_defined_in_derived_class
        end

        # SQL code to drop the FDW server
        def drop_server_command(server_name)
          fdw_drop_server server_name
        end

        # SQL code to drop the user mapping
        def drop_usermap_command(server_name, user)
          fdw_drop_usermap server_name, user
        end

        # SQL code to drop the foreign table
        def drop_foreign_table_command(schema_name, table_name)
          fdw_drop_foreign_table schema_name, table_name
{'fraction_non_alphanumeric': 0.038267339888386924, 'fraction_numerical': 0.0010629816635663034, 'mean_word_length': 2.325088339222615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '675315', 'n_tokens_mistral': 1040, 'n_tokens_neox': 991, 'n_words': 314}