1414from ruamel .yaml import YAMLError
1515
1616from sqlmesh .core .engine_adapter import EngineAdapter
17+ from sqlmesh .core .snapshot .definition import DeployabilityIndex
1718from sqlmesh .dbt .adapter import BaseAdapter , ParsetimeAdapter , RuntimeAdapter
1819from sqlmesh .dbt .relation import Policy
1920from sqlmesh .dbt .target import TARGET_TYPE_TO_CONFIG_CLASS
@@ -371,8 +372,20 @@ def create_builtin_globals(
371372 if variables is not None :
372373 builtin_globals ["var" ] = Var (variables )
373374
375+ deployability_index = (
376+ jinja_globals .get ("deployability_index" ) or DeployabilityIndex .all_deployable ()
377+ )
374378 snapshot = jinja_globals .pop ("snapshot" , None )
375- is_incremental = bool (snapshot .intervals ) and snapshot .is_incremental if snapshot else False
379+
380+ if snapshot and snapshot .is_incremental :
381+ intervals = (
382+ snapshot .intervals
383+ if deployability_index .is_deployable (snapshot )
384+ else snapshot .dev_intervals
385+ )
386+ is_incremental = bool (intervals )
387+ else :
388+ is_incremental = False
376389 builtin_globals ["is_incremental" ] = lambda : is_incremental
377390
378391 builtin_globals ["builtins" ] = AttributeDict (
@@ -394,7 +407,7 @@ def create_builtin_globals(
394407 quote_policy = api .quote_policy ,
395408 snapshots = jinja_globals .get ("snapshots" , {}),
396409 table_mapping = jinja_globals .get ("table_mapping" , {}),
397- deployability_index = jinja_globals . get ( " deployability_index" ) ,
410+ deployability_index = deployability_index ,
398411 project_dialect = project_dialect ,
399412 )
400413 else :
0 commit comments