KevinZwx opened a new pull request #10015: [FLINK-14539][Table 
SQL/Planner]Unique key metadata should be ketp wh…
URL: https://github.com/apache/flink/pull/10015
 
 
   …en using concat or concat_ws in some cases
   
   ## What is the purpose of the change
   
   Currently unique key metadata of a project relnode are only kept in the 
following three situations:
   
   - project the child unique keys while not changing them
   - cast the child unique key when ignoring nulls and the original type of the 
field and cast type are the same
   - rename the child unique keys
   
   Besides these situations, concat and concat_ws should also keep the metadata 
if they won't break the uniqueness of the child unique keys, i.e. each operands 
is in one of the above situations, and the operands include all the child 
unique keys.
   
   Say the f0 and f1 are the unique key fields of the child node, the following 
sqls should keep the unique key metadata
   ```sql
   select concat(f0, f1)
   -- the type of f0 and f1 are both varchar originally and ignore nulls
   select concat(cast(f0 as varchar), f1)
   select cast(concat(f0, f1) as varchar)
   ```
   
   while the following sqls should discard the unique key metadata
   ```sql
   -- the type of f0 and f1 are both varchar originally
   select concat(cast(f0 as bigint), f1)
   select cast(concat(f0, f1) as bigint)
   ```
   
   ## Brief change log
   This PR added a `BuildInToOutMapVisitor` in `FlinkRelMdUniqueKeys` to 
support preserving unique key metadata on using `convert` or `convert_ws` in a 
project node.
   
   ## Verifying this change
   This PR added a new unit test `testGetUniqueKeysOnProjectWithConcat` in 
`FlinkRelMdUniqueKeysTest`
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / 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, Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to