[FLINK-40399][state] Separate SavepointKeyFilter runtime contract from push-down planning - #28982
Conversation
| } | ||
|
|
||
| @Test | ||
| void testOrOfExactAndRangeOnKeyIsNotPushedDownButReturnsCorrectResult() throws Exception { |
There was a problem hiding this comment.
this will be supported in the next MR
| } | ||
|
|
||
| @Test | ||
| void testOrOfTwoRangesOnKeyIsNotPushedDownButReturnsCorrectResult() throws Exception { |
There was a problem hiding this comment.
also will be supported in the next MR
|
@flinkbot run azure |
|
fyi: merge commit is always a blocker |
|
Thanks for the efforts! Shrinking the public API surface here is the right direction, good call splitting the runtime contract from the push-down-only algebra. That said, Flink's existing filter push-down connectors (e.g. Right now Could this be done without the duplication by keeping the intersect/bounds combining logic as private computation inside |
|
Thanks for fixing, the code looks good but the description is stale. |
|
This fixes two cases where converting numeric literals to the key type could produce an incorrect pushed-down filter. First,
Second, converting an integral FLOAT or DOUBLE literal to one exact BIGINT bound is not always safe. When a BIGINT key is compared with a FLOAT or DOUBLE literal, SQL coerces the BIGINT operand to an approximate numeric type. At large magnitudes, adjacent BIGINT values can then round to the same value. For example:
The fix uses For DOUBLE keys, finite numeric literals are converted to DOUBLE because SQL applies the same conversion to the literal. Tests cover fractional and out-of-range values, NaN and infinity, positive and negative precision boundaries, equality and range predicates, and values immediately below the boundaries that remain safe to push. |
|
I'm fine with the bugfix, found some gaps: Test gap: add (or restore, adapted) a test for = against a DOUBLE key with a Long literal that isn't exactly representable as a double (e.g. key = Description: rephrase "There is no change to the supported predicates or their push-down behavior" since it's no longer accurate since the DOUBLE-key precision-loss case now pushes down where it previously didn't. |
|
Seems like unrelated test issues, can you plz kick it green? |
|
as it was mentioned at #28982 (comment) |
|
Good catch, just for my own understanding squash and merge won't resolve that? Or what would happen? |
based on my experience (a couple of years ago) it does not Not sure if Github changed this behavior |
|
Good to be on safe side, thanks! |
…own planning Keep SavepointKeyFilter focused on runtime filtering and move predicate-combination state into SavepointFilterTranslator. Preserve SQL comparison semantics when converting numeric literals for BIGINT and DOUBLE key push-down.
merged commit removed, dismissing requesting changes
What is the purpose of the change
SavepointKeyFiltercurrently combines two responsibilities:testandgetExactKeys); andisEmpty, bounds, intersection, key filtering, andBoundInfo).The planning methods are public even though DataStream API implementations do not use them. This change keeps only the runtime contract on
SavepointKeyFilterand moves predicate-combination state intoSavepointFilterTranslator.The supported predicate shapes are unchanged, but numeric literal conversion now preserves SQL comparison semantics. Safe conversions to BIGINT or DOUBLE are pushed down. Lossy BIGINT conversions—such as truncating 1.5 to 1—and approximate values that can alias multiple BIGINT keys are no longer pushed down.
Brief change log
SavepointKeyFilterfocused ontest(K),getExactKeys(), and theexact(...)/range(...)factories.BoundInfo, andEmptyKeyFilter, without introducing a separate table-side filter-plan hierarchy.KeyFilterPlaninsideSavepointFilterTranslatorwhile walking expressions. It performs the existing intersection logic and creates the finalSavepointKeyFilter.exact(...)orSavepointKeyFilter.range(...)only after translation.ExactKeyFilterandRangeKeyFilterso they contain only runtime filtering behavior. An empty exact-key set now represents a filter that matches nothing.empty()factory and planning-method references.Verifying this change
The tests cover:
remaining()so they are still evaluated;AND/ORpush-down;The existing limitation is preserved:
ORonly combines finite exact-key predicates. For example,k = 5 OR k < 10and disjunctions of ranges are not pushed down and remain for normal SQL evaluation.Does this pull request potentially affect one of the following parts:
@Experimental). Planning-only methods andempty()are removed fromSavepointKeyFilter; its runtime contract (test,getExactKeys) and exact/range factories remain.Documentation
docs/contentanddocs/content.zhfor the reduced interface.Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5)