77from sqlmesh .integrations .dlt import generate_dlt_models_and_settings
88from sqlmesh .utils .date import yesterday_ds
99from sqlmesh .utils .errors import SQLMeshError
10- from datetime import datetime
1110
1211from sqlmesh .core .config .connection import (
1312 CONNECTION_CONFIG_TO_TYPE ,
@@ -161,7 +160,7 @@ class ExampleObjects:
161160 python_macros : t .Dict [str , str ]
162161
163162
164- def _gen_example_objects (schema_name : str , start_year : int ) -> ExampleObjects :
163+ def _gen_example_objects (schema_name : str , dialect : str ) -> ExampleObjects :
165164 sql_models : t .Dict [str , str ] = {}
166165 python_models : t .Dict [str , str ] = {}
167166 seeds : t .Dict [str , str ] = {}
@@ -193,9 +192,10 @@ def _gen_example_objects(schema_name: str, start_year: int) -> ExampleObjects:
193192 sql_models [incremental_model_name ] = f"""MODEL (
194193 name { incremental_model_name } ,
195194 kind INCREMENTAL_BY_TIME_RANGE (
196- time_column event_date
195+ time_column event_date,
196+ { "partition_by_time_column false" if dialect == "doris" else "" }
197197 ),
198- start '{ start_year } -01-01',
198+ start '2020 -01-01',
199199 cron '@daily',
200200 grain (id, event_date)
201201);
@@ -224,14 +224,14 @@ def _gen_example_objects(schema_name: str, start_year: int) -> ExampleObjects:
224224);
225225 """
226226
227- seeds ["seed_data" ] = f """id,item_id,event_date
228- 1,2,{ start_year } -01-01
229- 2,1,{ start_year } -01-01
230- 3,3,{ start_year } -01-03
231- 4,1,{ start_year } -01-04
232- 5,1,{ start_year } -01-05
233- 6,1,{ start_year } -01-06
234- 7,1,{ start_year } -01-07
227+ seeds ["seed_data" ] = """id,item_id,event_date
228+ 1,2,2020 -01-01
229+ 2,1,2020 -01-01
230+ 3,3,2020 -01-03
231+ 4,1,2020 -01-04
232+ 5,1,2020 -01-05
233+ 6,1,2020 -01-06
234+ 7,1,2020 -01-07
235235"""
236236
237237 audits ["assert_positive_order_ids" ] = """AUDIT (
@@ -319,7 +319,7 @@ def init_example_project(
319319 settings = None
320320 start = None
321321 if engine_type and template == ProjectTemplate .DLT :
322- project_dialect = dialect or DIALECT_TO_TYPE .get (engine_type )
322+ project_dialect = dialect if dialect else DIALECT_TO_TYPE .get (engine_type )
323323 if pipeline and project_dialect :
324324 dlt_models , settings , start = generate_dlt_models_and_settings (
325325 pipeline_name = pipeline , dialect = project_dialect , dlt_path = dlt_path
@@ -329,9 +329,6 @@ def init_example_project(
329329 "Please provide a DLT pipeline with the `--dlt-pipeline` flag to generate a SQLMesh project from DLT."
330330 )
331331
332- if engine_type == "doris" :
333- start = datetime (datetime .now ().year , 1 , 1 ).strftime ("%Y-%m-%d" )
334-
335332 _create_config (config_path , engine_type , dialect , settings , start , template , cli_mode )
336333 if template == ProjectTemplate .DBT :
337334 return config_path
@@ -344,7 +341,10 @@ def init_example_project(
344341 )
345342 return config_path
346343
347- example_objects = _gen_example_objects (schema_name = schema_name , start_year = datetime .now ().year )
344+ example_objects = _gen_example_objects (
345+ schema_name = schema_name ,
346+ dialect = dialect if dialect else DIALECT_TO_TYPE .get (engine_type , "duckdb" ),
347+ )
348348
349349 if template != ProjectTemplate .EMPTY :
350350 _create_object_files (models_path , example_objects .sql_models , "sql" )
0 commit comments