Skip to content

Conversation

@Travior
Copy link

@Travior Travior commented Dec 18, 2025

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 18, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@Travior Travior self-assigned this Dec 18, 2025
@Travior Travior marked this pull request as ready for review December 18, 2025 16:46
@Travior Travior requested a review from burnash December 22, 2025 08:05
Copy link
Collaborator

@burnash burnash left a 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:
Copy link
Collaborator

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(
Copy link
Collaborator

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]
Copy link
Collaborator

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.

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.

bigquery_adapter() silently drops partition hint when same column is used for both partition and cluster

3 participants