-
Notifications
You must be signed in to change notification settings - Fork 167
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
Update incremental table execution to avoid create or replace #1712
base: main
Are you sure you want to change the base?
Conversation
}${options.length > 0 ? `OPTIONS(${options.join(",")})` : ""}as ${table.query}`; | ||
let statement = "create "; | ||
if (table.enumType !== dataform.TableType.INCREMENTAL) { | ||
statement += "or replace "; |
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.
From the bug - I think we still want to create or replace in the case that it is incremental AND it's not projected AND it's full refresh?
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.
We should also add a test for this case
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.
What is projected? Have added the full refresh.
This is tested, but not obviously, across
dataform/tests/api/api.spec.ts
Line 463 in c55ca6b
const expectedExecutionActions: dataform.IExecutionAction[] = [ |
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.
*protected!
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.
Ah right! Done.
I had to update the protected logic, such as removing the error that we test for here
dataform/tests/api/api.spec.ts
Line 109 in c55ca6b
test("trying to fully refresh a protected dataset fails", () => { |
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.
Right, sorry I think this has got really confusing, a few thoughts.
- leave this method as
createOrReplace
and don't pass in run options or do all that logic. - Add a
createIfNotExists
method next to it (they can share some private impl if you want, but I wouldn't bother) - Update the logic in publishTasks, only for the incremental tables, to do what you want to do and call
createIfNotExists
by default, andcreateOrReplace
only when!protected && fullRefresh
The original method was clear what it did, but now you've moved this logic into it, I'd say it's much harder to follow what's going on in publishTasks
.
@@ -74,10 +74,6 @@ export class Builder { | |||
tableMetadata: dataform.ITableMetadata, | |||
runConfig: dataform.IRunConfig | |||
) { | |||
if (table.protected && this.runConfig.fullRefresh) { |
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.
Can we keep this?
Fixes #1561