88 exampleBuiltInAssertions ,
99 exampleBuiltInAssertionsAsYaml
1010} from "df/core/actions/index_test" ;
11- import { dataform } from "df/protos/ts" ;
11+ import { dataform } from "df/protos/ts" ;
1212import { asPlainObject , suite , test } from "df/testing" ;
1313import { TmpDirFixture } from "df/testing/fixtures" ;
1414import {
@@ -396,7 +396,7 @@ defaultIcebergConfig:
396396 }
397397 }` ,
398398 expected : {
399- target : { name : "incremental_table1" , schema : "dataset1" , database : "defaultProject" } ,
399+ target : { name : "incremental_table1" , schema : "dataset1" , database : "defaultProject" } ,
400400 bigquery : {
401401 tableFormat : "ICEBERG" ,
402402 fileFormat : "PARQUET" ,
@@ -423,7 +423,7 @@ defaultIcebergConfig:
423423 }
424424 }` ,
425425 expected : {
426- target : { name : "incremental_table2" , schema : "dataset2" , database : "defaultProject" } ,
426+ target : { name : "incremental_table2" , schema : "dataset2" , database : "defaultProject" } ,
427427 bigquery : {
428428 tableFormat : "ICEBERG" ,
429429 fileFormat : "PARQUET" ,
@@ -449,7 +449,7 @@ defaultIcebergConfig:
449449 }
450450 }` ,
451451 expected : {
452- target : { name : "incremental_table3" , schema : "dataset3" , database : "defaultProject" } ,
452+ target : { name : "incremental_table3" , schema : "dataset3" , database : "defaultProject" } ,
453453 bigquery : {
454454 tableFormat : "ICEBERG" ,
455455 fileFormat : "PARQUET" ,
@@ -475,7 +475,7 @@ defaultIcebergConfig:
475475 }
476476 }` ,
477477 expected : {
478- target : { name : "my-incremental" , schema : "my-dataset" , database : "defaultProject" } ,
478+ target : { name : "my-incremental" , schema : "my-dataset" , database : "defaultProject" } ,
479479 bigquery : {
480480 tableFormat : "ICEBERG" ,
481481 fileFormat : "PARQUET" ,
@@ -500,7 +500,7 @@ defaultIcebergConfig:
500500 }
501501 }` ,
502502 expected : {
503- target : { name : "my-incremental" , schema : "defaultDataset" , database : "defaultProject" } ,
503+ target : { name : "my-incremental" , schema : "defaultDataset" , database : "defaultProject" } ,
504504 bigquery : {
505505 tableFormat : "ICEBERG" ,
506506 fileFormat : "PARQUET" ,
@@ -526,7 +526,7 @@ defaultIcebergConfig:
526526 }
527527 }` ,
528528 expected : {
529- target : { name : "incremental_table6" , schema : "dataset6" , database : "defaultProject" } ,
529+ target : { name : "incremental_table6" , schema : "dataset6" , database : "defaultProject" } ,
530530 bigquery : {
531531 tableFormat : "ICEBERG" ,
532532 fileFormat : "PARQUET" ,
@@ -552,7 +552,7 @@ defaultIcebergConfig:
552552 }
553553 }` ,
554554 expected : {
555- target : { name : "incremental_table7" , schema : "dataset7" , database : "defaultProject" } ,
555+ target : { name : "incremental_table7" , schema : "dataset7" , database : "defaultProject" } ,
556556 bigquery : {
557557 tableFormat : "ICEBERG" ,
558558 fileFormat : "PARQUET" ,
@@ -579,7 +579,7 @@ defaultIcebergConfig:
579579 }
580580 }` ,
581581 expected : {
582- target : { name : "incremental_table8" , schema : "dataset8" , database : "defaultProject" } ,
582+ target : { name : "incremental_table8" , schema : "dataset8" , database : "defaultProject" } ,
583583 bigquery : {
584584 tableFormat : "ICEBERG" ,
585585 fileFormat : "PARQUET" ,
@@ -657,16 +657,16 @@ defaultIcebergConfig:
657657 }
658658 }` ,
659659 expected : {
660- target : { name : "iceberg_incremental_mixed" , schema : "mixed_dataset" , database : "defaultProject" } ,
660+ target : { name : "iceberg_incremental_mixed" , schema : "mixed_dataset" , database : "defaultProject" } ,
661661 bigquery : {
662662 tableFormat : "ICEBERG" ,
663663 fileFormat : "PARQUET" ,
664664 connection : "gcp.us.conn-id" ,
665665 storageUri : "gs://my-bucket/my-root/my-subpath" ,
666666 partitionBy : "partition_col" ,
667667 clusterBy : [ "cluster_col1" , "cluster_col2" ] ,
668- labels : { "env" : "test" , "type" : "iceberg" } ,
669- additionalOptions : { "key1" : "val1" , "key2" : "val2" } ,
668+ labels : { "env" : "test" , "type" : "iceberg" } ,
669+ additionalOptions : { "key1" : "val1" , "key2" : "val2" } ,
670670 } ,
671671 } ,
672672 expectError : false ,
@@ -829,7 +829,7 @@ defaultIcebergConfig:
829829 } ,
830830 expectError : false ,
831831 } ,
832- {
832+ {
833833 testName : "bucketName not defined in config or workspace settings" ,
834834 configBlock : `
835835 type: "incremental",
@@ -927,4 +927,60 @@ select \${incremental()} as is_incremental`
927927 expect ( compiledTable . target . name ) . equals ( "incremental_table_without_default_project" ) ;
928928 expect ( compiledTable . target . database ) . equals ( "" ) ;
929929 } ) ;
930+
931+ suite ( "jit compilation" , ( ) => {
932+ test ( "jit compilation is supported" , ( ) => {
933+ const projectDir = tmpDirFixture . createNewTmpDir ( ) ;
934+ fs . writeFileSync ( path . join ( projectDir , "workflow_settings.yaml" ) , VALID_WORKFLOW_SETTINGS_YAML ) ;
935+ fs . mkdirSync ( path . join ( projectDir , "definitions" ) ) ;
936+ fs . writeFileSync (
937+ path . join ( projectDir , "definitions/incremental.js" ) ,
938+ `publish("incremental", {type: "incremental"}).jitCode((ctx) => Promise.resolve({query: "select 1", incrementalQuery: "select 1"}))`
939+ ) ;
940+
941+ const result = runMainInVm ( coreExecutionRequestFromPath ( projectDir ) ) ;
942+
943+ expect ( result . compile . compiledGraph . graphErrors . compilationErrors ) . deep . equals ( [ ] ) ;
944+ expect ( asPlainObject ( result . compile . compiledGraph . tables ) ) . deep . equals ( [
945+ {
946+ target : {
947+ database : "defaultProject" ,
948+ schema : "defaultDataset" ,
949+ name : "incremental"
950+ } ,
951+ canonicalTarget : {
952+ database : "defaultProject" ,
953+ schema : "defaultDataset" ,
954+ name : "incremental"
955+ } ,
956+ type : "incremental" ,
957+ enumType : "INCREMENTAL" ,
958+ disabled : false ,
959+ protected : false ,
960+ hermeticity : "NON_HERMETIC" ,
961+ onSchemaChange : "IGNORE" ,
962+ fileName : "definitions/incremental.js" ,
963+ jitCode : '(ctx) => Promise.resolve({query: "select 1", incrementalQuery: "select 1"})' ,
964+ actionDescriptor : {
965+ compilationMode : "ACTION_COMPILATION_MODE_JIT"
966+ }
967+ }
968+ ] ) ;
969+ } ) ;
970+
971+ test ( "jit compilation fails if query is also provided" , ( ) => {
972+ const projectDir = tmpDirFixture . createNewTmpDir ( ) ;
973+ fs . writeFileSync ( path . join ( projectDir , "workflow_settings.yaml" ) , VALID_WORKFLOW_SETTINGS_YAML ) ;
974+ fs . mkdirSync ( path . join ( projectDir , "definitions" ) ) ;
975+ fs . writeFileSync (
976+ path . join ( projectDir , "definitions/incremental.js" ) ,
977+ `publish("incremental", {type: "incremental"}).jitCode((ctx) => ({query: "select 1", incrementalQuery: "select 1"})).query("select 1")`
978+ ) ;
979+
980+ const result = runMainInVm ( coreExecutionRequestFromPath ( projectDir ) ) ;
981+
982+ expect ( result . compile . compiledGraph . graphErrors . compilationErrors . length ) . greaterThan ( 0 ) ;
983+ expect ( result . compile . compiledGraph . graphErrors . compilationErrors . some ( e => e . message . includes ( "Cannot mix AoT and JiT compilation" ) ) ) . equals ( true ) ;
984+ } ) ;
985+ } ) ;
930986} ) ;
0 commit comments