@@ -704,7 +704,7 @@ def generate_server_node(
704
704
This is a context manager that will clear the node after execution and leverages a mutex during manifest mutation.
705
705
"""
706
706
# 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 )
708
708
with self .manifest_mutation_mutex :
709
709
self ._clear_node (node_name )
710
710
sql_node = self .sql_parser .parse_remote (sql , node_name )
@@ -5937,10 +5937,26 @@ def run_sql(runners: DbtProjectContainer) -> Union[ServerRunResult, ServerErrorC
5937
5937
column_types = [column ._data_type for column in new_columns ],
5938
5938
row_names = new_columns [0 ]._keys ,
5939
5939
)
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
+ }
5940
5955
return asdict (
5941
5956
ServerRunResult (
5942
5957
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 ,
5944
5960
executed_code = compiled_query .strip (),
5945
5961
raw_code = query ,
5946
5962
)
0 commit comments