-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-15381] [table-planner-blink] correct collation derive logic on RelSubset in RelMdCollation #10694
Conversation
* {@link org.apache.calcite.rel.metadata.RelMetadataQuery#collations} | ||
* for the standard logical algebra. | ||
*/ | ||
public class FlinkRelMdCollation implements MetadataHandler<BuiltInMetadata.Collation> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most logic (except the part about RelSebset) is same with RelMdCollation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add the comment in The code. It's really a long class.
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit e9b4471 (Thu Dec 26 07:17:26 UTC 2019) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
@flinkbot run travis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@godfreyhe ,the fix makes sense.
However, it's better to fix the bug in Calcite.
Or Mark "The class should be removed after CALCITE-{JIARANUMBER} is fixed." in the header comment of the class.
What do you think?
return mq.collations(rel.getOriginal()); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix makes sense.
* {@link org.apache.calcite.rel.metadata.RelMetadataQuery#collations} | ||
* for the standard logical algebra. | ||
*/ | ||
public class FlinkRelMdCollation implements MetadataHandler<BuiltInMetadata.Collation> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add the comment in The code. It's really a long class.
thanks for the suggestion @beyond1920 . Flink had rewritten most metadata handlers defined in Calcite. I think we should keep this class in order to support more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm agreed with you.
However it's unsafe to throw exception in the else branch.
RelNode rel = Util.first(subset.getBest(), subset.getOriginal()); | ||
return mq.collations(rel); | ||
} else { | ||
throw new RuntimeException("CALCITE_1048 is fixed, so check this method again!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unsafe to throw exception here.
|
LGTM |
@godfreyhe could you remove the cast string on this line? Line 229 in 2e9a7f3
It should work now if the bug is fixed. |
… RelSubset in RelMdCollation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the effort @godfreyhe .
…Subset in RelMdCollation (#10694)
What is the purpose of the change
sql:
select cast(a as int), cast(b as varchar) from (values (3, 'c')) T(a,b)
will fail,the reason is: the original LogicalProject has collation trait (see the picture in FLINK-15381: [1] which means the second field is ordered and its direction is ascending), but when LogicalProject converts to LogicalCalc in ProjectToCalcRule, the collation info of new Calc is empty. The root cause is the collation derive logic on RelSubset in RelMdCollation in not collect.
This PR aim to fix the bug
Brief change log
Verifying this change
This change added tests and can be verified as follows:
select cast(a as int), cast(b as varchar) from (values (3, 'c')) T(a,b)
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation