gustavodemorais opened a new pull request, #30114:
URL: https://github.com/apache/flink/pull/30114

   ## What is the purpose of the change
   
   Errors for `FOR SYSTEM_TIME AS OF` joins use planner terms, print the 
optimized plan, or point at the wrong problem. This PR rewrites them so each 
message names the user's columns, states the one requirement that is not met, 
and says how to fix the query. Only the messages change: every check keeps its 
condition, order and exception type.
   
   For example, a right table without a primary key went from
   
       Temporal Table Join requires primary key in versioned table, but no 
primary key can be found. The physical plan is: FlinkLogicalJoin(...)
   
   to
   
       The right side of an event-time temporal join must have a primary key on 
the join key, but none can be derived. Declare PRIMARY KEY (currency) NOT 
ENFORCED on the right table, or deduplicate it to the last row per key with 
ROW_NUMBER() OVER (PARTITION BY currency ORDER BY rate_time DESC) = 1. To join 
each row with the current rows of the right table instead of the version valid 
at the row's time, use a LATERAL SNAPSHOT join, which needs no primary key but 
an append-only left side.
   
   ## Brief change log
   
   - New `TemporalJoinErrors` builds all messages. The rules only call it right 
before they throw.
   - `FOR SYSTEM_TIME AS OF` on a regular column names the column and lists the 
time attributes of the left side.
   - A right side with two rowtimes now says so, instead of "no row time 
attribute can be found".
   - The primary key messages name the right side's columns instead of the 
renamed join columns (`currency0`), and no longer print the plan.
   - A rowtime type mismatch explains to declare the watermark on a column of 
the matching type, and that a CAST in the query does not work.
   - Points to a LATERAL SNAPSHOT join where it is a valid alternative.
   
   ## Verifying this change
   
   - Updated the expected messages in `TemporalJoinTest` and 
`TemporalJoinRewriteWithUniqueKeyRuleTest`, and added cases for two rowtimes on 
the right side, a composite primary key that is only partly joined, a missing 
equality condition, and a processing-time join without primary key.
   - Added `testEventTimeTemporalJoinOnTimestampLtzComputedColumn`, which shows 
that the fix suggested for a rowtime type mismatch plans.
   
   ## Does this pull request potentially affect one of the following parts:
   
   - Dependencies (does it add or upgrade a dependency): no
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): no
   - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
   - The S3 file system connector: no
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 2.1.304 (Opus 5.5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to