From a064f9c7d90c15c83a1683bd0c012e0a6b46f793 Mon Sep 17 00:00:00 2001 From: Aleksandar Date: Mon, 4 Mar 2024 14:13:32 +0000 Subject: [PATCH] fix typos --- dbt/adapters/duckdb/plugins/__init__.py | 8 ++++---- dbt/adapters/duckdb/plugins/delta.py | 2 +- dbt/adapters/duckdb/plugins/excel.py | 4 ++-- dbt/adapters/duckdb/plugins/gsheet.py | 2 +- dbt/adapters/duckdb/plugins/iceberg.py | 2 +- dbt/adapters/duckdb/plugins/native.py | 2 +- dbt/adapters/duckdb/plugins/sqlalchemy.py | 2 +- tests/create_function_plugin.py | 19 +++++++++---------- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/dbt/adapters/duckdb/plugins/__init__.py b/dbt/adapters/duckdb/plugins/__init__.py index 93e667c5..39b2c15c 100644 --- a/dbt/adapters/duckdb/plugins/__init__.py +++ b/dbt/adapters/duckdb/plugins/__init__.py @@ -111,8 +111,8 @@ def configure_connection(self, conn: DuckDBPyConnection): """ pass - # coursor is needed for the native plugin - def load(self, source_config: SourceConfig, coursor=None): + # cursor is needed for the native plugin + def load(self, source_config: SourceConfig, cursor=None): """ Load data from a source config and return it as a DataFrame-like object that DuckDB can read. This method should be overridden by subclasses that @@ -123,13 +123,13 @@ def load(self, source_config: SourceConfig, coursor=None): """ raise NotImplementedError(f"load method not implemented for {self.name}") - # coursor is needed just for the native, we have to do it better + # cursor is needed just for the native, we have to do it better # to had it over in some initalization? def store(self, df: DuckDBPyRelation, target_config: TargetConfig, cursor=None): raise NotImplementedError(f"store method not implemented for {self.name}") def create_source_config(self, target_config: TargetConfig) -> SourceConfig: - raise NotImplementedError(f"store method not implemented for {self.name}") + raise NotImplementedError(f"create_source_config method not implemented for {self.name}") def can_be_upstream_referenced(self): return False diff --git a/dbt/adapters/duckdb/plugins/delta.py b/dbt/adapters/duckdb/plugins/delta.py index 75d1909e..5aa6e46d 100644 --- a/dbt/adapters/duckdb/plugins/delta.py +++ b/dbt/adapters/duckdb/plugins/delta.py @@ -18,7 +18,7 @@ def initialize(self, config: Dict[str, Any]): def configure_cursor(self, cursor): pass - def load(self, source_config: SourceConfig, coursor=None): + def load(self, source_config: SourceConfig, cursor=None): if "delta_table_path" not in source_config: raise Exception("'delta_table_path' is a required argument for the delta table!") diff --git a/dbt/adapters/duckdb/plugins/excel.py b/dbt/adapters/duckdb/plugins/excel.py index e59f2080..1dd47520 100644 --- a/dbt/adapters/duckdb/plugins/excel.py +++ b/dbt/adapters/duckdb/plugins/excel.py @@ -24,7 +24,7 @@ def initialize(self, plugin_config: Dict[str, Any]): if "s3_region" in plugin_config: os.environ["AWS_DEFAULT_REGION"] = plugin_config["s3_region"] - def load(self, source_config: SourceConfig, coursor=None): + def load(self, source_config: SourceConfig, cursor=None): ext_location = source_config["external_location"] ext_location = ext_location.format(**source_config.as_dict()) if "s3" in ext_location: @@ -95,7 +95,7 @@ def store(self, df: DuckDBPyRelation, target_config: TargetConfig, cursor=None): def create_source_config(self, target_config: TargetConfig) -> SourceConfig: # in the reader we have just location and sheet_name, maybe we can add here more options - # but in the first place i would not recommend to upstream excel file + # but in the first place i would not recommend to downstream excel file # this works for a very simple case but not all of them meta = { "external_location": target_config.location.path, diff --git a/dbt/adapters/duckdb/plugins/gsheet.py b/dbt/adapters/duckdb/plugins/gsheet.py index 2df7ca4c..b453bbb5 100644 --- a/dbt/adapters/duckdb/plugins/gsheet.py +++ b/dbt/adapters/duckdb/plugins/gsheet.py @@ -27,7 +27,7 @@ def initialize(self, config: Dict[str, Any]): self._config = GSheetConfig.from_dict(config) self._gc = self._config.client() - def load(self, source_config: SourceConfig, coursor=None): + def load(self, source_config: SourceConfig, cursor=None): doc = None if "title" in source_config: doc = self._gc.open(source_config["title"]) diff --git a/dbt/adapters/duckdb/plugins/iceberg.py b/dbt/adapters/duckdb/plugins/iceberg.py index e2cb33f2..56e3f708 100644 --- a/dbt/adapters/duckdb/plugins/iceberg.py +++ b/dbt/adapters/duckdb/plugins/iceberg.py @@ -14,7 +14,7 @@ def initialize(self, config: Dict[str, Any]): catalog = config.pop("catalog") self._catalog = pyiceberg.catalog.load_catalog(catalog, **config) - def load(self, source_config: SourceConfig, coursor=None): + def load(self, source_config: SourceConfig, cursor=None): table_format = source_config.get("iceberg_table", "{schema}.{identifier}") table_name = table_format.format(**source_config.as_dict()) table = self._catalog.load_table(table_name) diff --git a/dbt/adapters/duckdb/plugins/native.py b/dbt/adapters/duckdb/plugins/native.py index 95b45371..c78ea696 100644 --- a/dbt/adapters/duckdb/plugins/native.py +++ b/dbt/adapters/duckdb/plugins/native.py @@ -25,7 +25,7 @@ def default_materialization(self): # this one can be better not to go over some other format and df but directly # https://stackoverflow.com/questions/78055585/how-to-reference-duckdbpyrelation-from-another-connection - def load(self, source_config: SourceConfig, coursor=None): + def load(self, source_config: SourceConfig, cursor=None): location = external_read_location( source_config.meta.get("location", "").get("path"), source_config.meta.get("config", {}).get("options", {}), diff --git a/dbt/adapters/duckdb/plugins/sqlalchemy.py b/dbt/adapters/duckdb/plugins/sqlalchemy.py index 9273bc08..11c2b50b 100644 --- a/dbt/adapters/duckdb/plugins/sqlalchemy.py +++ b/dbt/adapters/duckdb/plugins/sqlalchemy.py @@ -19,7 +19,7 @@ class Plugin(BasePlugin): def initialize(self, plugin_config: Dict[str, Any]): self.engine = create_engine(plugin_config.pop("connection_url"), **plugin_config) - def load(self, source_config: SourceConfig, coursor=None): + def load(self, source_config: SourceConfig, cursor=None): if "query" in source_config: query = source_config["query"] query = query.format(**source_config.as_dict()) diff --git a/tests/create_function_plugin.py b/tests/create_function_plugin.py index 0b99b2de..b1b3ed09 100644 --- a/tests/create_function_plugin.py +++ b/tests/create_function_plugin.py @@ -13,23 +13,22 @@ class Plugin(BasePlugin): def configure_connection(self, conn: DuckDBPyConnection): conn.create_function("foo", foo) - def store(self, df: DuckDBPyRelation, target_config: TargetConfig, cursor = None): + def store(self, df: DuckDBPyRelation, target_config: TargetConfig, cursor=None): assert target_config.config.get("key") == "value" def can_be_upstream_referenced(self): return True - - def load(self, source_config: SourceConfig, coursor = None): - + + def load(self, source_config: SourceConfig, cursor=None): return duckdb.sql("SELECT 1729 as foo").arrow() - + def create_source_config(self, target_config: TargetConfig) -> SourceConfig: source_config = SourceConfig( - name= target_config.relation.name, - identifier= target_config.relation.identifier, + name=target_config.relation.name, + identifier=target_config.relation.identifier, schema=target_config.relation.schema, database=target_config.relation.database, - meta= target_config.as_dict(), - tags= [], + meta=target_config.as_dict(), + tags=[], ) - return source_config \ No newline at end of file + return source_config