Skip to content
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

[BigQuery] Missed one spot for aliasing #690

Merged
merged 6 commits into from
May 17, 2024
Merged

[BigQuery] Missed one spot for aliasing #690

merged 6 commits into from
May 17, 2024

Conversation

Tang8330
Copy link
Contributor

As per title

@Tang8330 Tang8330 marked this pull request as ready for review May 17, 2024 01:22
@@ -43,7 +44,7 @@ func (b *BigQuerySettings) GenerateMergeString(values []string) (string, error)
case "time":
switch b.PartitionBy {
case "daily":
return fmt.Sprintf(`DATE(c.%s) IN (%s)`, b.PartitionField, array.StringsJoinAddSingleQuotes(values)), nil
return fmt.Sprintf(`DATE(%s.%s) IN (%s)`, constants.TargetAlias, b.PartitionField, array.StringsJoinAddSingleQuotes(values)), nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sneaky!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is b.PartitionField always a column? Should we be quoting it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so could do sql.QuoteTableAliasColumns(constants.TargetAlias, columns.Column(b.PartitionField, typing.Invalid), BigQueryDialect{})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using the sql package at all may cause an import cycle, so maybe something to look at after this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should escape it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave a TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I can just move this to the bq pkg

@@ -49,3 +53,29 @@ func (s *Store) Merge(tableData *optimization.TableData) error {
RetryColBackfill: true,
})
}

func generateMergeString(bqSettings *partition.BigQuerySettings, dialect sql.Dialect, values []string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@Tang8330 Tang8330 merged commit 7066de7 into master May 17, 2024
1 check passed
@Tang8330 Tang8330 deleted the fix-bq branch May 17, 2024 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants