Skip to content

Conversation

@apilloud
Copy link
Member

This should completely reject non-udfs mixed with Java UDFs.


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.

if (scalarFunction.functionGroup.equals(
SqlAnalyzer.USER_DEFINED_JAVA_SCALAR_FUNCTIONS)) {
udfs.add(i);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Is it guaranteed that none of the RexNode in call.getOperands() contains any subexpression?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a case of nested call?

Copy link
Contributor

Choose a reason for hiding this comment

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

E.g. Increment(1 + 1) where Increment is a UDF?

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 exactly what I was thinking. If that is true, it is necessary to recursively call on each operand.

Copy link
Member

@kennknowles kennknowles Feb 18, 2021

Choose a reason for hiding this comment

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

However, it would be a normal approach to low-level code (like the Program object) to use SSA / A-normal form so that there is no nested expression. I just don't know what Calcite guarantees.

That would cause the project to be turned into:

x = 1 + 1
y = increment(x)

Then recursion is not needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

if there is such form, Calc splitting will become easy to implement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Only RexCall has getOperands. I was under the impression that these operands are garenteed to be prior entries returned in ExprList. It will be a little while before I have time to verify. If that is not the case, it is easy to transform the ExprList into that form. That will need to be true for this to be correct and for calc splitting to be easy.

Copy link
Member

Choose a reason for hiding this comment

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

Yea that is how I expected calc splitting to be implemented as well. I thought that the program was constrained to have that form as well.

Didn't you demonstrate an example like increment(1 + 1) where the + was executed by BeamCalcRel? This is what prompted me to read the code to see if the operands were checked.

Copy link
Member Author

Choose a reason for hiding this comment

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

The case you describe was solved by #13912.

Programs should be normalized before we get here, so RexCall is guaranteed to only reference previous arguments:
https://github.com/apache/calcite/blob/12a484a5c364c36e9551e59f4dc33bfb219ecf07/core/src/main/java/org/apache/calcite/rex/RexProgramBuilder.java#L507

Copy link

Choose a reason for hiding this comment

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

* group is equal to {@code SqlAnalyzer.USER_DEFINED_JAVA_SCALAR_FUNCTIONS}
*/
static boolean hasOnlyJavaUdfInProjects(RelOptRuleCall x) {
HashSet<Integer> udfs = new HashSet<>();
Copy link

Choose a reason for hiding this comment

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

This should be scoped inside for (RelNode relNode : resList).

Does anyone know if it's even possible for x to contain multiple rels?

@ibzib
Copy link

ibzib commented Mar 29, 2021

This isn't necessary since we merged #14010, right?

@apilloud
Copy link
Member Author

At some point we are going to revert #14010. This was intended to be a demonstration of what is required to entirely avoid mixing built-in operations with UDFs.

@apilloud apilloud closed this Mar 29, 2021
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.

4 participants