[ 
https://issues.apache.org/jira/browse/FLINK-14539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16960873#comment-16960873
 ] 

Jark Wu edited comment on FLINK-14539 at 10/28/19 9:01 AM:
-----------------------------------------------------------

Hi [~danny0405], I think the reason to use {{RexBiVisitor}} instead of 
{{RexVisitor}} is we need the operands information, i.e. uniqueness of 
operands. We can pass it to the constructor of RexVisitor, but I think using 
RexBiVisitor is much cleaner. 
However I didn't find any evidence that RexBiVisitor is used for three-valued 
boolean logic from the javadoc of RexBiVisitor. 


was (Author: jark):
Hi [~danny0405], the I think the reason to use {{RexBiVisitor}} instead of 
{{RexVisitor}} is we need the operands information, i.e. uniqueness of 
operands. We can pass it to the constructor of RexVisitor, but I think using 
RexBiVisitor is much cleaner. 
However I didn't find any evidence that RexBiVisitor is used for three-valued 
boolean logic from the javadoc of RexBiVisitor. 

> Unique key metadata should be ketp when using concat or concat_ws in some 
> cases
> -------------------------------------------------------------------------------
>
>                 Key: FLINK-14539
>                 URL: https://issues.apache.org/jira/browse/FLINK-14539
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.9.0, 1.9.1
>            Reporter: Kevin Zhang
>            Priority: Major
>
> 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 
> {code: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)
> {code}
> while the following sqls should discard the unique key metadata
> {code: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)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to