You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2026/09/27 12:03:53 UTC
(asterixdb) branch master updated (0acebe2ecc -> bd61aac4d0)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
from 0acebe2ecc [NO ISSUE][STO] Cap flush leaf size on all columns
new a8f5ea5319 [NO ISSUE][MISC] Advance the AWS SDK to 2.55.5
new 131d840e8f [NO ISSUE][MISC] Advance the GCS SDK to 2.74.0
new e476e1bac9 Merge branch 'gerrit/trinity' into 'gerrit/morpheus'
new 55baa9cfd8 [ASTERIXDB-3899][COMP] Do not constant-fold median
new 6175d4c656 Merge branch 'gerrit/trinity' into 'gerrit/morpheus'
new 2d2b77d6a2 Merge branch 'gerrit/morpheus' into 'master'
new bd61aac4d0 Merge "Merge branch 'gerrit/morpheus' into 'master'"
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../optimizer/rules/visitor/ConstantFoldingVisitor.java | 7 ++++++-
.../scalar_median.1.query.sqlpp} | 6 ++----
.../scalar_median/scalar_median.2.query.sqlpp} | 13 +++++++++++--
.../scalar_median.3.query.sqlpp} | 5 +++--
.../scalar_median/scalar_median.1.adm} | 0
.../results/aggregate-sql/scalar_median/scalar_median.2.adm | 1 +
.../scalar_median/scalar_median.3.adm} | 0
.../src/test/resources/runtimets/sqlpp_queries.xml | 5 +++++
asterixdb/pom.xml | 4 ++--
hyracks-fullstack/pom.xml | 6 +++---
10 files changed, 33 insertions(+), 14 deletions(-)
copy asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/{scalar_avg_null/scalar_avg_null.1.ddl.sqlpp => scalar_median/scalar_median.1.query.sqlpp} (86%)
copy asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/{misc/dataset-resources/dataset-resources.4.query.sqlpp => aggregate-sql/scalar_median/scalar_median.2.query.sqlpp} (72%)
copy asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/{countn_empty_01/countn_empty_01.2.update.sqlpp => scalar_median/scalar_median.3.query.sqlpp} (84%)
copy asterixdb/asterix-app/src/test/resources/runtimets/results/{aggregate/query-ASTERIXDB-1230/query-ASTERIXDB-1230.1.adm => aggregate-sql/scalar_median/scalar_median.1.adm} (100%)
create mode 100644 asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.2.adm
copy asterixdb/asterix-app/src/test/resources/runtimets/results/{aggregate/query-ASTERIXDB-1230/query-ASTERIXDB-1230.1.adm => aggregate-sql/scalar_median/scalar_median.3.adm} (100%)
(asterixdb) 05/07: Merge branch 'gerrit/trinity' into 'gerrit/morpheus'
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 6175d4c6565bcc613ef68c9994568c97fb0d027c
Merge: e476e1bac9 55baa9cfd8
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Fri Sep 25 17:55:49 2026 -0400
Merge branch 'gerrit/trinity' into 'gerrit/morpheus'
* [ASTERIXDB-3899][COMP] Do not constant-fold median (MB-74216)
Generated-By: Claude Opus 5.5 <no...@anthropic.com>
Change-Id: I47d705b2efa9143cd3f6bdeacf538db2136d918b
Ext-ref: MB-74216
.../optimizer/rules/ConstantFoldingRule.java | 7 +++++-
.../scalar_median/scalar_median.1.query.sqlpp | 24 ++++++++++++++++++
.../scalar_median/scalar_median.2.query.sqlpp | 29 ++++++++++++++++++++++
.../scalar_median/scalar_median.3.query.sqlpp | 25 +++++++++++++++++++
.../scalar_median/scalar_median.1.adm | 1 +
.../scalar_median/scalar_median.2.adm | 1 +
.../scalar_median/scalar_median.3.adm | 1 +
.../src/test/resources/runtimets/sqlpp_queries.xml | 5 ++++
8 files changed, 92 insertions(+), 1 deletion(-)
(asterixdb) 02/07: [NO ISSUE][MISC] Advance the GCS SDK to 2.74.0
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 131d840e8f9f2aede1aa915d1c351a0bf828b111
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Thu Sep 24 18:48:27 2026 -0400
[NO ISSUE][MISC] Advance the GCS SDK to 2.74.0
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
Ext-ref: MB-73268
Change-Id: If82d8be5b7d4f39e1ed987c623212dc7dd46716e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21885
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mb...@apache.org>
---
asterixdb/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/asterixdb/pom.xml b/asterixdb/pom.xml
index 4908aff3e1..54f1741825 100644
--- a/asterixdb/pom.xml
+++ b/asterixdb/pom.xml
@@ -105,7 +105,7 @@
<azurecore.version>1.59.1</azurecore.version>
<azurecorehttpnetty.version>1.16.7</azurecorehttpnetty.version>
- <gcsjavasdk.version>2.73.0</gcsjavasdk.version>
+ <gcsjavasdk.version>2.74.0</gcsjavasdk.version>
<hadoop-azuresdk.version>8.6.6</hadoop-azuresdk.version>
<hadoop-gcs.version>hadoop3-2.2.25</hadoop-gcs.version>
<io.opencensus.version>0.31.1</io.opencensus.version>
(asterixdb) 07/07: Merge "Merge branch 'gerrit/morpheus' into 'master'"
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit bd61aac4d0479c8d70368f26d2de7a48659bae97
Merge: 0acebe2ecc 2d2b77d6a2
Author: Apache AsterixDB Gerrit <de...@asterixdb.apache.org>
AuthorDate: Sun Sep 27 04:36:04 2026 +0000
Merge "Merge branch 'gerrit/morpheus' into 'master'"
.../rules/visitor/ConstantFoldingVisitor.java | 7 +++++-
.../scalar_median/scalar_median.1.query.sqlpp | 24 ++++++++++++++++++
.../scalar_median/scalar_median.2.query.sqlpp | 29 ++++++++++++++++++++++
.../scalar_median/scalar_median.3.query.sqlpp | 25 +++++++++++++++++++
.../scalar_median/scalar_median.1.adm | 1 +
.../scalar_median/scalar_median.2.adm | 1 +
.../scalar_median/scalar_median.3.adm | 1 +
.../src/test/resources/runtimets/sqlpp_queries.xml | 5 ++++
asterixdb/pom.xml | 4 +--
hyracks-fullstack/pom.xml | 6 ++---
10 files changed, 97 insertions(+), 6 deletions(-)
(asterixdb) 01/07: [NO ISSUE][MISC] Advance the AWS SDK to 2.55.5
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit a8f5ea53195d05e14ec98261ee2c8033c5f23eb5
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Thu Sep 24 18:41:08 2026 -0400
[NO ISSUE][MISC] Advance the AWS SDK to 2.55.5
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
Ext-ref: MB-73268
Change-Id: I1d5cf529808a88ed018e0932ea70ef2156a414a1
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21884
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mb...@apache.org>
---
asterixdb/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/asterixdb/pom.xml b/asterixdb/pom.xml
index e310195b04..4908aff3e1 100644
--- a/asterixdb/pom.xml
+++ b/asterixdb/pom.xml
@@ -93,7 +93,7 @@
<hadoop.version>3.4.3</hadoop.version>
<jacoco.version>0.7.6.201602180812</jacoco.version>
<log4j.version>2.26.1</log4j.version>
- <awsjavasdk.version>2.55.3</awsjavasdk.version>
+ <awsjavasdk.version>2.55.5</awsjavasdk.version>
<s3mock.version>5.2.3</s3mock.version>
<parquet.version>1.18.1</parquet.version> <!-- NOTICE: please update transitives from parquet below on any change -->
<hadoop-awsjavasdk.version>1.12.797</hadoop-awsjavasdk.version>
(asterixdb) 03/07: Merge branch 'gerrit/trinity' into 'gerrit/morpheus'
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit e476e1bac92ba7527dc3f578e9182f83041ffb1e
Merge: b5fa89db5c 131d840e8f
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Fri Sep 25 10:28:29 2026 -0400
Merge branch 'gerrit/trinity' into 'gerrit/morpheus'
* [NO ISSUE][MISC] Advance the AWS SDK to 2.55.5 (MB-73268)
* [NO ISSUE][MISC] Advance the GCS SDK to 2.74.0 (MB-73268)
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
Change-Id: Ib7ffc64fd79a5b9e5c9fdc1b5add2cf7d1ee026c
Ext-ref: MB-73268
asterixdb/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(asterixdb) 06/07: Merge branch 'gerrit/morpheus' into 'master'
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 2d2b77d6a2275f794654034536f6db2f1ef2c2f0
Merge: b410fe8c3d 6175d4c656
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Sat Sep 26 08:48:18 2026 -0400
Merge branch 'gerrit/morpheus' into 'master'
* [NO ISSUE][MISC] Advance the AWS SDK to 2.55.5 (MB-73268)
* [NO ISSUE][MISC] Advance the GCS SDK to 2.74.0 (MB-73268)
* [ASTERIXDB-3899][COMP] Do not constant-fold median (MB-74216)
The median guard goes in ConstantFoldingVisitor, where canConstantFold
lives on this branch, and hyracks-fullstack takes the same SDK versions
per its keep-in-sync notes.
Generated-By: Claude Opus 5.5 <no...@anthropic.com>
Ext-ref: MB-73268,MB-74216
Change-Id: I740c30cb5c70937e675c7acac07ed5bde5d73812
.../rules/visitor/ConstantFoldingVisitor.java | 7 +++++-
.../scalar_median/scalar_median.1.query.sqlpp | 24 ++++++++++++++++++
.../scalar_median/scalar_median.2.query.sqlpp | 29 ++++++++++++++++++++++
.../scalar_median/scalar_median.3.query.sqlpp | 25 +++++++++++++++++++
.../scalar_median/scalar_median.1.adm | 1 +
.../scalar_median/scalar_median.2.adm | 1 +
.../scalar_median/scalar_median.3.adm | 1 +
.../src/test/resources/runtimets/sqlpp_queries.xml | 5 ++++
asterixdb/pom.xml | 4 +--
hyracks-fullstack/pom.xml | 6 ++---
10 files changed, 97 insertions(+), 6 deletions(-)
diff --cc asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/visitor/ConstantFoldingVisitor.java
index 148e7615eb,0000000000..67abddf938
mode 100644,000000..100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/visitor/ConstantFoldingVisitor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/visitor/ConstantFoldingVisitor.java
@@@ -1,490 -1,0 +1,495 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.optimizer.rules.visitor;
+
+import java.io.DataInputStream;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.asterix.common.annotations.isTransformRecordAnnotation;
+import org.apache.asterix.common.config.GlobalConfig;
+import org.apache.asterix.common.dataflow.ICcApplicationContext;
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.WarningCollector;
+import org.apache.asterix.dataflow.data.common.ExpressionTypeComputer;
+import org.apache.asterix.dataflow.data.nontagged.MissingWriterFactory;
+import org.apache.asterix.dataflow.data.nontagged.NullWriterFactory;
+import org.apache.asterix.formats.nontagged.ADMPrinterFactoryProvider;
+import org.apache.asterix.formats.nontagged.BinaryBooleanInspector;
+import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
+import org.apache.asterix.formats.nontagged.BinaryHashFunctionFactoryProvider;
+import org.apache.asterix.formats.nontagged.BinaryHashFunctionFamilyProvider;
+import org.apache.asterix.formats.nontagged.BinaryIntegerInspector;
+import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
+import org.apache.asterix.formats.nontagged.TypeTraitProvider;
+import org.apache.asterix.jobgen.QueryLogicalExpressionJobGen;
+import org.apache.asterix.metadata.declared.MetadataProvider;
+import org.apache.asterix.om.base.ADouble;
+import org.apache.asterix.om.base.IAObject;
+import org.apache.asterix.om.constants.AsterixConstantValue;
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.types.TypeTagUtil;
+import org.apache.asterix.om.utils.ConstantExpressionUtil;
+import org.apache.asterix.runtime.base.UnnestingPositionWriterFactory;
+import org.apache.asterix.runtime.evaluators.functions.PointableHelper;
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractLogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.ExpressionRuntimeProvider;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IAlgebricksConstantValue;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.StatefulFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
+import org.apache.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform;
+import org.apache.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionVisitor;
+import org.apache.hyracks.algebricks.core.config.AlgebricksConfig;
+import org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext;
+import org.apache.hyracks.algebricks.core.rewriter.base.PhysicalOptimizationConfig;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.serializer.ResultSerializerFactoryProvider;
+import org.apache.hyracks.algebricks.runtime.writers.PrinterBasedWriterFactory;
+import org.apache.hyracks.api.application.IServiceContext;
+import org.apache.hyracks.api.context.IEvaluatorContext;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.IWarningCollector;
+import org.apache.hyracks.api.exceptions.NoOpWarningCollector;
+import org.apache.hyracks.api.exceptions.Warning;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
+import org.apache.hyracks.util.LogRedactionUtil;
+
+import com.google.common.collect.ImmutableMap;
+
+public class ConstantFoldingVisitor implements ILogicalExpressionVisitor<Pair<Boolean, ILogicalExpression>, Void>,
+ ILogicalExpressionReferenceTransform, IEvaluatorContext {
+
+ /**
+ * Throws exceptions in substituteProducedVariable, setVarType, and one getVarType method.
+ */
+ private static final IVariableTypeEnvironment _emptyTypeEnv = new IVariableTypeEnvironment() {
+
+ @Override
+ public boolean substituteProducedVariable(LogicalVariable v1, LogicalVariable v2) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public void setVarType(LogicalVariable var, Object type) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public Object getVarType(LogicalVariable var, List<LogicalVariable> nonMissableVariables,
+ List<List<LogicalVariable>> correlatedMissableVariableLists, List<LogicalVariable> nonNullableVariables,
+ List<List<LogicalVariable>> correlatedNullableVariableLists) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public Object getVarType(LogicalVariable var) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public Object getType(ILogicalExpression expr) throws AlgebricksException {
+ return ExpressionTypeComputer.INSTANCE.getType(expr, null, this);
+ }
+ };
+
+ private static final IOperatorSchema[] _emptySchemas = new IOperatorSchema[] {};
+
+ private static final Map<FunctionIdentifier, IAObject> FUNC_ID_TO_CONSTANT = ImmutableMap
+ .of(BuiltinFunctions.NUMERIC_E, new ADouble(Math.E), BuiltinFunctions.NUMERIC_PI, new ADouble(Math.PI));
+ private final JobGenContext jobGenCtx;
+ private final IPointable p = VoidPointable.FACTORY.createPointable();
+ private final ByteBufferInputStream bbis = new ByteBufferInputStream();
+ private final DataInputStream dis = new DataInputStream(bbis);
+ private final WarningCollector warningCollector = new WarningCollector();
+ private IOptimizationContext optContext;
+ private IServiceContext serviceContext;
+
+ public ConstantFoldingVisitor(ICcApplicationContext appCtx) {
+ MetadataProvider metadataProvider = MetadataProvider.createWithDefaultNamespace(appCtx);
+ jobGenCtx = new JobGenContext(null, metadataProvider, appCtx, SerializerDeserializerProvider.INSTANCE,
+ BinaryHashFunctionFactoryProvider.INSTANCE, BinaryHashFunctionFamilyProvider.INSTANCE,
+ BinaryComparatorFactoryProvider.INSTANCE, TypeTraitProvider.INSTANCE, BinaryBooleanInspector.FACTORY,
+ BinaryIntegerInspector.FACTORY, ADMPrinterFactoryProvider.INSTANCE, PrinterBasedWriterFactory.INSTANCE,
+ ResultSerializerFactoryProvider.INSTANCE, MissingWriterFactory.INSTANCE, NullWriterFactory.INSTANCE,
+ UnnestingPositionWriterFactory.INSTANCE, null,
+ new ExpressionRuntimeProvider(new QueryLogicalExpressionJobGen(metadataProvider.getFunctionManager())),
+ ExpressionTypeComputer.INSTANCE, null, null, null, null, GlobalConfig.DEFAULT_FRAME_SIZE, null,
+ NoOpWarningCollector.INSTANCE, 0, new PhysicalOptimizationConfig(), null);
+ }
+
+ public void reset(IOptimizationContext context) {
+ optContext = context;
+ serviceContext = ((MetadataProvider) context.getMetadataProvider()).getApplicationContext().getServiceContext();
+ }
+
+ @Override
+ public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException {
+ AbstractLogicalExpression expr = (AbstractLogicalExpression) exprRef.getValue();
+ Pair<Boolean, ILogicalExpression> newExpression = expr.accept(this, null);
+ if (newExpression.first) {
+ exprRef.setValue(newExpression.second);
+ }
+ return newExpression.first;
+ }
+
+ @Override
+ public Pair<Boolean, ILogicalExpression> visitConstantExpression(ConstantExpression expr, Void arg) {
+ return new Pair<>(false, expr);
+ }
+
+ @Override
+ public Pair<Boolean, ILogicalExpression> visitVariableReferenceExpression(VariableReferenceExpression expr,
+ Void arg) {
+ return new Pair<>(false, expr);
+ }
+
+ @Override
+ public Pair<Boolean, ILogicalExpression> visitScalarFunctionCallExpression(ScalarFunctionCallExpression expr,
+ Void arg) throws AlgebricksException {
+ FunctionIdentifier fid = expr.getFunctionIdentifier();
+
+ // Guard against O(N^2) behavior for large OR/AND trees (e.g. IN with a long list expands
+ // into O(N) OR nodes; visiting each one and iterating all siblings is O(N^2) total).
+ if ((BuiltinFunctions.OR.equals(fid) || BuiltinFunctions.AND.equals(fid))
+ && expr.getArguments().size() > optContext.getPhysicalOptimizationConfig().getMaxExpressionTreeSize()) {
+ return new Pair<>(false, expr);
+ }
+
+ boolean changed = constantFoldArgs(expr, arg);
+ List<Mutable<ILogicalExpression>> argList = expr.getArguments();
+ int argConstantCount = countConstantArgs(argList);
+ if (argConstantCount != argList.size()) {
+ if (argConstantCount > 0 && (BuiltinFunctions.OR.equals(fid) || BuiltinFunctions.AND.equals(fid))) {
+ if (foldOrAndArgs(expr)) {
+ ILogicalExpression changedExpr =
+ expr.getArguments().size() == 1 ? expr.getArguments().get(0).getValue() : expr;
+ return new Pair<>(true, changedExpr);
+ }
+ }
+ return new Pair<>(changed, expr);
+ }
+
+ if (!expr.isFunctional() || !canConstantFold(expr)) {
+ return new Pair<>(changed, expr);
+ }
+
+ try {
+ if (BuiltinFunctions.FIELD_ACCESS_BY_NAME.equals(fid)) {
+ IAType argType = (IAType) _emptyTypeEnv.getType(expr.getArguments().get(0).getValue());
+ if (argType.getTypeTag() == ATypeTag.OBJECT) {
+ ARecordType rt = (ARecordType) argType;
+ String str = ConstantExpressionUtil.getStringConstant(expr.getArguments().get(1).getValue());
+ int k = rt.getFieldIndex(str);
+ if (k >= 0) {
+ // wait for the ByNameToByIndex rule to apply
+ return new Pair<>(changed, expr);
+ }
+ }
+ }
+ IAObject c = FUNC_ID_TO_CONSTANT.get(fid);
+ if (c != null) {
+ ConstantExpression constantExpression = new ConstantExpression(new AsterixConstantValue(c));
+ constantExpression.setSourceLocation(expr.getSourceLocation());
+ return new Pair<>(true, constantExpression);
+ }
+
+ IScalarEvaluatorFactory fact = jobGenCtx.getExpressionRuntimeProvider().createEvaluatorFactory(expr,
+ _emptyTypeEnv, _emptySchemas, jobGenCtx);
+
+ warningCollector.clear();
+ IScalarEvaluator eval = fact.createScalarEvaluator(this);
+ eval.evaluate(null, p);
+ IAType returnType = (IAType) _emptyTypeEnv.getType(expr);
+ ATypeTag runtimeType = PointableHelper.getTypeTag(p);
+ if (runtimeType.isDerivedType()) {
+ returnType = TypeComputeUtils.getActualType(returnType);
+ } else {
+ returnType = TypeTagUtil.getBuiltinTypeByTag(runtimeType);
+ }
+ @SuppressWarnings("rawtypes")
+ ISerializerDeserializer serde =
+ jobGenCtx.getSerializerDeserializerProvider().getSerializerDeserializer(returnType);
+ bbis.setByteBuffer(ByteBuffer.wrap(p.getByteArray(), p.getStartOffset(), p.getLength()), 0);
+ IAObject o = (IAObject) serde.deserialize(dis);
+ warningCollector.getWarnings(optContext.getWarningCollector());
+ ConstantExpression constantExpression = new ConstantExpression(new AsterixConstantValue(o));
+ constantExpression.setSourceLocation(expr.getSourceLocation());
+ return new Pair<>(true, constantExpression);
+ } catch (HyracksDataException | AlgebricksException e) {
+ if (AlgebricksConfig.ALGEBRICKS_LOGGER.isTraceEnabled()) {
+ AlgebricksConfig.ALGEBRICKS_LOGGER.trace("Exception caught at constant folding: " + e, e);
+ }
+ return new Pair<>(false, null);
+ }
+ }
+
+ @Override
+ public Pair<Boolean, ILogicalExpression> visitAggregateFunctionCallExpression(AggregateFunctionCallExpression expr,
+ Void arg) throws AlgebricksException {
+ boolean changed = constantFoldArgs(expr, arg);
+ return new Pair<>(changed, expr);
+ }
+
+ @Override
+ public Pair<Boolean, ILogicalExpression> visitStatefulFunctionCallExpression(StatefulFunctionCallExpression expr,
+ Void arg) throws AlgebricksException {
+ boolean changed = constantFoldArgs(expr, arg);
+ return new Pair<>(changed, expr);
+ }
+
+ @Override
+ public Pair<Boolean, ILogicalExpression> visitUnnestingFunctionCallExpression(UnnestingFunctionCallExpression expr,
+ Void arg) throws AlgebricksException {
+ boolean changed = constantFoldArgs(expr, arg);
+ return new Pair<>(changed, expr);
+ }
+
+ private boolean constantFoldArgs(AbstractFunctionCallExpression expr, Void arg) throws AlgebricksException {
+ return expr.getFunctionIdentifier().equals(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR) ? foldRecordArgs(expr, arg)
+ : foldFunctionArgs(expr, arg);
+ }
+
+ private boolean foldFunctionArgs(AbstractFunctionCallExpression expr, Void arg) throws AlgebricksException {
+ boolean changed = false;
+ for (Mutable<ILogicalExpression> exprArgRef : expr.getArguments()) {
+ changed |= foldArg(exprArgRef, arg);
+ }
+ return changed;
+ }
+
+ private boolean foldRecordArgs(AbstractFunctionCallExpression expr, Void arg) throws AlgebricksException {
+ if (expr.getArguments().size() % 2 != 0) {
+ String functionName = expr.getFunctionIdentifier().getName();
+ throw CompilationException.create(ErrorCode.COMPILATION_INVALID_NUM_OF_ARGS, expr.getSourceLocation(),
+ functionName);
+ }
+ boolean changed = false;
+ Iterator<Mutable<ILogicalExpression>> iterator = expr.getArguments().iterator();
+ int fieldNameIdx = 0;
+ while (iterator.hasNext()) {
+ Mutable<ILogicalExpression> fieldNameExprRef = iterator.next();
+ Pair<Boolean, ILogicalExpression> fieldNameExpr = fieldNameExprRef.getValue().accept(this, arg);
+ boolean isDuplicate = false;
+ if (fieldNameExpr.first) {
+ String fieldName = ConstantExpressionUtil.getStringConstant(fieldNameExpr.second);
+ if (fieldName != null) {
+ isDuplicate = isDuplicateField(fieldName, fieldNameIdx, expr.getArguments());
+ }
+ if (isDuplicate) {
+ IWarningCollector warningCollector = optContext.getWarningCollector();
+ if (warningCollector.shouldWarn()) {
+ warningCollector.warn(Warning.of(fieldNameExpr.second.getSourceLocation(),
+ ErrorCode.COMPILATION_DUPLICATE_FIELD_NAME, LogRedactionUtil.userData(fieldName)));
+ }
+ iterator.remove();
+ iterator.next();
+ iterator.remove();
+ } else {
+ fieldNameExprRef.setValue(fieldNameExpr.second);
+ }
+ changed = true;
+ }
+ if (!isDuplicate) {
+ Mutable<ILogicalExpression> fieldValue = iterator.next();
+ changed |= foldArg(fieldValue, arg);
+ fieldNameIdx += 2;
+ }
+ }
+ return changed;
+ }
+
+ private boolean isDuplicateField(String fName, int fIdx, List<Mutable<ILogicalExpression>> args) {
+ for (int i = 0, size = args.size(); i < size; i += 2) {
+ if (i != fIdx && fName.equals(ConstantExpressionUtil.getStringConstant(args.get(i).getValue()))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean foldArg(Mutable<ILogicalExpression> exprArgRef, Void arg) throws AlgebricksException {
+ Pair<Boolean, ILogicalExpression> newExpr = exprArgRef.getValue().accept(this, arg);
+ if (newExpr.first) {
+ exprArgRef.setValue(newExpr.second);
+ return true;
+ }
+ return false;
+ }
+
+ private int countConstantArgs(List<Mutable<ILogicalExpression>> argList) {
+ int n = 0;
+ for (Mutable<ILogicalExpression> r : argList) {
+ if (r.getValue().getExpressionTag() == LogicalExpressionTag.CONSTANT) {
+ n++;
+ }
+ }
+ return n;
+ }
+
+ private boolean canConstantFold(ScalarFunctionCallExpression function) throws AlgebricksException {
+ // skip external functions because they're not available at compile time (on CC)
+ IFunctionInfo fi = function.getFunctionInfo();
+ if (fi.isExternal()) {
+ return false;
+ }
++ // median sorts through run files, which need the task context that is null at compile time
++ FunctionIdentifier fid = function.getFunctionIdentifier();
++ if (fid.equals(BuiltinFunctions.SCALAR_SQL_MEDIAN) || fid.equals(BuiltinFunctions.SCALAR_MEDIAN)) {
++ return false;
++ }
+ IAType returnType = (IAType) _emptyTypeEnv.getType(function);
+ // skip all functions that would produce records/arrays/multisets (derived types) in their open format
+ // this is because constant folding them will make them closed (currently)
- if (function.getFunctionIdentifier().equals(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
++ if (fid.equals(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
+ if (returnType.getTypeTag() != ATypeTag.OBJECT || ((ARecordType) returnType).isOpen()
+ || function.hasAnnotation(isTransformRecordAnnotation.class)) {
+ return false;
+ }
+ }
+ return canConstantFoldType(returnType);
+ }
+
+ private boolean canConstantFoldType(IAType returnType) {
+ ATypeTag tag = returnType.getTypeTag();
+ if (tag == ATypeTag.ANY) {
+ // if the function is to return a record (or derived data), that record would (should) be an open record
+ return false;
+ } else if (tag == ATypeTag.OBJECT) {
+ ARecordType recordType = (ARecordType) returnType;
+ if (recordType.isOpen()) {
+ return false;
+ }
+ IAType[] fieldTypes = recordType.getFieldTypes();
+ for (int i = 0; i < fieldTypes.length; i++) {
+ if (!canConstantFoldType(fieldTypes[i])) {
+ return false;
+ }
+ }
+ } else if (tag.isListType()) {
+ AbstractCollectionType listType = (AbstractCollectionType) returnType;
+ return canConstantFoldType(listType.getItemType());
+ } else if (tag == ATypeTag.UNION) {
+ return canConstantFoldType(((AUnionType) returnType).getActualType());
+ }
+ return true;
+ }
+
+ private boolean foldOrAndArgs(ScalarFunctionCallExpression expr) {
+ // or(true,x,y) -> true; or(false,x,y) -> or(x,y)
+ boolean changed = false;
+ List<Mutable<ILogicalExpression>> argList = expr.getArguments();
+ Iterator<Mutable<ILogicalExpression>> argIter = argList.iterator();
+ Mutable<ILogicalExpression> argFalse = null;
+ while (argIter.hasNext()) {
+ Mutable<ILogicalExpression> argExprRef = argIter.next();
+ ILogicalExpression argExpr = argExprRef.getValue();
+ if (argExpr.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
+ continue;
+ }
+
+ ConstantExpression cExpr = (ConstantExpression) argExpr;
+ IAlgebricksConstantValue cValue = cExpr.getValue();
+ FunctionIdentifier fid = expr.getFunctionIdentifier();
+
+ if (replaceAndReturn(cValue, fid)) {
+ // or(true,x,y) -> true;
+ // and(false, x, y) -> false
+ argList.clear();
+ argList.add(argExprRef);
+ return true;
+ } else if (removeAndContinue(cValue, fid)) {
+ // or(false, x, y) -> or(x, y)
+ // and(true, x, y) -> and(x, y)
+ // remove 'false' (or 'true') from arg list, but save the expression.
+ argFalse = argExprRef;
+ argIter.remove();
+ changed = true;
+ }
+ }
+ if (argList.isEmpty() && argFalse != null) {
+ argList.add(argFalse);
+ }
+ return changed;
+ }
+
+ private boolean replaceAndReturn(IAlgebricksConstantValue cValue, FunctionIdentifier fid) {
+ if (BuiltinFunctions.OR.equals(fid)) {
+ return cValue.isTrue();
+ } else {
+ // BuiltinFunctions.AND
+ return cValue.isFalse();
+ }
+ }
+
+ private boolean removeAndContinue(IAlgebricksConstantValue cValue, FunctionIdentifier fid) {
+ if (BuiltinFunctions.OR.equals(fid)) {
+ return cValue.isFalse();
+ } else {
+ // BuiltinFunctions.AND
+ return cValue.isTrue();
+ }
+ }
+
+ // IEvaluatorContext
+
+ @Override
+ public IServiceContext getServiceContext() {
+ return serviceContext;
+ }
+
+ @Override
+ public IHyracksTaskContext getTaskContext() {
+ return null;
+ }
+
+ @Override
+ public IWarningCollector getWarningCollector() {
+ return warningCollector;
+ }
+}
diff --cc asterixdb/pom.xml
index 19c2a1f806,54f1741825..fd3b50a192
--- a/asterixdb/pom.xml
+++ b/asterixdb/pom.xml
@@@ -104,11 -98,6 +104,11 @@@
<parquet.version>1.18.1</parquet.version> <!-- NOTICE: please update transitives from parquet below on any change -->
<hadoop-awsjavasdk.version>1.12.797</hadoop-awsjavasdk.version>
+ <!-- keep in sync with hyracks-fullstack/pom.xml -->
- <awsjavasdk.version>2.55.3</awsjavasdk.version>
++ <awsjavasdk.version>2.55.5</awsjavasdk.version>
+ <!-- @derived-from: software.amazon.awssdk:aws-sdk-java-pom:${awsjavasdk.version}#awscrt.version -->
+ <awsjavasdk.crt.version>0.48.4</awsjavasdk.crt.version>
+
<azureblobjavasdk.version>12.35.1</azureblobjavasdk.version>
<azurecommonjavasdk.version>12.34.1</azurecommonjavasdk.version>
<azureidentity.version>1.18.6</azureidentity.version>
@@@ -116,8 -105,7 +116,8 @@@
<azurecore.version>1.59.1</azurecore.version>
<azurecorehttpnetty.version>1.16.7</azurecorehttpnetty.version>
- <gcsjavasdk.version>2.74.0</gcsjavasdk.version>
+ <!-- keep in sync with hyracks-fullstack/pom.xml -->
- <google-cloud-storage.version>2.73.0</google-cloud-storage.version>
++ <google-cloud-storage.version>2.74.0</google-cloud-storage.version>
<hadoop-azuresdk.version>8.6.6</hadoop-azuresdk.version>
<hadoop-gcs.version>hadoop3-2.2.25</hadoop-gcs.version>
<io.opencensus.version>0.31.1</io.opencensus.version>
diff --cc hyracks-fullstack/pom.xml
index 75199d2417,2c27a3df0c..32e5e8b242
--- a/hyracks-fullstack/pom.xml
+++ b/hyracks-fullstack/pom.xml
@@@ -76,20 -81,7 +76,20 @@@
<jackson.version>2.22.3</jackson.version>
<jackson-annotations.version>2.22</jackson-annotations.version>
<jackson-databind.version>${jackson.version}</jackson-databind.version>
+ <!-- 4.2 is a new netty generation; stay on the 4.1.x line (patch updates only) -->
<netty.version>4.1.138.Final</netty.version>
+ <netty.tcnative.version>2.0.84.Final</netty.tcnative.version>
+ <asm.version>9.10.1</asm.version>
+ <!-- keep in sync with asterixdb/pom.xml -->
- <awsjavasdk.version>2.54.17</awsjavasdk.version>
++ <awsjavasdk.version>2.55.5</awsjavasdk.version>
+
+ <!-- keep in sync with asterixdb/pom.xml -->
- <google-cloud-storage.version>2.73.0</google-cloud-storage.version>
++ <google-cloud-storage.version>2.74.0</google-cloud-storage.version>
+ <!-- @derived-from: com.google.cloud:google-cloud-storage:${google-cloud-storage.version}#dep:google-cloud-core -->
- <google-cloud-core.version>2.75.0</google-cloud-core.version>
++ <google-cloud-core.version>2.76.0</google-cloud-core.version>
+
+ <!-- keep in sync with asterixdb/pom.xml -->
+ <azurecore.version>1.59.1</azurecore.version>
<implementation.title>Apache Hyracks and Algebricks - ${project.name}</implementation.title>
<implementation.url>https://asterixdb.apache.org/</implementation.url>
(asterixdb) 04/07: [ASTERIXDB-3899][COMP] Do not constant-fold median
Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 55baa9cfd8d156d6d251aab03a963636d6f3df58
Author: Ali Alsuliman <al...@gmail.com>
AuthorDate: Fri Sep 25 11:22:10 2026 -0700
[ASTERIXDB-3899][COMP] Do not constant-fold median
- user model changes: no
- storage format changes: no
- interface changes: no
Details: array_median over a constant argument failed with a
NullPointerException. Constant folding evaluates a function with a
null task context, and median sorts its input through run files, so
it needs that context from construction to finish. Allocating the
frame lazily would only move the failure, so median is no longer
folded and is evaluated at run time instead.
Ext-ref: MB-74216
Generated-By: Claude Opus 5.5 <no...@anthropic.com>
Change-Id: I1c184be9779cfe00dfe79df884812bd147dc606e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21895
Reviewed-by: Ian Maxon <im...@apache.org>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
---
.../optimizer/rules/ConstantFoldingRule.java | 7 +++++-
.../scalar_median/scalar_median.1.query.sqlpp | 24 ++++++++++++++++++
.../scalar_median/scalar_median.2.query.sqlpp | 29 ++++++++++++++++++++++
.../scalar_median/scalar_median.3.query.sqlpp | 25 +++++++++++++++++++
.../scalar_median/scalar_median.1.adm | 1 +
.../scalar_median/scalar_median.2.adm | 1 +
.../scalar_median/scalar_median.3.adm | 1 +
.../src/test/resources/runtimets/sqlpp_queries.xml | 5 ++++
8 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
index 9fe1ba4ab2..b46b87138b 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
@@ -395,9 +395,14 @@ public class ConstantFoldingRule implements IAlgebraicRewriteRule {
if (fi.isExternal()) {
return false;
}
+ // median sorts through run files, which need the task context that is null at compile time
+ FunctionIdentifier fid = function.getFunctionIdentifier();
+ if (fid.equals(BuiltinFunctions.SCALAR_SQL_MEDIAN) || fid.equals(BuiltinFunctions.SCALAR_MEDIAN)) {
+ return false;
+ }
// skip all functions that would produce records/arrays/multisets (derived types) in their open format
// this is because constant folding them will make them closed (currently)
- if (function.getFunctionIdentifier().equals(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
+ if (fid.equals(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
return false;
}
IAType returnType = (IAType) _emptyTypeEnv.getType(function);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.1.query.sqlpp
new file mode 100644
index 0000000000..5349f04465
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.1.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description : Tests the scalar version of array_median over a constant array.
+ * Success : Yes
+ */
+
+select value array_median([1.0, 2.0, 3.0]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.2.query.sqlpp
new file mode 100644
index 0000000000..ecec19234c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.2.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description : Tests the scalar version of array_median over constant arrays that are unsorted,
+ * of even length, contain nulls, or are empty.
+ * Success : Yes
+ */
+
+select array_median([3, 1, 2]) as odd,
+ array_median([4, 1, 3, 2]) as even,
+ array_median([3, null, 1]) as with_null,
+ array_median([null]) as all_null,
+ array_median([]) as empty;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.3.query.sqlpp
new file mode 100644
index 0000000000..1b31e1943c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_median/scalar_median.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description : Tests the scalar version of array_median over a constant array bound by FROM.
+ * Success : Yes
+ */
+
+from [[1.0, 2.0, 3.0]] as a
+select value array_median(a);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.1.adm
new file mode 100644
index 0000000000..cd5ac039d6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.1.adm
@@ -0,0 +1 @@
+2.0
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.2.adm
new file mode 100644
index 0000000000..d36f5beb53
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.2.adm
@@ -0,0 +1 @@
+{ "odd": 2.0, "even": 2.5, "with_null": 2.0, "all_null": null, "empty": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.3.adm
new file mode 100644
index 0000000000..cd5ac039d6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/scalar_median/scalar_median.3.adm
@@ -0,0 +1 @@
+2.0
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 2a1bfd0826..e628d2183a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -2073,6 +2073,11 @@
<output-dir compare="Text">scalar_max_null</output-dir>
</compilation-unit>
</test-case>
+ <test-case FilePath="aggregate-sql">
+ <compilation-unit name="scalar_median">
+ <output-dir compare="Text">scalar_median</output-dir>
+ </compilation-unit>
+ </test-case>
<test-case FilePath="aggregate-sql">
<compilation-unit name="scalar_min">
<output-dir compare="Text">scalar_min</output-dir>