From notifications-return-158327-archive-asf-public=cust-asf.ponee.io@asterixdb.apache.org Thu Jun 17 17:35:13 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id A26B4180658 for ; Thu, 17 Jun 2021 19:35:12 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id D99E93EF09 for ; Thu, 17 Jun 2021 17:35:11 +0000 (UTC) Received: (qmail 32405 invoked by uid 500); 17 Jun 2021 17:35:11 -0000 Mailing-List: contact notifications-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list notifications@asterixdb.apache.org Received: (qmail 32391 invoked by uid 99); 17 Jun 2021 17:35:11 -0000 Received: from spamproc1-he-fi.apache.org (HELO spamproc1-he-fi.apache.org) (95.217.134.168) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jun 2021 17:35:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamproc1-he-fi.apache.org (ASF Mail Server at spamproc1-he-fi.apache.org) with ESMTP id 42F84C0484 for ; Thu, 17 Jun 2021 17:35:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamproc1-he-fi.apache.org X-Spam-Flag: NO X-Spam-Score: 0.213 X-Spam-Level: X-Spam-Status: No, score=0.213 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=0.2, SPF_NONE=0.001, T_KAM_HTML_FONT_INVALID=0.01, URIBL_BLOCKED=0.001, WEIRD_PORT=0.001] autolearn=disabled Received: from mx1-ec2-va.apache.org ([116.203.227.195]) by localhost (spamproc1-he-fi.apache.org [95.217.134.168]) (amavisd-new, port 10024) with ESMTP id QGdkpryoCOA5 for ; Thu, 17 Jun 2021 17:35:08 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=128.195.1.133; helo=adrian-monk-v3.ics.uci.edu; envelope-from=do-not-reply@asterix-gerrit.ics.uci.edu; receiver= Received: from adrian-monk-v3.ics.uci.edu (adrian-monk-v3.ics.uci.edu [128.195.1.133]) by mx1-ec2-va.apache.org (ASF Mail Server at mx1-ec2-va.apache.org) with ESMTPS id 8B302BC48D for ; Thu, 17 Jun 2021 17:35:06 +0000 (UTC) Received: from 92d4af910d15 (vitalstatistix.ics.uci.edu [128.195.52.38]) by adrian-monk-v3.ics.uci.edu (Postfix) with ESMTP id 187CFC028C7A; Thu, 17 Jun 2021 10:35:02 -0700 (PDT) X-Gerrit-PatchSet: 1 Date: Thu, 17 Jun 2021 17:35:02 +0000 From: AsterixDB Code Review To: Till Westmann Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: Change in asterixdb[mad-hatter]: [ASTERIXDB-2843][COMP] Fix type computer for scalar aggregates X-Gerrit-Change-Id: Ic587f29840262f052f15e7d257c3d7dda7e40686 X-Gerrit-Change-Number: 11984 X-Gerrit-Project: asterixdb X-Gerrit-ChangeURL: X-Gerrit-Commit: 1e443ecebf61b771bed1bb2fbe895bd393020397 References: Reply-To: dmitry.lychagin@couchbase.com, notifications@asterixdb.apache.org, lwhaywhu@gmail.com, tillw@apache.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.12 Content-Type: multipart/alternative; boundary="SdjxmGwSOaQ="; charset=UTF-8 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: 187CFC028C7A.A69F4 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.985, required 5, ALL_TRUSTED -1.00, FSL_HELO_NON_FQDN_1 0.00, HELO_NO_DOMAIN 0.00, HTML_MESSAGE 0.00, T_KAM_HTML_FONT_INVALID 0.01, URIBL_BLOCKED 0.00, WEIRD_PORT 0.00) X-ICS-MailScanner-From: do-not-reply@asterix-gerrit.ics.uci.edu --SdjxmGwSOaQ= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From Dmitry Lychagin : Dmitry Lychagin = has uploaded this change for review=2E ( https://asterix-gerrit=2Eics=2Euci= =2Eedu/c/asterixdb/+/11984 ) Change subject: [ASTERIXDB-2843][COMP] Fix t= ype computer for scalar aggregates =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E [ASTERIXDB-2843][COMP] Fix type computer for scalar = aggregates - user model changes: no - storage format changes: no - interfa= ce changes: no Details: - Align type computation for scalar aggregates wit= h regular aggregates Change-Id: Ic587f29840262f052f15e7d257c3d7dda7e4068= 6 --- M asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/= BuiltinFunctions=2Ejava A asterixdb/asterix-om/src/main/java/org/apache/ast= erix/om/typecomputer/impl/AggregateResultTypeComputer=2Ejava M asterixdb/as= terix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTyp= eComputer=2Ejava M asterixdb/asterix-om/src/main/java/org/apache/asterix/om= /typecomputer/impl/NumericSumAggTypeComputer=2Ejava M asterixdb/asterix-om/= src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggreg= ateResultType=2Ejava 5 files changed, 93 insertions(+), 61 deletions(-) = git pull ssh://asterix-gerrit=2Eics=2Euci=2Eedu:29418/asterixdb refs/chan= ges/84/11984/1 diff --git a/asterixdb/asterix-om/src/main/java/org/apache/= asterix/om/functions/BuiltinFunctions=2Ejava b/asterixdb/asterix-om/src/mai= n/java/org/apache/asterix/om/functions/BuiltinFunctions=2Ejava index bf2709= a=2E=2Ef2a1edf 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/a= sterix/om/functions/BuiltinFunctions=2Ejava +++ b/asterixdb/asterix-om/src/= main/java/org/apache/asterix/om/functions/BuiltinFunctions=2Ejava @@ -1771,= 6 +1771,11 @@ addFunction(NEGINF_IF, DoubleIfTypeComputer=2EINSTAN= CE, true); // Aggregate Functions + ScalarVersionOfAggreg= ateResultType scalarNumericSumTypeComputer =3D + new ScalarV= ersionOfAggregateResultType(NumericSumAggTypeComputer=2EINSTANCE); + = ScalarVersionOfAggregateResultType scalarMinMaxTypeComputer =3D + = new ScalarVersionOfAggregateResultType(MinMaxAggTypeComputer=2EINSTA= NCE); + addPrivateFunction(LISTIFY, OrderedListConstructorTypeComp= uter=2EINSTANCE, true); addFunction(SCALAR_ARRAYAGG, ScalarArrayAg= gTypeComputer=2EINSTANCE, true); addFunction(MAX, MinMaxAggTypeCom= puter=2EINSTANCE, true); @@ -1816,7 +1821,7 @@ // SUM a= ddFunction(SUM, NumericSumAggTypeComputer=2EINSTANCE, true); - addFu= nction(SCALAR_SUM, ScalarVersionOfAggregateResultType=2EINSTANCE, true); + = addFunction(SCALAR_SUM, scalarNumericSumTypeComputer, true); = addPrivateFunction(LOCAL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true)= ; addPrivateFunction(INTERMEDIATE_SUM, NumericSumAggTypeComputer= =2EINSTANCE, true); addPrivateFunction(GLOBAL_SUM, NumericSumAggTy= peComputer=2EINSTANCE, true); @@ -1832,8 +1837,8 @@ addPrivateFunc= tion(SERIAL_INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer=2EINSTANCE, true); = addFunction(SCALAR_AVG, NullableDoubleTypeComputer=2EINSTANCE, true= ); addFunction(SCALAR_COUNT, AInt64TypeComputer=2EINSTANCE, true);= - addFunction(SCALAR_MAX, ScalarVersionOfAggregateResultType=2EINST= ANCE, true); - addFunction(SCALAR_MIN, ScalarVersionOfAggregateResul= tType=2EINSTANCE, true); + addFunction(SCALAR_MAX, scalarMinMaxTypeC= omputer, true); + addFunction(SCALAR_MIN, scalarMinMaxTypeComputer, = true); addPrivateFunction(INTERMEDIATE_AVG, LocalAvgTypeComputer= =2EINSTANCE, true); addFunction(SCALAR_STDDEV_SAMP, NullableDouble= TypeComputer=2EINSTANCE, true); addPrivateFunction(INTERMEDIATE_ST= DDEV_SAMP, LocalSingleVarStatisticsTypeComputer=2EINSTANCE, true); @@ -1874= ,7 +1879,7 @@ // SQL SUM addFunction(SQL_SUM, NumericSu= mAggTypeComputer=2EINSTANCE, true); - addFunction(SCALAR_SQL_SUM, Sc= alarVersionOfAggregateResultType=2EINSTANCE, true); + addFunction(SC= ALAR_SQL_SUM, scalarNumericSumTypeComputer, true); addPrivateFunct= ion(LOCAL_SQL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true); ad= dPrivateFunction(INTERMEDIATE_SQL_SUM, NumericSumAggTypeComputer=2EINSTANCE= , true); addPrivateFunction(GLOBAL_SQL_SUM, NumericSumAggTypeCompu= ter=2EINSTANCE, true); @@ -1898,8 +1903,8 @@ addPrivateFunction(GL= OBAL_SQL_MIN, MinMaxAggTypeComputer=2EINSTANCE, true); addFunction= (SCALAR_SQL_AVG, NullableDoubleTypeComputer=2EINSTANCE, true); add= Function(SCALAR_SQL_COUNT, AInt64TypeComputer=2EINSTANCE, true); - a= ddFunction(SCALAR_SQL_MAX, ScalarVersionOfAggregateResultType=2EINSTANCE, t= rue); - addFunction(SCALAR_SQL_MIN, ScalarVersionOfAggregateResultTy= pe=2EINSTANCE, true); + addFunction(SCALAR_SQL_MAX, scalarMinMaxType= Computer, true); + addFunction(SCALAR_SQL_MIN, scalarMinMaxTypeCompu= ter, true); addPrivateFunction(INTERMEDIATE_SQL_AVG, LocalAvgTypeC= omputer=2EINSTANCE, true); addFunction(SQL_STDDEV_SAMP, NullableDo= ubleTypeComputer=2EINSTANCE, true); addPrivateFunction(GLOBAL_SQL_= STDDEV_SAMP, NullableDoubleTypeComputer=2EINSTANCE, true); @@ -1974,9 +1979= ,9 @@ addFunction(SCALAR_SQL_COUNT_DISTINCT, AInt64TypeComputer=2E= INSTANCE, true); addFunction(SUM_DISTINCT, NumericSumAggTypeComp= uter=2EINSTANCE, true); - addFunction(SCALAR_SUM_DISTINCT, ScalarVer= sionOfAggregateResultType=2EINSTANCE, true); + addFunction(SCALAR_SU= M_DISTINCT, scalarNumericSumTypeComputer, true); addFunction(SQL_S= UM_DISTINCT, NumericSumAggTypeComputer=2EINSTANCE, true); - addFunct= ion(SCALAR_SQL_SUM_DISTINCT, ScalarVersionOfAggregateResultType=2EINSTANCE,= true); + addFunction(SCALAR_SQL_SUM_DISTINCT, scalarNumericSumTypeC= omputer, true); addFunction(AVG_DISTINCT, NullableDoubleTypeComp= uter=2EINSTANCE, true); addFunction(SCALAR_AVG_DISTINCT, NullableD= oubleTypeComputer=2EINSTANCE, true); @@ -1984,14 +1989,14 @@ addFu= nction(SCALAR_SQL_AVG_DISTINCT, NullableDoubleTypeComputer=2EINSTANCE, true= ); addFunction(MAX_DISTINCT, MinMaxAggTypeComputer=2EINSTANCE, t= rue); - addFunction(SCALAR_MAX_DISTINCT, ScalarVersionOfAggregateRes= ultType=2EINSTANCE, true); + addFunction(SCALAR_MAX_DISTINCT, scalar= MinMaxTypeComputer, true); addFunction(SQL_MAX_DISTINCT, MinMaxAgg= TypeComputer=2EINSTANCE, true); - addFunction(SCALAR_SQL_MAX_DISTINC= T, ScalarVersionOfAggregateResultType=2EINSTANCE, true); + addFuncti= on(SCALAR_SQL_MAX_DISTINCT, scalarMinMaxTypeComputer, true); add= Function(MIN_DISTINCT, MinMaxAggTypeComputer=2EINSTANCE, true); - ad= dFunction(SCALAR_MIN_DISTINCT, ScalarVersionOfAggregateResultType=2EINSTANC= E, true); + addFunction(SCALAR_MIN_DISTINCT, scalarMinMaxTypeCompute= r, true); addFunction(SQL_MIN_DISTINCT, MinMaxAggTypeComputer=2EIN= STANCE, true); - addFunction(SCALAR_SQL_MIN_DISTINCT, ScalarVersionO= fAggregateResultType=2EINSTANCE, true); + addFunction(SCALAR_SQL_MIN= _DISTINCT, scalarMinMaxTypeComputer, true); addFunction(STDDEV_S= AMP_DISTINCT, NullableDoubleTypeComputer=2EINSTANCE, true); addFun= ction(SCALAR_STDDEV_SAMP_DISTINCT, NullableDoubleTypeComputer=2EINSTANCE, t= rue); diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om= /typecomputer/impl/AggregateResultTypeComputer=2Ejava b/asterixdb/asterix-o= m/src/main/java/org/apache/asterix/om/typecomputer/impl/AggregateResultType= Computer=2Ejava new file mode 100644 index 0000000=2E=2E8e663a7 --- /dev/nu= ll +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecompu= ter/impl/AggregateResultTypeComputer=2Ejava @@ -0,0 +1,39 @@ +/* + * Licens= ed to the Apache Software Foundation (ASF) under one + * or more contributo= r license agreements=2E See the NOTICE file + * distributed with this work= for additional information + * regarding copyright ownership=2E The ASF l= icenses this file + * to you under the Apache License, Version 2=2E0 (the += * "License"); you may not use this file except in compliance + * with the = License=2E You may obtain a copy of the License at + * + * http://www=2E= apache=2Eorg/licenses/LICENSE-2=2E0 + * + * Unless required by applicable l= aw or agreed to in writing, + * software distributed under the License is d= istributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY= + * KIND, either express or implied=2E See the License for the + * specif= ic language governing permissions and limitations + * under the License=2E = + */ + +package org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Eimpl; + +impor= t org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultTypeCom= puter; +import org=2Eapache=2Easterix=2Eom=2Etypes=2EIAType; +import org=2E= apache=2Ehyracks=2Ealgebricks=2Ecommon=2Eexceptions=2EAlgebricksException; = +import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealgebra=2Ebase=2EILogi= calExpression; +import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealgebra= =2Efunctions=2EFunctionIdentifier; +import org=2Eapache=2Ehyracks=2Eapi=2Ee= xceptions=2ESourceLocation; + +public abstract class AggregateResultTypeCom= puter extends AbstractResultTypeComputer { + @Override + protected vo= id checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, Sourc= eLocation sourceLoc) + throws AlgebricksException { + sup= er=2EcheckArgType(funcId, argIndex, type, sourceLoc); + } + + @Overri= de + protected abstract IAType getResultType(ILogicalExpression expr, IA= Type=2E=2E=2E strippedInputTypes) + throws AlgebricksException; = +} \ No newline at end of file diff --git a/asterixdb/asterix-om/src/main/j= ava/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer=2Ejava b/= asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/= MinMaxAggTypeComputer=2Ejava index c34b5ed=2E=2Efc1eee5 100644 --- a/asteri= xdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMax= AggTypeComputer=2Ejava +++ b/asterixdb/asterix-om/src/main/java/org/apache/= asterix/om/typecomputer/impl/MinMaxAggTypeComputer=2Ejava @@ -19,7 +19,6 @@= package org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Eimpl; import org= =2Eapache=2Easterix=2Edataflow=2Edata=2Ecommon=2EILogicalBinaryComparator; = -import org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultT= ypeComputer; import org=2Eapache=2Easterix=2Eom=2Etypes=2EATypeTag; impor= t org=2Eapache=2Easterix=2Eom=2Etypes=2EAUnionType; import org=2Eapache=2E= asterix=2Eom=2Etypes=2EBuiltinType; @@ -27,7 +26,7 @@ import org=2Eapache= =2Ehyracks=2Ealgebricks=2Ecommon=2Eexceptions=2EAlgebricksException; impor= t org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealgebra=2Ebase=2EILogicalExp= ression; -public class MinMaxAggTypeComputer extends AbstractResultTypeCo= mputer { +public class MinMaxAggTypeComputer extends AggregateResultTypeCom= puter { public static final MinMaxAggTypeComputer INSTANCE =3D new M= inMaxAggTypeComputer(); diff --git a/asterixdb/asterix-om/src/main/java/o= rg/apache/asterix/om/typecomputer/impl/NumericSumAggTypeComputer=2Ejava b/a= sterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/N= umericSumAggTypeComputer=2Ejava index 1c67e56=2E=2Ea4b5e34 100644 --- a/ast= erixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/Num= ericSumAggTypeComputer=2Ejava +++ b/asterixdb/asterix-om/src/main/java/org/= apache/asterix/om/typecomputer/impl/NumericSumAggTypeComputer=2Ejava @@ -18= ,42 +18,20 @@ */ package org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Eim= pl; -import org=2Eapache=2Easterix=2Eom=2Eexceptions=2EUnsupportedTypeExc= eption; -import org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Ebase=2EAbstrac= tResultTypeComputer; import org=2Eapache=2Easterix=2Eom=2Etypes=2EATypeTag= ; import org=2Eapache=2Easterix=2Eom=2Etypes=2EAUnionType; import org=2Ea= pache=2Easterix=2Eom=2Etypes=2EBuiltinType; import org=2Eapache=2Easterix= =2Eom=2Etypes=2EIAType; import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecommo= n=2Eexceptions=2EAlgebricksException; import org=2Eapache=2Ehyracks=2Ealge= bricks=2Ecore=2Ealgebra=2Ebase=2EILogicalExpression; -import org=2Eapache= =2Ehyracks=2Ealgebricks=2Ecore=2Ealgebra=2Efunctions=2EFunctionIdentifier; = -import org=2Eapache=2Ehyracks=2Eapi=2Eexceptions=2ESourceLocation; -publ= ic class NumericSumAggTypeComputer extends AbstractResultTypeComputer { +pu= blic class NumericSumAggTypeComputer extends AggregateResultTypeComputer { = public static final NumericSumAggTypeComputer INSTANCE =3D new Numeric= SumAggTypeComputer(); private NumericSumAggTypeComputer() { } = @Override - protected void checkArgType(FunctionIdentifier funcId,= int argIndex, IAType type, SourceLocation sourceLoc) - throws A= lgebricksException { - ATypeTag tag =3D type=2EgetTypeTag(); - = switch (tag) { - case DOUBLE: - case FLOAT: - = case BIGINT: - case INTEGER: - case SMALLINT: -= case TINYINT: - case ANY: - break; - = default: - throw new UnsupportedTypeException(sou= rceLoc, funcId, tag); - } - } - - @Override protected IAT= ype getResultType(ILogicalExpression expr, IAType=2E=2E=2E strippedInputTyp= es) throws AlgebricksException { ATypeTag tag =3D strippedInputTyp= es[0]=2EgetTypeTag(); switch (tag) { @@ -61,15 +39,12 @@ = case SMALLINT: case INTEGER: case BIGINT: - = IAType int64Type =3D BuiltinType=2EAINT64; - r= eturn AUnionType=2EcreateNullableType(int64Type, "AggResult"); + = return AUnionType=2EcreateNullableType(BuiltinType=2EAINT64); = case FLOAT: case DOUBLE: - IAType doubleTy= pe =3D BuiltinType=2EADOUBLE; - return AUnionType=2EcreateNu= llableType(doubleType, "AggResult"); + return AUnionType=2Ec= reateNullableType(BuiltinType=2EADOUBLE); case ANY: - = IAType anyType =3D strippedInputTypes[0]; - return AU= nionType=2EcreateNullableType(anyType, "AggResult"); + retur= n BuiltinType=2EANY; default: // All other po= ssible cases=2E return BuiltinType=2EANULL; diff --git a/a= sterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/S= calarVersionOfAggregateResultType=2Ejava b/asterixdb/asterix-om/src/main/ja= va/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultTy= pe=2Ejava index 5b90974=2E=2Efda0285 100644 --- a/asterixdb/asterix-om/src/= main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateR= esultType=2Ejava +++ b/asterixdb/asterix-om/src/main/java/org/apache/asteri= x/om/typecomputer/impl/ScalarVersionOfAggregateResultType=2Ejava @@ -18,9 += 18,7 @@ */ package org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Eimpl; = -import org=2Eapache=2Easterix=2Eom=2Eexceptions=2ETypeMismatchException; = import org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultTy= peComputer; -import org=2Eapache=2Easterix=2Eom=2Etypes=2EATypeTag; import= org=2Eapache=2Easterix=2Eom=2Etypes=2EAUnionType; import org=2Eapache=2Ea= sterix=2Eom=2Etypes=2EAbstractCollectionType; import org=2Eapache=2Easteri= x=2Eom=2Etypes=2EBuiltinType; @@ -32,32 +30,48 @@ public class ScalarVer= sionOfAggregateResultType extends AbstractResultTypeComputer { - publi= c static final ScalarVersionOfAggregateResultType INSTANCE =3D new ScalarVe= rsionOfAggregateResultType(); + private final AggregateResultTypeCompute= r aggResultTypeComputer; - private ScalarVersionOfAggregateResultType(= ) { + public ScalarVersionOfAggregateResultType(AggregateResultTypeCompu= ter aggResultTypeComputer) { + this=2EaggResultTypeComputer =3D aggR= esultTypeComputer; } @Override - public void checkArgType(Fu= nctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLo= c) + protected void checkArgType(FunctionIdentifier funcId, int argIndex= , IAType argType, SourceLocation sourceLoc) throws AlgebricksE= xception { - ATypeTag tag =3D type=2EgetTypeTag(); - if (tag = !=3D ATypeTag=2EANY && tag !=3D ATypeTag=2EARRAY && tag !=3D ATypeTag=2EMUL= TISET) { - throw new TypeMismatchException(sourceLoc, funcId, ar= gIndex, tag, ATypeTag=2EARRAY, ATypeTag=2EMULTISET); + if (argIndex = =3D=3D 0) { + switch (argType=2EgetTypeTag()) { + = case ARRAY: + case MULTISET: + AbstractC= ollectionType act =3D (AbstractCollectionType) argType; + = aggResultTypeComputer=2EcheckArgType(funcId, argIndex, act=2EgetItemType(= ), sourceLoc); + break; + } } }= @Override protected IAType getResultType(ILogicalExpression ex= pr, IAType=2E=2E=2E strippedInputTypes) throws AlgebricksException { - = ATypeTag tag =3D strippedInputTypes[0]=2EgetTypeTag(); - if (tag = =3D=3D ATypeTag=2EANY) { - return BuiltinType=2EANY; + IA= Type argType =3D strippedInputTypes[0]; + switch (argType=2EgetTypeT= ag()) { + case ARRAY: + case MULTISET: + = AbstractCollectionType act =3D (AbstractCollectionType) argType; + = IAType[] strippedInputTypes2 =3D strippedInputTypes=2Eclone(); + = strippedInputTypes2[0] =3D act=2EgetItemType(); + = IAType resultType =3D aggResultTypeComputer=2EgetResultType(expr, stri= ppedInputTypes2); + switch (resultType=2EgetTypeTag()) { + = case NULL: + case MISSING: + = case ANY: + return resultType; + = case UNION: + return AUnionType=2EcreateUn= knownableType(((AUnionType) resultType)=2EgetActualType()); + = default: + return AUnionType=2EcreateUnknownab= leType(resultType); + } + default: + = return BuiltinType=2EANY; } - if (tag !=3D ATypeTag=2EAR= RAY && tag !=3D ATypeTag=2EMULTISET) { - // this condition being= true would've thrown an exception above, no? - return strippedI= nputTypes[0]; - } - AbstractCollectionType act =3D (AbstractC= ollectionType) strippedInputTypes[0]; - IAType t =3D act=2EgetItemTy= pe(); - return AUnionType=2EcreateUnknownableType(t); } } -- = To view, visit https://asterix-gerrit=2Eics=2Euci=2Eedu/c/asterixdb/+/1198= 4 To unsubscribe, or for help writing mail filters, visit https://asterix-g= errit=2Eics=2Euci=2Eedu/settings Gerrit-Project: asterixdb Gerrit-Branch: = mad-hatter Gerrit-Change-Id: Ic587f29840262f052f15e7d257c3d7dda7e40686 Gerr= it-Change-Number: 11984 Gerrit-PatchSet: 1 Gerrit-Owner: Dmitry Lychagin Gerrit-MessageType: newchange --SdjxmGwSOaQ= Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Dmitry Lychagin has uploaded this change for review=2E<= /p>

View Change

[ASTERIXDB-2843][COMP] Fix type computer for scalar agg=
regates

- user model changes: no
- storage format changes: no
= - interface changes: no

Details:
- Align type computation for sca= lar aggregates with
regular aggregates

Change-Id: Ic587f2984026= 2f052f15e7d257c3d7dda7e40686
---
M asterixdb/asterix-om/src/main/java= /org/apache/asterix/om/functions/BuiltinFunctions=2Ejava
A asterixdb/ast= erix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AggregateResu= ltTypeComputer=2Ejava
M asterixdb/asterix-om/src/main/java/org/apache/as= terix/om/typecomputer/impl/MinMaxAggTypeComputer=2Ejava
M asterixdb/aste= rix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggT= ypeComputer=2Ejava
M asterixdb/asterix-om/src/main/java/org/apache/aster= ix/om/typecomputer/impl/ScalarVersionOfAggregateResultType=2Ejava
5 file= s changed, 93 insertions(+), 61 deletions(-)

git pull ssh://aster=
ix-gerrit=2Eics=2Euci=2Eedu:29418/asterixdb refs/changes/84/11984/1
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/func= tions/BuiltinFunctions=2Ejava b/asterixdb/asterix-om/src/main/java/org/apac= he/asterix/om/functions/BuiltinFunctions=2Ejava
index bf270= 9a=2E=2Ef2a1edf 100644
--- a/asterixdb/asterix-om/src/main/= java/org/apache/asterix/om/functions/BuiltinFunctions=2Ejava
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/= BuiltinFunctions=2Ejava
@@ -1771,6 +1771,11 @@
addFunction(NEGINF_IF, DoubleIfTypeComputer=2EINSTANCE, true);=

// Aggregate Functions+ ScalarVersionOfAggre= gateResultType scalarNumericSumTypeComputer =3D
+ new ScalarVersionOfAggregateRes= ultType(NumericSumAggTypeComputer=2EINSTANCE);
+ ScalarVersionOfAggregateResultType scala= rMinMaxTypeComputer =3D
+ new ScalarVersionOfAggregateResultType(MinMaxAggTypeCom= puter=2EINSTANCE);
+<= /span>
addPrivateFunction(LISTIFY, OrderedListConstructor= TypeComputer=2EINSTANCE, true);
addFunction(SCALAR= _ARRAYAGG, ScalarArrayAggTypeComputer=2EINSTANCE, true);
= addFunction(MAX, MinMaxAggTypeComputer=2EINSTANCE, true);
= @@ -1816,7 +1821,7 @@

// S= UM
addFunction(SUM, NumericSumAggTypeComputer=2EIN= STANCE, true);
- = addFunction(SCALAR_SUM, ScalarVersionOfAggregateResultType=2EINSTANCE, tru= e);
+ addFunct= ion(SCALAR_SUM, scalarNumericSumTypeComputer, true);
= addPrivateFunction(LOCAL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true= );
addPrivateFunction(INTERMEDIATE_SUM, NumericSum= AggTypeComputer=2EINSTANCE, true);
addPrivateFunct= ion(GLOBAL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true);
@@ -1832,8 +1837,8 @@

addPrivateFunction(SERIAL_= INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer=2EINSTANCE, true);
addFunction(SCALAR_AVG, NullableDoubleTypeComputer=2EINSTANCE, = true);
addFunction(SCALAR_COUNT, AInt64TypeCompute= r=2EINSTANCE, true);
- = addFunction(SCALAR_MAX, ScalarVersionOfAggregateResultType=2EINSTANC= E, true);
- addF= unction(SCALAR_MIN, ScalarVersionOfAggregateResultType=2EINSTANCE, true);
+ addFunction(S= CALAR_MAX, scalarMinMaxTypeComputer, true);
+ addFunction(SCALAR_MIN, scalarMinMaxTypeCom= puter, true);
addPrivateFunction(INTERMEDIATE_AVG,= LocalAvgTypeComputer=2EINSTANCE, true);
addFuncti= on(SCALAR_STDDEV_SAMP, NullableDoubleTypeComputer=2EINSTANCE, true);=
addPrivateFunction(INTERMEDIATE_STDDEV_SAMP, LocalSingle= VarStatisticsTypeComputer=2EINSTANCE, true);
@@ -1874,7 +18= 79,7 @@

// SQL SUM
addFunction(SQL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true= );

- addFunction= (SCALAR_SQL_SUM, ScalarVersionOfAggregateResultType=2EINSTANCE, true);

+ addFunction(SCAL= AR_SQL_SUM, scalarNumericSumTypeComputer, true);
a= ddPrivateFunction(LOCAL_SQL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true= );
addPrivateFunction(INTERMEDIATE_SQL_SUM, Numeri= cSumAggTypeComputer=2EINSTANCE, true);
addPrivateF= unction(GLOBAL_SQL_SUM, NumericSumAggTypeComputer=2EINSTANCE, true);=
@@ -1898,8 +1903,8 @@
addPrivateFunction= (GLOBAL_SQL_MIN, MinMaxAggTypeComputer=2EINSTANCE, true);
= addFunction(SCALAR_SQL_AVG, NullableDoubleTypeComputer=2EINSTANCE, = true);
addFunction(SCALAR_SQL_COUNT, AInt64TypeCom= puter=2EINSTANCE, true);
- = addFunction(SCALAR_SQL_MIN, ScalarVersionOfAggregateResultType=2EINST= ANCE, true);
+ = addFunction(SCALAR_SQL_MAX, scalarMinMaxTypeComputer, true);
+ addFunction(SCALAR_SQL_MI= N, scalarMinMaxTypeComputer, true);
addPrivateFunc= tion(INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer=2EINSTANCE, true); addFunction(SQL_STDDEV_SAMP, NullableDoubleTypeComputer=2E= INSTANCE, true);
addPrivateFunction(GLOBAL_SQL_STD= DEV_SAMP, NullableDoubleTypeComputer=2EINSTANCE, true);
@@ = -1974,9 +1979,9 @@
addFunction(SCALAR_SQL_COUNT_DI= STINCT, AInt64TypeComputer=2EINSTANCE, true);

<= span> addFunction(SUM_DISTINCT, NumericSumAggTypeComputer=2EINSTANC= E, true);
- addF= unction(SCALAR_SUM_DISTINCT, ScalarVersionOfAggregateResultType=2EINSTANCE,= true);
+ addF= unction(SCALAR_SUM_DISTINCT, scalarNumericSumTypeComputer, true); addFunction(SQL_SUM_DISTINCT, NumericSumAggTypeComputer=2EI= NSTANCE, true);
- = addFunction(SCALAR_SQL_SUM_DISTINCT, ScalarVersionOfAggregateResultType= =2EINSTANCE, true);
+= addFunction(SCALAR_SQL_SUM_DISTINCT, scalarNumericSumTypeComputer, = true);

addFunction(AVG_DISTINCT,= NullableDoubleTypeComputer=2EINSTANCE, true);
add= Function(SCALAR_AVG_DISTINCT, NullableDoubleTypeComputer=2EINSTANCE, true);=
@@ -1984,14 +1989,14 @@
addFuncti= on(SCALAR_SQL_AVG_DISTINCT, NullableDoubleTypeComputer=2EINSTANCE, true);

addFunction(MAX_DISTINCT, MinMaxA= ggTypeComputer=2EINSTANCE, true);
- addFunction(SCALAR_MAX_DISTINCT, ScalarVersionOfAggrega= teResultType=2EINSTANCE, true);
+ addFunction(SCALAR_MAX_DISTINCT, scalarMinMaxTypeComput= er, true);
addFunction(SQL_MAX_DISTINCT, MinMaxAgg= TypeComputer=2EINSTANCE, true);
- addFunction(SCALAR_SQL_MAX_DISTINCT, ScalarVersionOfAggre= gateResultType=2EINSTANCE, true);
+ addFunction(SCALAR_SQL_MAX_DISTINCT, scalarMinMaxType= Computer, true);

addFunction(MIN= _DISTINCT, MinMaxAggTypeComputer=2EINSTANCE, true);
- addFunction(SCALAR_MIN_DISTINCT, Sc= alarVersionOfAggregateResultType=2EINSTANCE, true);
+ addFunction(SCALAR_MIN_DISTINCT, = scalarMinMaxTypeComputer, true);
addFunction(SQL_M= IN_DISTINCT, MinMaxAggTypeComputer=2EINSTANCE, true);
- addFunction(SCALAR_SQL_MIN_DISTINCT= , ScalarVersionOfAggregateResultType=2EINSTANCE, true);
+ addFunction(SCALAR_SQL_MIN_DIST= INCT, scalarMinMaxTypeComputer, true);

= addFunction(STDDEV_SAMP_DISTINCT, NullableDoubleTypeComputer=2EINSTA= NCE, true);
addFunction(SCALAR_STDDEV_SAMP_DISTINC= T, NullableDoubleTypeComputer=2EINSTANCE, true);
diff --git= a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/im= pl/AggregateResultTypeComputer=2Ejava b/asterixdb/asterix-om/src/main/java/= org/apache/asterix/om/typecomputer/impl/AggregateResultTypeComputer=2Ejava<= /span>
new file mode 100644
index 0000000=2E=2E8e6= 63a7
--- /dev/null
+++ b/asterixdb/asterix-= om/src/main/java/org/apache/asterix/om/typecomputer/impl/AggregateResultTyp= eComputer=2Ejava
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one<= /span>
+ * or more contribut= or license agreements=2E See the NOTICE file
+ * distributed with this work for additional info= rmation
+ * regarding= copyright ownership=2E The ASF licenses this file
+ * to you under the Apache License, Versi= on 2=2E0 (the
+ * &qu= ot;License"); you may not use this file except in compliance+ * with the License=2E You m= ay obtain a copy of the License at
+ *
+ *= http://www=2Eapache=2Eorg/licenses/LICENSE-2=2E0
+ *
+ * Unless required by applicable law or agreed to in writi= ng,
+ * software dist= ributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES O= R CONDITIONS OF ANY
+= * KIND, either express or implied=2E See the License for the
+ * specific language governing p= ermissions and limitations

+ * under the License=2E
+ */
+
+package org=2Eapache=2Ea= sterix=2Eom=2Etypecomputer=2Eimpl;
+
+impo= rt org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultTypeCo= mputer;
+import org= =2Eapache=2Easterix=2Eom=2Etypes=2EIAType;
+import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecommon= =2Eexceptions=2EAlgebricksException;
+import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealgebr= a=2Ebase=2EILogicalExpression;
+import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealgebra=2Efu= nctions=2EFunctionIdentifier;
+import org=2Eapache=2Ehyracks=2Eapi=2Eexceptions=2ESourceLocation= ;
+
+public abstract class AggregateResult= TypeComputer extends AbstractResultTypeComputer {
+ @Override
+ protected void checkArgType(FunctionIdentifier = funcId, int argIndex, IAType type, SourceLocation sourceLoc)
+ throws AlgebricksExcep= tion {

+ super= =2EcheckArgType(funcId, argIndex, type, sourceLoc);
+ }
+
= + @Override
+ p= rotected abstract IAType getResultType(ILogicalExpression expr, IAType=2E= =2E=2E strippedInputTypes)
+ throws AlgebricksException;
+}
\ No newline at end of file
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/as= terix/om/typecomputer/impl/MinMaxAggTypeComputer=2Ejava b/asterixdb/asterix= -om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComp= uter=2Ejava
index c34b5ed=2E=2Efc1eee5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecompu= ter/impl/MinMaxAggTypeComputer=2Ejava

+++ b/asterixdb/aster= ix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeCo= mputer=2Ejava
@@ -19,7 +19,6 @@
package or= g=2Eapache=2Easterix=2Eom=2Etypecomputer=2Eimpl;
import org=2Eapache=2Easterix=2Edataflow=2Edata=2Ecommon=2EILogica= lBinaryComparator;
-imp= ort org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultTypeC= omputer;
import org=2Eapache=2Easterix=2Eom=2Etypes=2EATyp= eTag;
import org=2Eapache=2Easterix=2Eom=2Etypes=2EAUnionT= ype;
import org=2Eapache=2Easterix=2Eom=2Etypes=2EBuiltinT= ype;
@@ -27,7 +26,7 @@
import org=2Eapache= =2Ehyracks=2Ealgebricks=2Ecommon=2Eexceptions=2EAlgebricksException;=
import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealgebra=2Eba= se=2EILogicalExpression;

-public class MinMaxAggTypeComputer extends AbstractRes= ultTypeComputer {
+pu= blic class MinMaxAggTypeComputer extends AggregateResultTypeComputer {

public static final MinMaxAggTypeCompute= r INSTANCE =3D new MinMaxAggTypeComputer();

diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/ty= pecomputer/impl/NumericSumAggTypeComputer=2Ejava b/asterixdb/asterix-om/src= /main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggTypeCompute= r=2Ejava

index 1c67e56=2E=2Ea4b5e34 100644
= --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer= /impl/NumericSumAggTypeComputer=2Ejava
+++ b/asterixdb/aste= rix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggT= ypeComputer=2Ejava
@@ -18,42 +18,20 @@
*/=
package org=2Eapache=2Easterix=2Eom=2Etypecomputer=2Eimpl= ;

-im= port org=2Eapache=2Easterix=2Eom=2Eexceptions=2EUnsupportedTypeException;
-import org=2Eapache=2Ea= sterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultTypeComputer;
<= span> import org=2Eapache=2Easterix=2Eom=2Etypes=2EATypeTag;

import org=2Eapache=2Easterix=2Eom=2Etypes=2EAUnionType;

import org=2Eapache=2Easterix=2Eom=2Etypes=2EBuiltinType;

import org=2Eapache=2Easterix=2Eom=2Etypes=2EIAType;
imp= ort org=2Eapache=2Ehyracks=2Ealgebricks=2Ecommon=2Eexceptions=2EAlgebricksE= xception;
import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecor= e=2Ealgebra=2Ebase=2EILogicalExpression;
-import org=2Eapache=2Ehyracks=2Ealgebricks=2Ecore=2Ealge= bra=2Efunctions=2EFunctionIdentifier;
-import org=2Eapache=2Ehyracks=2Eapi=2Eexceptions=2ESourceLo= cation;

-public class NumericSumAggTypeComputer extends AbstractResultTypeComput= er {
+public class Nu= mericSumAggTypeComputer extends AggregateResultTypeComputer {
public static final NumericSumAggTypeComputer INSTANCE =3D new Nume= ricSumAggTypeComputer();

private Num= ericSumAggTypeComputer() {
}
<= br> @Override
- protected void checkArgType(FunctionIdentifier funcId, int argIndex, = IAType type, SourceLocation sourceLoc)
- throws AlgebricksException {
- ATypeTag tag =3D type=2EgetType= Tag();
- switch = (tag) {
- ca= se DOUBLE:
- = case FLOAT:
- = case BIGINT:
- = case INTEGER:
- = case SMALLINT:
- case ANY:
- break;
- default:
- throw new UnsupportedTypeException(sourceLoc, funcId= , tag);
- }
- }
-
- @Override
protected IAType getResultTy= pe(ILogicalExpression expr, IAType=2E=2E=2E strippedInputTypes) throws Alge= bricksException {
ATypeTag tag =3D strippedInputTy= pes[0]=2EgetTypeTag();
switch (tag) {
@@ -61,15 +39,12 @@

case SMALLINT:<= br> case INTEGER:
case BIGIN= T:
- IAT= ype int64Type =3D BuiltinType=2EAINT64;
- return AUnionType=2EcreateNullableType(in= t64Type, "AggResult");
+ return AUnionType=2EcreateNullableType(Builtin= Type=2EAINT64);
case FLOAT:
= case DOUBLE:
- IAType doubleType =3D BuiltinType=2EADOUBLE;
- return AUnionType= =2EcreateNullableType(doubleType, "AggResult");
+ return AUnionType=2Ec= reateNullableType(BuiltinType=2EADOUBLE);
case= ANY:
- = IAType anyType =3D strippedInputTypes[0];
- return AUnionType=2EcreateNullableType(= anyType, "AggResult");
+ return BuiltinType=2EANY;
= default:
// All other possible ca= ses=2E
return BuiltinType=2EANULL;<= br>diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix= /om/typecomputer/impl/ScalarVersionOfAggregateResultType=2Ejava b/asterixdb= /asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVer= sionOfAggregateResultType=2Ejava
index 5b90974=2E=2Efda0285= 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache= /asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType=2Ejava

+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om= /typecomputer/impl/ScalarVersionOfAggregateResultType=2Ejava
@@ -18,9 +18,7 @@
*/
package org=2Eapa= che=2Easterix=2Eom=2Etypecomputer=2Eimpl;

-import org=2Eapache=2Easterix=2Eom=2E= exceptions=2ETypeMismatchException;
import org=2Eapache=2E= asterix=2Eom=2Etypecomputer=2Ebase=2EAbstractResultTypeComputer;
= -import org=2Eapache=2Easterix=2E= om=2Etypes=2EATypeTag;
import org=2Eapache=2Easterix=2Eom= =2Etypes=2EAUnionType;
import org=2Eapache=2Easterix=2Eom= =2Etypes=2EAbstractCollectionType;
import org=2Eapache=2Ea= sterix=2Eom=2Etypes=2EBuiltinType;
@@ -32,32 +30,48 @@


public class ScalarVersionOfAggregateResultT= ype extends AbstractResultTypeComputer {

- public static final ScalarVersionO= fAggregateResultType INSTANCE =3D new ScalarVersionOfAggregateResultType();=
+ private final A= ggregateResultTypeComputer aggResultTypeComputer;
<= br>- private ScalarVersionOfAg= gregateResultType() {
+ public ScalarVersionOfAggregateResultType(AggregateResultTypeComputer= aggResultTypeComputer) {
+ this=2EaggResultTypeComputer =3D aggResultTypeComputer;

}

@Override- public void checkArgType(F= unctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceL= oc)
+ protected vo= id checkArgType(FunctionIdentifier funcId, int argIndex, IAType argType, So= urceLocation sourceLoc)
throws AlgebricksExcep= tion {
- ATypeTa= g tag =3D type=2EgetTypeTag();
- if (tag !=3D ATypeTag=2EANY && tag !=3D ATypeTag= =2EARRAY && tag !=3D ATypeTag=2EMULTISET) {
- throw new TypeMismatchException= (sourceLoc, funcId, argIndex, tag, ATypeTag=2EARRAY, ATypeTag=2EMULTISET);<= /span>
+ if (argIndex= =3D=3D 0) {
+ = switch (argType=2EgetTypeTag()) {
+ case ARRAY:
+ case MULTISET:
+ AbstractCollectio= nType act =3D (AbstractCollectionType) argType;
+ aggResultTypeComputer=2Eche= ckArgType(funcId, argIndex, act=2EgetItemType(), sourceLoc);
+ break;
<= br>+ }
}
}

= @Override
protected IAType getResultType(ILogicalExpr= ession expr, IAType=2E=2E=2E strippedInputTypes) throws AlgebricksException= {
- ATypeTag ta= g =3D strippedInputTypes[0]=2EgetTypeTag();
- if (tag =3D=3D ATypeTag=2EANY) {
- return BuiltinType=2EA= NY;
+ IAType a= rgType =3D strippedInputTypes[0];
+ switch (argType=2EgetTypeTag()) {
+ case ARRAY:
+ case MULTISET:+ AbstractColl= ectionType act =3D (AbstractCollectionType) argType;
+ IAType[] strippedInputTyp= es2 =3D strippedInputTypes=2Eclone();
+ strippedInputTypes2[0] =3D act=2EgetItemT= ype();
+ = IAType resultType =3D aggResultTypeComputer=2EgetResultType(expr, stripp= edInputTypes2);
+ = switch (resultType=2EgetTypeTag()) {
+ case NULL:
+ case MISSING:
+ c= ase ANY:
+ = return resultType;
+ case UNION:
+ return AUnionType=2EcreateU= nknownableType(((AUnionType) resultType)=2EgetActualType());
+ default:

+ r= eturn AUnionType=2EcreateUnknownableType(resultType);
+ }
+ default:
+ return BuiltinType=2EANY= ;
}
- if (tag !=3D ATypeTag=2EARRAY && tag !=3D ATypeTag= =2EMULTISET) {
- = // this condition being true would've thrown an exception above, n= o?
- return = strippedInputTypes[0];
= - }
- Abs= tractCollectionType act =3D (AbstractCollectionType) strippedInputTypes[0];=
- IAType t =3D = act=2EgetItemType();
- = return AUnionType=2EcreateUnknownableType(t);
}=
}

To view, visit change= 11984=2E To unsubscribe, or for help writing mail filters, visit settings=2E

Gerrit-Project= : asterixdb
Gerrit-Branch: mad-hatter <= /div>
Gerrit-Change-Id: Ic587f29840262f052f15e= 7d257c3d7dda7e40686
Gerrit-Change-Numbe= r: 11984
Gerrit-PatchSet: 1
Gerrit-Owner: Dmitry Lychagin <dmitry=2Elychagi= n@couchbase=2Ecom>
Gerrit-MessageTyp= e: newchange
--SdjxmGwSOaQ=--