[
https://issues.apache.org/jira/browse/BEAM-11747?focusedWorklogId=552813&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-552813
]
ASF GitHub Bot logged work on BEAM-11747:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 16/Feb/21 04:49
Start Date: 16/Feb/21 04:49
Worklog Time Spent: 10m
Work Description: amaliujia commented on a change in pull request #13912:
URL: https://github.com/apache/beam/pull/13912#discussion_r576547245
##########
File path:
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLQueryPlanner.java
##########
@@ -116,8 +116,43 @@ public QueryPlanner createPlanner(
return modifyRuleSetsForZetaSql(BeamRuleSets.getRuleSets());
}
- /** Returns true if the argument contains any user-defined Java functions. */
- static boolean hasUdfInProjects(RelOptRuleCall x) {
+ /**
+ * Returns true if the arguments only contain any user-defined Java
functions, otherwise returns
+ * false.
+ */
+ static boolean hasOnlyJavaUdfInProjects(RelOptRuleCall x) {
+ List<RelNode> resList = x.getRelList();
+ for (RelNode relNode : resList) {
+ if (relNode instanceof LogicalCalc) {
+ LogicalCalc logicalCalc = (LogicalCalc) relNode;
+ for (RexNode rexNode : logicalCalc.getProgram().getExprList()) {
+ if (rexNode instanceof RexCall) {
+ RexCall call = (RexCall) rexNode;
+ if (call.getOperator() instanceof SqlUserDefinedFunction) {
+ SqlUserDefinedFunction udf = (SqlUserDefinedFunction) call.op;
+ if (udf.function instanceof ZetaSqlScalarFunctionImpl) {
+ ZetaSqlScalarFunctionImpl scalarFunction =
(ZetaSqlScalarFunctionImpl) udf.function;
+ if (!scalarFunction.functionGroup.equals(
+ SqlAnalyzer.USER_DEFINED_JAVA_SCALAR_FUNCTIONS)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns false if the argument contains any user-defined Java functions,
otherwise returns true.
+ */
+ static boolean hasNoJavaUdfInProjects(RelOptRuleCall x) {
Review comment:
I agreed this might be better. But I think it's bit tricky to implement
the positive version of `hasNoJavaUdfInProjects `. The `hasNoJavaUdfInProjects
` is more error prone at this moment (we only need to consider java udf).
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 552813)
Time Spent: 2h 20m (was: 2h 10m)
> Reject the mixed Java UDF and ZetaSQL builtin operators cases
> --------------------------------------------------------------
>
> Key: BEAM-11747
> URL: https://issues.apache.org/jira/browse/BEAM-11747
> Project: Beam
> Issue Type: Sub-task
> Components: dsl-sql-zetasql
> Reporter: Rui Wang
> Assignee: Rui Wang
> Priority: P2
> Time Spent: 2h 20m
> Remaining Estimate: 0h
>
> Before we have Calc splitting implemented, we can reject the mixed Java UDF
> and ZetaSQL builtin operators cases to maintain the correctness of a query.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)