Skip to content

Commit 8ced43a

Browse files
committed
DCV-3262 fix compilation of snapshots
1 parent ef72858 commit 8ced43a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/dbt_core_interface/project.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def generate_server_node(
704704
This is a context manager that will clear the node after execution and leverages a mutex during manifest mutation.
705705
"""
706706
# Remove {% ... %} patterns from the SQL string
707-
sql = re.sub(r'{%.*?%}', '', sql, flags=re.DOTALL)
707+
sql = re.sub(r'{%\s*(?:snapshot\s+.*?\s*|endsnapshot\s*)%}', '', sql, flags=re.DOTALL)
708708
with self.manifest_mutation_mutex:
709709
self._clear_node(node_name)
710710
sql_node = self.sql_parser.parse_remote(sql, node_name)
@@ -5937,10 +5937,26 @@ def run_sql(runners: DbtProjectContainer) -> Union[ServerRunResult, ServerErrorC
59375937
column_types=[column._data_type for column in new_columns],
59385938
row_names=new_columns[0]._keys,
59395939
)
5940+
5941+
# Define the mapping between Agate column types and Tabulator column types
5942+
AGATE_TO_TABULATOR_TYPE_MAP = {
5943+
"Text": 'string',
5944+
"Number": 'number',
5945+
"Boolean": 'boolean',
5946+
"Date": 'date',
5947+
"DateTime": 'datetime',
5948+
"TimeDelta": 'time',
5949+
}
5950+
# change column_names to a dictionary of column names and their types
5951+
name_type_union = {
5952+
column_name: AGATE_TO_TABULATOR_TYPE_MAP.get(column_type.__class__.__name__, 'string')
5953+
for column_name, column_type in zip(new_table.column_names, new_table.column_types)
5954+
}
59405955
return asdict(
59415956
ServerRunResult(
59425957
rows=[list(row) for row in new_table.rows],
5943-
column_names=new_table.column_names,
5958+
# column_names=new_table.column_names,
5959+
column_names=name_type_union,
59445960
executed_code=compiled_query.strip(),
59455961
raw_code=query,
59465962
)

0 commit comments

Comments
 (0)