diff --git a/dlt/destinations/impl/athena/athena.py b/dlt/destinations/impl/athena/athena.py index f86503929e..21935551c7 100644 --- a/dlt/destinations/impl/athena/athena.py +++ b/dlt/destinations/impl/athena/athena.py @@ -105,7 +105,7 @@ class AthenaTypeMapper(TypeMapper): def __init__(self, capabilities: DestinationCapabilitiesContext): super().__init__(capabilities) - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: precision = column.get("precision") table_format = table.get("table_format") if precision is None: diff --git a/dlt/destinations/impl/bigquery/bigquery.py b/dlt/destinations/impl/bigquery/bigquery.py index 5020d912c6..4cc484ecf1 100644 --- a/dlt/destinations/impl/bigquery/bigquery.py +++ b/dlt/destinations/impl/bigquery/bigquery.py @@ -90,7 +90,7 @@ class BigQueryTypeMapper(TypeMapper): "TIME": "time", } - def to_db_decimal_type(self, column: TColumnSchema = None) -> str: + def to_db_decimal_type(self, column: TColumnSchema) -> str: # Use BigQuery's BIGNUMERIC for large precision decimals precision, scale = self.decimal_precision(column.get("precision"), column.get("scale")) if precision > 38 or scale > 9: diff --git a/dlt/destinations/impl/databricks/databricks.py b/dlt/destinations/impl/databricks/databricks.py index 63edf0c8a0..9697760c7e 100644 --- a/dlt/destinations/impl/databricks/databricks.py +++ b/dlt/destinations/impl/databricks/databricks.py @@ -68,7 +68,7 @@ class DatabricksTypeMapper(TypeMapper): "wei": "DECIMAL(%i,%i)", } - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: precision = column.get("precision") if precision is None: return "BIGINT" diff --git a/dlt/destinations/impl/duckdb/duck.py b/dlt/destinations/impl/duckdb/duck.py index db79e26425..d5065f5bdd 100644 --- a/dlt/destinations/impl/duckdb/duck.py +++ b/dlt/destinations/impl/duckdb/duck.py @@ -62,7 +62,7 @@ class DuckDbTypeMapper(TypeMapper): "TIMESTAMP_NS": "timestamp", } - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: precision = column.get("precision") if precision is None: return "BIGINT" @@ -83,7 +83,7 @@ def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = def to_db_datetime_type( self, - column: TColumnSchema = None, + column: TColumnSchema, table: TTableSchema = None, ) -> str: column_name = column.get("name") diff --git a/dlt/destinations/impl/lancedb/lancedb_client.py b/dlt/destinations/impl/lancedb/lancedb_client.py index f2af8d5ad3..02240b8f93 100644 --- a/dlt/destinations/impl/lancedb/lancedb_client.py +++ b/dlt/destinations/impl/lancedb/lancedb_client.py @@ -105,30 +105,27 @@ class LanceDBTypeMapper(TypeMapper): pa.date32(): "date", } - def to_db_decimal_type(self, column: TColumnSchema = None) -> pa.Decimal128Type: + def to_db_decimal_type(self, column: TColumnSchema) -> pa.Decimal128Type: precision, scale = self.decimal_precision(column.get("precision"), column.get("scale")) return pa.decimal128(precision, scale) def to_db_datetime_type( self, - column: TColumnSchema = None, + column: TColumnSchema, table: TTableSchema = None, ) -> pa.TimestampType: column_name = column.get("name") - table_name = table.get("name") timezone = column.get("timezone") precision = column.get("precision") if timezone is not None or precision is not None: logger.warning( "LanceDB does not currently support column flags for timezone or precision." - f" These flags were used in column '{column_name}' of table '{table_name}'." + f" These flags were used in column '{column_name}'." ) unit: str = TIMESTAMP_PRECISION_TO_UNIT[self.capabilities.timestamp_precision] return pa.timestamp(unit, "UTC") - def to_db_time_type( - self, column: TColumnSchema = None, table: TTableSchema = None - ) -> pa.Time64Type: + def to_db_time_type(self, column: TColumnSchema, table: TTableSchema = None) -> pa.Time64Type: unit: str = TIMESTAMP_PRECISION_TO_UNIT[self.capabilities.timestamp_precision] return pa.time64(unit) diff --git a/dlt/destinations/impl/mssql/mssql.py b/dlt/destinations/impl/mssql/mssql.py index e684c1cd3d..b35d62495d 100644 --- a/dlt/destinations/impl/mssql/mssql.py +++ b/dlt/destinations/impl/mssql/mssql.py @@ -59,7 +59,7 @@ class MsSqlTypeMapper(TypeMapper): "int": "bigint", } - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: precision = column.get("precision") if precision is None: return "bigint" diff --git a/dlt/destinations/impl/postgres/postgres.py b/dlt/destinations/impl/postgres/postgres.py index abad936c42..101cdc9e25 100644 --- a/dlt/destinations/impl/postgres/postgres.py +++ b/dlt/destinations/impl/postgres/postgres.py @@ -66,7 +66,7 @@ class PostgresTypeMapper(TypeMapper): "integer": "bigint", } - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: precision = column.get("precision") if precision is None: return "bigint" @@ -83,7 +83,7 @@ def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = def to_db_datetime_type( self, - column: TColumnSchema = None, + column: TColumnSchema, table: TTableSchema = None, ) -> str: column_name = column.get("name") diff --git a/dlt/destinations/impl/redshift/redshift.py b/dlt/destinations/impl/redshift/redshift.py index 7c5f5b5f5c..4219b911aa 100644 --- a/dlt/destinations/impl/redshift/redshift.py +++ b/dlt/destinations/impl/redshift/redshift.py @@ -82,7 +82,7 @@ class RedshiftTypeMapper(TypeMapper): "integer": "bigint", } - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: precision = column.get("precision") if precision is None: return "bigint" diff --git a/dlt/destinations/impl/snowflake/snowflake.py b/dlt/destinations/impl/snowflake/snowflake.py index 73357bcd54..2f3c73356b 100644 --- a/dlt/destinations/impl/snowflake/snowflake.py +++ b/dlt/destinations/impl/snowflake/snowflake.py @@ -79,7 +79,7 @@ def from_db_type( def to_db_datetime_type( self, - column: TColumnSchema = None, + column: TColumnSchema, table: TTableSchema = None, ) -> str: column_name = column.get("name") diff --git a/dlt/destinations/type_mapping.py b/dlt/destinations/type_mapping.py index 087ebce2d6..100b8df424 100644 --- a/dlt/destinations/type_mapping.py +++ b/dlt/destinations/type_mapping.py @@ -27,38 +27,38 @@ class TypeMapper: def __init__(self, capabilities: DestinationCapabilitiesContext) -> None: self.capabilities = capabilities - def to_db_integer_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_integer_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: # Override in subclass if db supports other integer types (e.g. smallint, integer, tinyint, etc.) return self.sct_to_unbound_dbt["bigint"] def to_db_datetime_type( self, - column: TColumnSchema = None, + column: TColumnSchema, table: TTableSchema = None, ) -> str: # Override in subclass if db supports other timestamp types (e.g. with different time resolutions) - if column is not None and table is not None: - timezone = column.get("timezone") - precision = column.get("precision") - if timezone is not None or precision is not None: - logger.warning( - "Column flags for timezone or precision are not yet supported in this" - " destination. One or both of these flags were used in column" - f" '{column.get('name')}' of table '{table.get('name')}'." - ) + timezone = column.get("timezone") + precision = column.get("precision") + if timezone is not None or precision is not None: + logger.warning( + "Column flags for timezone or precision are not yet supported in this" + " destination. One or both of these flags were used in column" + f" '{column.get('name')}''." + ) return None - def to_db_time_type(self, column: TColumnSchema = None, table: TTableSchema = None) -> str: + def to_db_time_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: # Override in subclass if db supports other time types (e.g. with different time resolutions) return None - def to_db_decimal_type(self, column: TColumnSchema = None) -> str: + def to_db_decimal_type(self, column: TColumnSchema) -> str: precision_tup = self.decimal_precision(column.get("precision"), column.get("scale")) if not precision_tup or "decimal" not in self.sct_to_dbt: return self.sct_to_unbound_dbt["decimal"] return self.sct_to_dbt["decimal"] % (precision_tup[0], precision_tup[1]) + # TODO: refactor lancedb and wevavite to make table object required def to_db_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: sc_t = column["data_type"] if sc_t == "bigint": @@ -83,7 +83,7 @@ def to_db_type(self, column: TColumnSchema, table: TTableSchema = None) -> str: return self.sct_to_dbt[sc_t] % precision_tuple def precision_tuple_or_default( - self, data_type: TDataType, column: TColumnSchema = None + self, data_type: TDataType, column: TColumnSchema ) -> Optional[Tuple[int, ...]]: precision = column.get("precision") scale = column.get("scale")