Skip to content

Commit

Permalink
Fix insert query (#2713)
Browse files Browse the repository at this point in the history
  • Loading branch information
ravenac95 authored Jan 8, 2025
1 parent 12a25ca commit f5be914
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions warehouse/oso_dagster/resources/sqlmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ async def export(
context.log.info(f"executing sql: {create_query.sql(dialect='trino')}")
cursor.execute(create_query.sql(dialect="trino"))
# Insert the data into the new table
cursor.execute(
self.generate_insert_query(
model,
self.trino_source_table(table_name),
self.trino_destination_table(exported_table_name),
).sql(dialect="trino")
insert_query = self.generate_insert_query(
model,
self.trino_source_table(table_name),
self.trino_destination_table(exported_table_name),
)
context.log.info(f"executing sql: {insert_query.sql(dialect='trino')}")
cursor.execute(insert_query.sql(dialect="trino"))

with clickhouse.get_client() as clickhouse_client:
# Create the clickhouse table
Expand Down Expand Up @@ -184,7 +184,7 @@ def generate_insert_query(
assert model.columns_to_types is not None, "columns must not be None"
select = exp.select(
*[column_name for column_name in model.columns_to_types.keys()]
)
).from_(source_table)
insert = exp.Insert(this=exp.to_table(destination_table), expression=select)

return insert

0 comments on commit f5be914

Please sign in to comment.