Skip to content

Conversation

@ibzib
Copy link

@ibzib ibzib commented Jan 29, 2021

The rule isn't used yet because there are no USER_DEFINED_JAVA_SCALAR_FUNCTIONS yet.

Most of this code was originally written by @amaliujia.

R: @amaliujia @apilloud


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status --- Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status Build Status Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status --- --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

root.rel.getCluster().invalidateMetadataQuery();
return (BeamRelNode) plannerImpl.transform(0, desiredTraits, root.rel);
BeamRelNode beamRelNode = (BeamRelNode) plannerImpl.transform(0, desiredTraits, root.rel);
LOG.info("BEAMPlan>\n" + RelOptUtil.toString(beamRelNode));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we need this LOG.info?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, but it may be useful someday. I actually left this in from your original PR (#12398).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that was added for the purpose of debugging.

Keep this LOG.info is fine. I find that in CalciteQueryPlanner there is also a such LOG.info.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess LOG.debug would probably be better. I might change both planners in a separate PR.

Copy link
Contributor

@amaliujia amaliujia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ibzib ibzib merged commit a497ff2 into apache:master Jan 30, 2021

@Override
public boolean matches(RelOptRuleCall x) {
return ZetaSQLQueryPlanner.hasUdfInProjects(x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is insufficient and likely introduces data corruption bugs if UDFs and regular operators are mixed. I plan to review this pull request on Monday.

Copy link
Member

@apilloud apilloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs tests. What happens if ZetaSQL is mixed with UDFs? It should fail to plan, but as implemented everything will BeamCalcRel.

import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.rel.logical.LogicalCalc;

/** {@link ConverterRule} to replace {@link Calc} with {@link BeamCalcRel}. */
public class BeamJavaUdfCalcRule extends ConverterRule {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You can drop the convert method if you extend BeamCalcRule instead...

}

/** Returns true if the argument contains any user-defined Java functions. */
static boolean hasUdfInProjects(RelOptRuleCall x) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would probably stick this method in BeamZetaSqlCalcRule. What you have here are operators not supported by ZetaSqlCalc.

@amaliujia
Copy link
Contributor

We will need to reject the mixed UDF and builtin functions queries before calc/rule splitting happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants