File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1082,8 +1082,20 @@ export class VSCodeCommands implements Disposable {
1082
1082
return ;
1083
1083
}
1084
1084
1085
- // Build the complete query
1086
- let query = "WITH " ;
1085
+ // Build the complete query including preamble before WITH clause
1086
+ // Extract everything before the WITH clause (dbt configs, variables, etc.)
1087
+ const preamble = text . substring ( 0 , targetCte . withClauseStart ) . trim ( ) ;
1088
+
1089
+ let query = "" ;
1090
+ if ( preamble ) {
1091
+ query += preamble + "\n\n" ;
1092
+ this . dbtTerminal . debug (
1093
+ "CteExecution" ,
1094
+ `Including preamble (${ preamble . length } chars) before WITH clause` ,
1095
+ ) ;
1096
+ }
1097
+
1098
+ query += "WITH " ;
1087
1099
query += cteDefinitions . join ( ",\n" ) ;
1088
1100
1089
1101
// Add a simple SELECT to execute the target CTE with proper quoting
You can’t perform that action at this time.
0 commit comments