Brendan Jackson
05/31/2023, 12:10 PMselect * from {table}
, as in one of the documentation examples.
I imagine this is not done, because it would require the loading of the view to happen within a dbt run (where the view still exists)?Guy McCombe
05/31/2023, 12:12 PMGuy McCombe
05/31/2023, 12:13 PMBrendan Jackson
05/31/2023, 12:14 PMBrendan Jackson
05/31/2023, 12:14 PMBrendan Jackson
05/31/2023, 12:15 PMdef load_input(self, context) -> pd.DataFrame:
"""Load the contents of a table as a pandas DataFrame."""
table_name = context.asset_key.path[-1]
return pd.read_sql(f"SELECT * FROM {table_name}", con=self.connection_str)
But {table_name}
will not exist.Guy McCombe
05/31/2023, 12:16 PMGuy McCombe
05/31/2023, 12:16 PMtable_name
not just the name of your view?Brendan Jackson
05/31/2023, 12:16 PMBrendan Jackson
05/31/2023, 12:17 PMBrendan Jackson
05/31/2023, 12:17 PMGuy McCombe
05/31/2023, 12:18 PMGuy McCombe
05/31/2023, 12:18 PMBrendan Jackson
05/31/2023, 12:20 PMBrendan Jackson
05/31/2023, 12:20 PMBrendan Jackson
05/31/2023, 12:21 PMwhere date > '{{ var("start_date") }}' and date <= '{{ var("end_date") }}'
Brendan Jackson
05/31/2023, 12:21 PMpartition_key_to_vars_fn
Brendan Jackson
05/31/2023, 12:23 PMB
just a regular table, I would adopt incremental materialisation. I can't do that here. I could specify the view without where clause, and use the IO manager to do that part?Guy McCombe
05/31/2023, 12:23 PMBrendan Jackson
05/31/2023, 12:23 PMBrendan Jackson
05/31/2023, 12:24 PMGuy McCombe
05/31/2023, 12:27 PMdef load_input(self, context) -> pd.DataFrame:
"""Load the contents of a table as a pandas DataFrame."""
table_name = context.asset_key.path[-1]
if context.has_partition_key:
return pd.read_sql(f"SELECT * FROM {table_name} WHERE date={context.asset_partition_key}",
con=self.connection_str)
return pd.read_sql(f"SELECT * FROM {table_name}", con=self.connection_str)