-
Notifications
You must be signed in to change notification settings - Fork 414
Fix cluster hint overriding partition hint on bigquery #3497
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: devel
Are you sure you want to change the base?
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | c0fcefd | Commit Preview URL Branch Preview URL |
Dec 18 2025, 02:23 PM |
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.
The fix is correct. Please see the comments for the 2 minor improvements: additional unit test and a small refactor, which may help if another hint type is added later and a developer might forgets to use setdefault and reintroduces the bug.
| assert expected_clause in sql_partitioned | ||
|
|
||
|
|
||
| def test_adapter_hints_comprehensive_single_column() -> None: |
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.
A unit test is good. But this particular scenario likely already worked before the fix because bigquery_adapter() below creates a new column_hints = {} each time.
It's best to add also a unit test for the actual bug: a single call with both partition and cluster on the same column.
| destinations_configs(default_sql_configs=True, subset=["bigquery"]), | ||
| ids=lambda x: x.name, | ||
| ) | ||
| def test_adapter_hints_clustering_and_partitioning( |
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.
Good!
|
|
||
| if isinstance(partition, str): | ||
| column_hints[partition] = {"name": partition, PARTITION_HINT: True} # type: ignore[typeddict-unknown-key] | ||
| column_hints.setdefault(partition, {"name": partition})[PARTITION_HINT] = True # type: ignore[typeddict-unknown-key] |
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.
This fix is correct.
Here's also a chance to improve code quality: this pattern of setting column hints repeats 4 times. Let's extract this pattern into a helper function (e.g. _set_column_hint()) for maintainability. Most likely it could be used in other adapters, but this is a for a follow-up PR. For now I'd keep _set_column_hint in this module.
Fixes a bug where applying both a partition hint and a cluster hint on the same column would result in the partition hint being silently dropped.
Closes #3471