Skip to content

Commit

Permalink
add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Nov 10, 2024
1 parent ff13003 commit b636df4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dlt/destinations/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def columns_schema(self, new_value: TTableSchemaColumns) -> None:
def compute_columns_schema(self) -> TTableSchemaColumns:
"""provide schema columns for the cursor, may be filtered by selected columns"""

# TODO: if there were no joins, we can return the schema from the table
# for the prototype disable this
# TODO: we need to detect if the query is selecting from one table and also not doing
# any aggreates and maybe other things, then we can still return the hints for the result
return None

columns_schema = (
Expand Down Expand Up @@ -155,7 +155,7 @@ def _proxy_expression_method(self, method_name: str, *args: Any, **kwargs: Any)
return result

def __getattr__(self, name: str) -> Any:
"""Forward any unknown attributes/methods to the underlying expression"""
"""Wrap all callable attributes of the expression"""
if not hasattr(self._expression, name):
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")
attr = getattr(self._expression, name)
Expand Down Expand Up @@ -289,7 +289,7 @@ def table(self, table_name: str) -> SupportsReadableRelation:
table_schema = self.schema.tables[table_name]

# Convert dlt table schema columns to ibis schema
# TODO: convert all types properly
# TODO: this mapping is generated by cursor, we need to verify this ;)
ibis_schema = {}
for col_name, col_info in table_schema.get("columns", {}).items():
#
Expand All @@ -310,8 +310,9 @@ def table(self, table_name: str) -> SupportsReadableRelation:
col_type = col_info.get("data_type", "string")
ibis_schema[col_name] = col_mapping.get(col_type, "string")

print(ibis_schema)
# create unbound ibis table and return in dlt wrapper
# NOTE: we can also add the dataset to the unbound table here, then the user could probably do cross
# dataset joins with this on the same db
unbound_table = ibis.table(schema=ibis_schema, name=table_name)
return ReadableDBAPIRelation(readable_dataset=self, expression=unbound_table)

Expand Down

0 comments on commit b636df4

Please sign in to comment.