This is an automated email from the ASF dual-hosted git repository.

htowaileb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 76a80b7976 [NO ISSUE]: Return expression cannot be constant for COPY TO
76a80b7976 is described below

commit 76a80b7976c1eb10aef8135923e002035a2e6a7d
Author: Hussain Towaileb <[email protected]>
AuthorDate: Thu Jun 6 17:11:19 2024 +0300

    [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]>
---
 .../core/algebra/operators/physical/SinkWritePOperator.java      | 9 +++++++++
 .../rewriter/rules/SetAlgebricksPhysicalOperatorsRule.java       | 1 -
 .../main/java/org/apache/hyracks/api/exceptions/ErrorCode.java   | 3 ++-
 .../hyracks-api/src/main/resources/errormsg/en.properties        | 3 ++-
 4 files changed, 13 insertions(+), 3 deletions(-)

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 9c1879feca..b8c1f36eb2 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 @@ public class SinkWritePOperator extends 
AbstractPhysicalOperator {
                 
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 9fd4cd97eb..f945994684 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 @@ public class SetAlgebricksPhysicalOperatorsRule implements 
IAlgebraicRewriteRule
             }
             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 177117ec32..e46c0ef490 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 @@ public enum ErrorCode implements IError {
     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 ea1cc1e7c3..b3c2d7b02d 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

Reply via email to