-
Notifications
You must be signed in to change notification settings - Fork 193
Fix incremental table recreation when defaultProject not set #2057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -882,4 +882,39 @@ defaultIcebergConfig: | |
| }); | ||
| }); | ||
| }); | ||
|
|
||
| test("incremental table without defaultProject in workflow_settings", () => { | ||
| const projectDir = tmpDirFixture.createNewTmpDir(); | ||
| // Create workflow_settings without defaultProject (only defaultDataset and defaultLocation) | ||
| fs.writeFileSync( | ||
| path.join(projectDir, "workflow_settings.yaml"), | ||
| `defaultDataset: dataform | ||
| defaultLocation: europe-west2 | ||
| ` | ||
| ); | ||
| fs.mkdirSync(path.join(projectDir, "definitions")); | ||
| fs.writeFileSync( | ||
| path.join(projectDir, "definitions/incremental_table_without_default_project.sqlx"), | ||
| `config { | ||
| type: "incremental", | ||
| name: "incremental_table_without_default_project" | ||
| } | ||
|
|
||
| select \${incremental()} as is_incremental` | ||
| ); | ||
|
|
||
| const result = runMainInVm(coreExecutionRequestFromPath(projectDir)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that this test will validate the fix because the problem is not on the compilation stage. But anyway the more tests the better :) You'd need to add an integration test here https://github.com/dataform-co/dataform/blob/main/cli/index_test.ts#L951 to validate fix correctness, but I'm ok to accept PR without it. |
||
|
|
||
| expect(result.compile.compiledGraph.graphErrors.compilationErrors).deep.equals([]); | ||
| const compiledTable = result.compile.compiledGraph.tables[0]; | ||
| // Verify the table compiles without database field since defaultProject is not set. | ||
| // The normalizeWarehouseTarget ensures that targets without database | ||
| // are correctly matched with warehouse state during the build phase, allowing incremental | ||
| // appends to work even when defaultProject is not specified in workflow_settings.yaml. | ||
| expect(compiledTable.type).equals("incremental"); | ||
| expect(compiledTable.enumType).equals(dataform.TableType.INCREMENTAL); | ||
| expect(compiledTable.target.schema).equals("dataform"); | ||
| expect(compiledTable.target.name).equals("incremental_table_without_default_project"); | ||
| expect(compiledTable.target.database).equals(""); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to fix a bit differently: here we can set
targetinstead ofmetadataTargetin the metadata structure.It seems to me a more robust and concise solution.