>From Hussain Towaileb <[email protected]>:

Hussain Towaileb has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18345 )

Change subject: [NO ISSUE]: Return expression cannot be constant for COPY TO
......................................................................

[NO ISSUE]: Return expression cannot be constant for COPY TO

Change-Id: I02723741458e3fa04877c0099990405e7755f656
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18345
Reviewed-by: Wail Alkowaileet <[email protected]>
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
---
M 
hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SinkWritePOperator.java
M 
hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
M 
hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/SetAlgebricksPhysicalOperatorsRule.java
M 
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
4 files changed, 26 insertions(+), 3 deletions(-)

Approvals:
  Wail Alkowaileet: Looks good to me, approved
  Jenkins: Verified; Verified




diff --git 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SinkWritePOperator.java
 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SinkWritePOperator.java
index 9c1879f..b8c1f36 100644
--- 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SinkWritePOperator.java
+++ 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SinkWritePOperator.java
@@ -147,15 +147,24 @@
                 
JobGenHelper.variablesToAscBinaryComparatorFactories(partitionVariables, 
typeEnv, context);
 
         // Key expressions
+        boolean allConstants = true;
         IScalarEvaluatorFactory[] keyEvalFactories = new 
IScalarEvaluatorFactory[write.getKeyExpressions().size()];
         List<Mutable<ILogicalExpression>> keyExpressions = 
write.getKeyExpressions();
         if (!keyExpressions.isEmpty()) {
             for (int i = 0; i < keyExpressions.size(); i++) {
                 ILogicalExpression keyExpr = keyExpressions.get(i).getValue();
+                if (keyExpr.getExpressionTag() != 
LogicalExpressionTag.CONSTANT) {
+                    allConstants = false;
+                }
                 keyEvalFactories[i] = 
runtimeProvider.createEvaluatorFactory(keyExpr, typeEnv, inputSchemas, context);
             }
         }

+        // key cannot be fully constant
+        if (!keyExpressions.isEmpty() && allConstants) {
+            throw 
AlgebricksException.create(ErrorCode.EXPRESSION_CANNOT_BE_CONSTANT, 
op.getSourceLocation(), "KEY");
+        }
+
         RecordDescriptor recDesc =
                 
JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), 
propagatedSchema, context);
         RecordDescriptor inputDesc = JobGenHelper.mkRecordDescriptor(
diff --git 
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/SetAlgebricksPhysicalOperatorsRule.java
 
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/SetAlgebricksPhysicalOperatorsRule.java
index 9fd4cd9..f945994 100644
--- 
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/SetAlgebricksPhysicalOperatorsRule.java
+++ 
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/SetAlgebricksPhysicalOperatorsRule.java
@@ -408,7 +408,6 @@
             }
             ensureAllVariables(op.getPartitionExpressions(), v -> v);
             ensureAllVariables(op.getOrderExpressions(), Pair::getSecond);
-            ensureAllVariables(op.getKeyExpressions(), v -> v);
             return new SinkWritePOperator(op.getSourceVariable(), 
op.getPartitionVariables(), op.getOrderColumns());
         }

diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
index 177117e..e46c0ef 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
@@ -166,7 +166,8 @@
     OPERATOR_NOT_IMPLEMENTED(10005),
     INAPPLICABLE_HINT(10006),
     CROSS_PRODUCT_JOIN(10007),
-    GROUP_ALL_DECOR(10008);
+    GROUP_ALL_DECOR(10008),
+    EXPRESSION_CANNOT_BE_CONSTANT(10009);

     private static final String RESOURCE_PATH = "errormsg/en.properties";
     public static final String HYRACKS = "HYR";
diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
index ea1cc1e..b3c2d7b 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
@@ -155,4 +155,5 @@
 10005 = Operator is not implemented: %1$s
 10006 = Could not apply %1$s hint: %2$s
 10007 = Encountered a cross product join
-10008 = Inappropriate use of group by all with decor variables
\ No newline at end of file
+10008 = Inappropriate use of group by all with decor variables
+10009 = '%1$s' expression cannot be a constant
\ No newline at end of file

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18345
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I02723741458e3fa04877c0099990405e7755f656
Gerrit-Change-Number: 18345
Gerrit-PatchSet: 4
Gerrit-Owner: Hussain Towaileb <[email protected]>
Gerrit-Reviewer: Hussain Towaileb <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Wail Alkowaileet <[email protected]>
Gerrit-MessageType: merged

Reply via email to