Add EXISTS/NOT EXISTS.
- Fixed the precedence order of NOT.
Change-Id: I7ec20753659e2de2fd65e5f858e0f73796b907d0
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1001
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
index d207f20..39648d1 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
@@ -65,7 +65,6 @@
import org.apache.asterix.lang.common.expression.RecordTypeDefinition;
import org.apache.asterix.lang.common.expression.TypeReferenceExpression;
import org.apache.asterix.lang.common.expression.UnaryExpr;
-import org.apache.asterix.lang.common.expression.UnaryExpr.Sign;
import org.apache.asterix.lang.common.expression.UnorderedListTypeDefinition;
import org.apache.asterix.lang.common.expression.VariableExpr;
import org.apache.asterix.lang.common.statement.CompactStatement;
@@ -100,6 +99,7 @@
import org.apache.asterix.lang.common.struct.Identifier;
import org.apache.asterix.lang.common.struct.OperatorType;
import org.apache.asterix.lang.common.struct.QuantifiedPair;
+import org.apache.asterix.lang.common.struct.UnaryExprType;
import org.apache.asterix.lang.common.util.FunctionUtil;
import org.apache.asterix.metadata.declared.AqlMetadataProvider;
import org.apache.asterix.metadata.declared.FileSplitDataSink;
@@ -246,8 +246,8 @@
throw new AlgebricksException("Data format has not been set.");
}
format.registerRuntimeFunctions(FunctionCollection.getFunctionDescriptorFactories());
- Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
- new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator()));
+ Pair<ILogicalOperator, LogicalVariable> p =
+ expr.accept(this, new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator()));
ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
@@ -270,15 +270,15 @@
if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
throw new AlgebricksException("Cannot write output to an external dataset.");
}
- ARecordType itemType = (ARecordType) metadata.findType(dataset.getItemTypeDataverseName(),
- dataset.getItemTypeName());
+ ARecordType itemType =
+ (ARecordType) metadata.findType(dataset.getItemTypeDataverseName(), dataset.getItemTypeName());
List<List<String>> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
ArrayList<LogicalVariable> vars = new ArrayList<LogicalVariable>();
ArrayList<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>();
List<Mutable<ILogicalExpression>> varRefsForLoading = new ArrayList<Mutable<ILogicalExpression>>();
for (List<String> partitioningKey : partitioningKeys) {
- Triple<IScalarEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioner = format
- .partitioningEvaluatorFactory(itemType, partitioningKey);
+ Triple<IScalarEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioner =
+ format.partitioningEvaluatorFactory(itemType, partitioningKey);
AbstractFunctionCallExpression f = partitioner.second.cloneExpression();
f.substituteVar(METADATA_DUMMY_VAR, resVar);
exprs.add(new MutableObject<ILogicalExpression>(f));
@@ -354,8 +354,8 @@
break;
}
default: {
- Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(lc.getBindingExpr(),
- tupSource);
+ Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo =
+ aqlExprToAlgExpression(lc.getBindingExpr(), tupSource);
v = context.newVar(lc.getVarExpr());
returnedOp = new AssignOperator(v, new MutableObject<ILogicalExpression>(eo.first));
returnedOp.getInputs().add(eo.second);
@@ -414,8 +414,8 @@
AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME));
fldAccess.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
- ILogicalExpression faExpr = new ConstantExpression(
- new AsterixConstantValue(new AString(fa.getIdent().getValue())));
+ ILogicalExpression faExpr =
+ new ConstantExpression(new AsterixConstantValue(new AString(fa.getIdent().getValue())));
fldAccess.getArguments().add(new MutableObject<ILogicalExpression>(faExpr));
AssignOperator a = new AssignOperator(v, new MutableObject<ILogicalExpression>(fldAccess));
a.getInputs().add(p.second);
@@ -434,8 +434,8 @@
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER));
f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
} else {
- Pair<ILogicalExpression, Mutable<ILogicalOperator>> indexPair = aqlExprToAlgExpression(ia.getIndexExpr(),
- tupSource);
+ Pair<ILogicalExpression, Mutable<ILogicalOperator>> indexPair =
+ aqlExprToAlgExpression(ia.getIndexExpr(), tupSource);
f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.GET_ITEM));
f.getArguments().add(new MutableObject<ILogicalExpression>(p.first));
f.getArguments().add(new MutableObject<ILogicalExpression>(indexPair.first));
@@ -495,8 +495,8 @@
if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
f = AsterixBuiltinFunctions.makeAggregateFunctionExpression(fi, args);
} else if (AsterixBuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
- UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(fi),
- args);
+ UnnestingFunctionCallExpression ufce =
+ new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(fi), args);
ufce.setReturnsUniqueValues(AsterixBuiltinFunctions.returnsUniqueValues(fi));
f = ufce;
} else {
@@ -552,8 +552,8 @@
LogicalVariable oldVar = context.getVar(var);
List<Mutable<ILogicalExpression>> flArgs = new ArrayList<Mutable<ILogicalExpression>>(1);
flArgs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(oldVar)));
- AggregateFunctionCallExpression fListify = AsterixBuiltinFunctions
- .makeAggregateFunctionExpression(AsterixBuiltinFunctions.LISTIFY, flArgs);
+ AggregateFunctionCallExpression fListify =
+ AsterixBuiltinFunctions.makeAggregateFunctionExpression(AsterixBuiltinFunctions.LISTIFY, flArgs);
AggregateOperator agg = new AggregateOperator(mkSingletonArrayList(aggVar),
(List) mkSingletonArrayList(new MutableObject<ILogicalExpression>(fListify)));
agg.getInputs().add(new MutableObject<ILogicalOperator>(
@@ -596,9 +596,9 @@
sel1.getInputs().add(new MutableObject<ILogicalOperator>(pThen.first));
Pair<ILogicalOperator, LogicalVariable> pElse = ifexpr.getElseExpr().accept(this, nestedSource);
- AbstractFunctionCallExpression notVarCond = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
- new MutableObject<ILogicalExpression>(new VariableReferenceExpression(varCond)));
+ AbstractFunctionCallExpression notVarCond =
+ new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
+ new MutableObject<ILogicalExpression>(new VariableReferenceExpression(varCond)));
SelectOperator sel2 = new SelectOperator(new MutableObject<ILogicalExpression>(notVarCond), false, null);
sel2.getInputs().add(new MutableObject<ILogicalOperator>(pElse.first));
@@ -611,10 +611,10 @@
sp.getInputs().add(opCondRef);
LogicalVariable resV = context.newVar();
- AbstractFunctionCallExpression concatNonNull = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.CONCAT_NON_NULL),
- new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pThen.second)),
- new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pElse.second)));
+ AbstractFunctionCallExpression concatNonNull =
+ new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.CONCAT_NON_NULL),
+ new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pThen.second)),
+ new MutableObject<ILogicalExpression>(new VariableReferenceExpression(pElse.second)));
AssignOperator a = new AssignOperator(resV, new MutableObject<ILogicalExpression>(concatNonNull));
a.getInputs().add(new MutableObject<ILogicalOperator>(sp));
@@ -747,8 +747,8 @@
Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = aqlExprToAlgExpression(qt.getExpr(), topOp);
topOp = eo1.second;
LogicalVariable uVar = context.newVar(qt.getVarExpr());
- ILogicalOperator u = new UnnestOperator(uVar,
- new MutableObject<ILogicalExpression>(makeUnnestExpression(eo1.first)));
+ ILogicalOperator u =
+ new UnnestOperator(uVar, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo1.first)));
if (firstOp == null) {
firstOp = u;
@@ -840,7 +840,7 @@
Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = aqlExprToAlgExpression(expr, tupSource);
LogicalVariable v1 = context.newVar();
AssignOperator a;
- if (u.getSign() == Sign.POSITIVE) {
+ if (u.getExprType() == UnaryExprType.POSITIVE) {
a = new AssignOperator(v1, new MutableObject<ILogicalExpression>(eo.first));
} else {
AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
@@ -857,8 +857,8 @@
// Should we ever get to this method?
LogicalVariable var = context.newVar();
LogicalVariable oldV = context.getVar(v.getVar().getId());
- AssignOperator a = new AssignOperator(var,
- new MutableObject<ILogicalExpression>(new VariableReferenceExpression(oldV)));
+ AssignOperator a =
+ new AssignOperator(var, new MutableObject<ILogicalExpression>(new VariableReferenceExpression(oldV)));
a.getInputs().add(tupSource);
return new Pair<ILogicalOperator, LogicalVariable>(a, var);
}
@@ -931,11 +931,10 @@
UnnestOperator unnest2 = new UnnestOperator(unnestVar2, new MutableObject<ILogicalExpression>(
makeUnnestExpression(new VariableReferenceExpression(p1.second))));
unnest2.getInputs().add(new MutableObject<ILogicalOperator>(p1.first));
- List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>(
- 1);
+ List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<>(1);
LogicalVariable resultVar = context.newVar();
- Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(
- unnestVar1, unnestVar2, resultVar);
+ Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple =
+ new Triple<>(unnestVar1, unnestVar2, resultVar);
varMap.add(triple);
UnionAllOperator unionOp = new UnionAllOperator(varMap);
unionOp.getInputs().add(new MutableObject<ILogicalOperator>(unnest1));
@@ -949,8 +948,8 @@
aggregVars.add(aggVar);
List<Mutable<ILogicalExpression>> afcExprs = new ArrayList<Mutable<ILogicalExpression>>(1);
afcExprs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(lastVar)));
- AggregateFunctionCallExpression afc = AsterixBuiltinFunctions
- .makeAggregateFunctionExpression(AsterixBuiltinFunctions.LISTIFY, afcExprs);
+ AggregateFunctionCallExpression afc =
+ AsterixBuiltinFunctions.makeAggregateFunctionExpression(AsterixBuiltinFunctions.LISTIFY, afcExprs);
ArrayList<Mutable<ILogicalExpression>> aggregExprs = new ArrayList<Mutable<ILogicalExpression>>(1);
aggregExprs.add(new MutableObject<ILogicalExpression>(afc));
AggregateOperator agg = new AggregateOperator(aggregVars, aggregExprs);
@@ -1055,8 +1054,8 @@
Mutable<ILogicalOperator> topOp) throws AsterixException {
switch (expr.getKind()) {
case VARIABLE_EXPRESSION: {
- VariableReferenceExpression ve = new VariableReferenceExpression(
- context.getVar(((VariableExpr) expr).getVar().getId()));
+ VariableReferenceExpression ve =
+ new VariableReferenceExpression(context.getVar(((VariableExpr) expr).getVar().getId()));
return new Pair<ILogicalExpression, Mutable<ILogicalOperator>>(ve, topOp);
}
case METAVARIABLE_EXPRESSION: {
@@ -1272,8 +1271,8 @@
opRef = new MutableObject<ILogicalOperator>(rightSide.first);
}
- Pair<ILogicalExpression, Mutable<ILogicalOperator>> whereCond = aqlExprToAlgExpression(jc.getWhereExpr(),
- tupSource);
+ Pair<ILogicalExpression, Mutable<ILogicalOperator>> whereCond =
+ aqlExprToAlgExpression(jc.getWhereExpr(), tupSource);
AbstractBinaryJoinOperator join;
switch (jc.getKind()) {
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
index 03b530b..b8786d1 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
@@ -59,7 +59,6 @@
import org.apache.asterix.lang.common.expression.QuantifiedExpression.Quantifier;
import org.apache.asterix.lang.common.expression.RecordConstructor;
import org.apache.asterix.lang.common.expression.UnaryExpr;
-import org.apache.asterix.lang.common.expression.UnaryExpr.Sign;
import org.apache.asterix.lang.common.expression.VariableExpr;
import org.apache.asterix.lang.common.literal.StringLiteral;
import org.apache.asterix.lang.common.statement.FunctionDecl;
@@ -84,6 +83,7 @@
import org.apache.asterix.metadata.feeds.FeedMetadataUtil;
import org.apache.asterix.metadata.functions.ExternalFunctionCompilerUtil;
import org.apache.asterix.metadata.utils.DatasetUtils;
+import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -191,10 +191,10 @@
"Unable to load dataset " + clffs.getDatasetName() + " since it does not exist");
}
IAType itemType = metadataProvider.findType(dataset.getItemTypeDataverseName(), dataset.getItemTypeName());
- IAType metaItemType = metadataProvider.findType(dataset.getMetaItemTypeDataverseName(),
- dataset.getMetaItemTypeName());
- DatasetDataSource targetDatasource = validateDatasetInfo(metadataProvider, stmt.getDataverseName(),
- stmt.getDatasetName());
+ IAType metaItemType =
+ metadataProvider.findType(dataset.getMetaItemTypeDataverseName(), dataset.getMetaItemTypeName());
+ DatasetDataSource targetDatasource =
+ validateDatasetInfo(metadataProvider, stmt.getDataverseName(), stmt.getDatasetName());
List<List<String>> partitionKeys = DatasetUtils.getPartitioningKeys(targetDatasource.getDataset());
if (dataset.hasMetaPart()) {
throw new AlgebricksException(
@@ -257,8 +257,8 @@
additionalFilteringExpressions = new ArrayList<>();
PlanTranslationUtil.prepareVarAndExpression(additionalFilteringField, payloadVar, additionalFilteringVars,
additionalFilteringAssignExpressions, additionalFilteringExpressions, context);
- additionalFilteringAssign = new AssignOperator(additionalFilteringVars,
- additionalFilteringAssignExpressions);
+ additionalFilteringAssign =
+ new AssignOperator(additionalFilteringVars, additionalFilteringAssignExpressions);
}
InsertDeleteUpsertOperator insertOp = new InsertDeleteUpsertOperator(targetDatasource, payloadRef,
@@ -281,8 +281,8 @@
@Override
public ILogicalPlan translate(Query expr, String outputDatasetName, ICompiledDmlStatement stmt)
throws AlgebricksException, AsterixException {
- Pair<ILogicalOperator, LogicalVariable> p = expr.accept(this,
- new MutableObject<>(new EmptyTupleSourceOperator()));
+ Pair<ILogicalOperator, LogicalVariable> p =
+ expr.accept(this, new MutableObject<>(new EmptyTupleSourceOperator()));
ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<>();
ILogicalOperator topOp = p.first;
ProjectOperator project = (ProjectOperator) topOp;
@@ -324,10 +324,11 @@
project.getInputs().get(0).setValue(assignCollectionToSequence);
project.getVariables().set(0, seqVar);
resVar = seqVar;
- DatasetDataSource targetDatasource = validateDatasetInfo(metadataProvider, stmt.getDataverseName(),
- stmt.getDatasetName());
- List<Integer> keySourceIndicator = ((InternalDatasetDetails) targetDatasource.getDataset()
- .getDatasetDetails()).getKeySourceIndicator();
+ DatasetDataSource targetDatasource =
+ validateDatasetInfo(metadataProvider, stmt.getDataverseName(), stmt.getDatasetName());
+ List<Integer> keySourceIndicator =
+ ((InternalDatasetDetails) targetDatasource.getDataset().getDatasetDetails())
+ .getKeySourceIndicator();
ArrayList<LogicalVariable> vars = new ArrayList<>();
ArrayList<Mutable<ILogicalExpression>> exprs = new ArrayList<>();
List<Mutable<ILogicalExpression>> varRefsForLoading = new ArrayList<>();
@@ -359,8 +360,8 @@
PlanTranslationUtil.prepareVarAndExpression(additionalFilteringField, resVar, additionalFilteringVars,
additionalFilteringAssignExpressions, additionalFilteringExpressions, context);
- additionalFilteringAssign = new AssignOperator(additionalFilteringVars,
- additionalFilteringAssignExpressions);
+ additionalFilteringAssign =
+ new AssignOperator(additionalFilteringVars, additionalFilteringAssignExpressions);
additionalFilteringAssign.getInputs().add(new MutableObject<>(project));
assign.getInputs().add(new MutableObject<>(additionalFilteringAssign));
} else {
@@ -435,8 +436,8 @@
List<LogicalVariable> metaAndKeysVars = null;
List<Mutable<ILogicalExpression>> metaAndKeysExprs = null;
List<Mutable<ILogicalExpression>> metaExpSingletonList = null;
- boolean isChangeFeed = FeedMetadataUtil.isChangeFeed(metadataProvider, sfs.getDataverseName(),
- sfs.getFeedName());
+ boolean isChangeFeed =
+ FeedMetadataUtil.isChangeFeed(metadataProvider, sfs.getDataverseName(), sfs.getFeedName());
if (targetDatasource.getDataset().hasMetaPart() || isChangeFeed) {
metaAndKeysVars = new ArrayList<>();
metaAndKeysExprs = new ArrayList<>();
@@ -458,8 +459,8 @@
varRefsForLoading.clear();
for (Mutable<ILogicalExpression> assignExpr : exprs) {
if (assignExpr.getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
- AbstractFunctionCallExpression funcCall = (AbstractFunctionCallExpression) assignExpr
- .getValue();
+ AbstractFunctionCallExpression funcCall =
+ (AbstractFunctionCallExpression) assignExpr.getValue();
funcCall.substituteVar(resVar, unnestVar);
LogicalVariable pkVar = context.newVar();
metaAndKeysVars.add(pkVar);
@@ -530,8 +531,8 @@
}
AqlSourceId sourceId = new AqlSourceId(dataverseName, datasetName);
IAType itemType = metadataProvider.findType(dataset.getItemTypeDataverseName(), dataset.getItemTypeName());
- IAType metaItemType = metadataProvider.findType(dataset.getMetaItemTypeDataverseName(),
- dataset.getMetaItemTypeName());
+ IAType metaItemType =
+ metadataProvider.findType(dataset.getMetaItemTypeDataverseName(), dataset.getMetaItemTypeName());
INodeDomain domain = metadataProvider.findNodeDomain(dataset.getNodeGroupName());
DatasetDataSource dataSource = new DatasetDataSource(sourceId, dataset, itemType, metaItemType,
AqlDataSourceType.INTERNAL_DATASET, dataset.getDatasetDetails(), domain);
@@ -540,8 +541,8 @@
private FileSplit getDefaultOutputFileLocation() throws MetadataException {
String outputDir = System.getProperty("java.io.tmpDir");
- String filePath = outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX
- + outputFileID.incrementAndGet();
+ String filePath =
+ outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet();
AsterixMetadataProperties metadataProperties = AsterixAppContextInfo.getInstance().getMetadataProperties();
return new FileSplit(metadataProperties.getMetadataNodeName(), new FileReference(new File(filePath)));
}
@@ -562,8 +563,8 @@
}
default: {
v = context.newVar(lc.getVarExpr());
- Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(lc.getBindingExpr(),
- tupSource);
+ Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo =
+ langExprToAlgExpression(lc.getBindingExpr(), tupSource);
returnedOp = new AssignOperator(v, new MutableObject<>(eo.first));
returnedOp.getInputs().add(eo.second);
break;
@@ -580,8 +581,8 @@
AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME));
fldAccess.getArguments().add(new MutableObject<>(p.first));
- ILogicalExpression faExpr = new ConstantExpression(
- new AsterixConstantValue(new AString(fa.getIdent().getValue())));
+ ILogicalExpression faExpr =
+ new ConstantExpression(new AsterixConstantValue(new AString(fa.getIdent().getValue())));
fldAccess.getArguments().add(new MutableObject<>(faExpr));
AssignOperator a = new AssignOperator(v, new MutableObject<>(fldAccess));
a.getInputs().add(p.second);
@@ -599,8 +600,8 @@
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER));
f.getArguments().add(new MutableObject<>(p.first));
} else {
- Pair<ILogicalExpression, Mutable<ILogicalOperator>> indexPair = langExprToAlgExpression(ia.getIndexExpr(),
- tupSource);
+ Pair<ILogicalExpression, Mutable<ILogicalOperator>> indexPair =
+ langExprToAlgExpression(ia.getIndexExpr(), tupSource);
f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.GET_ITEM));
f.getArguments().add(new MutableObject<>(p.first));
f.getArguments().add(new MutableObject<>(indexPair.first));
@@ -710,8 +711,8 @@
if (AsterixBuiltinFunctions.isBuiltinAggregateFunction(fi)) {
f = AsterixBuiltinFunctions.makeAggregateFunctionExpression(fi, args);
} else if (AsterixBuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
- UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(fi),
- args);
+ UnnestingFunctionCallExpression ufce =
+ new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(fi), args);
ufce.setReturnsUniqueValues(AsterixBuiltinFunctions.returnsUniqueValues(fi));
f = ufce;
} else {
@@ -734,8 +735,9 @@
List<Pair<Expression, Identifier>> groupFieldList = gc.getGroupFieldList();
List<Mutable<ILogicalExpression>> groupRecordConstructorArgList = new ArrayList<>();
for (Pair<Expression, Identifier> groupField : groupFieldList) {
- ILogicalExpression groupFieldNameExpr = langExprToAlgExpression(
- new LiteralExpr(new StringLiteral(groupField.second.getValue())), topOp).first;
+ ILogicalExpression groupFieldNameExpr =
+ langExprToAlgExpression(new LiteralExpr(new StringLiteral(groupField.second.getValue())),
+ topOp).first;
groupRecordConstructorArgList.add(new MutableObject<>(groupFieldNameExpr));
ILogicalExpression groupFieldExpr = langExprToAlgExpression(groupField.first, topOp).first;
groupRecordConstructorArgList.add(new MutableObject<>(groupFieldExpr));
@@ -838,9 +840,9 @@
new MutableObject<>(new VariableReferenceExpression(varCond)), ifexpr.getThenExpr());
// Creates a subplan for the "else" branch.
- AbstractFunctionCallExpression notVarCond = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
- Collections.singletonList(new MutableObject<>(new VariableReferenceExpression(varCond))));
+ AbstractFunctionCallExpression notVarCond =
+ new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.NOT),
+ Collections.singletonList(new MutableObject<>(new VariableReferenceExpression(varCond))));
Pair<ILogicalOperator, LogicalVariable> opAndVarForElse = constructSubplanOperatorForBranch(
opAndVarForThen.first, new MutableObject<>(notVarCond), ifexpr.getElseExpr());
@@ -867,8 +869,8 @@
// Produces the final result.
LogicalVariable resultVar = context.newVar();
- AssignOperator finalAssignOp = new AssignOperator(resultVar,
- new MutableObject<>(new VariableReferenceExpression(unnestVar)));
+ AssignOperator finalAssignOp =
+ new AssignOperator(resultVar, new MutableObject<>(new VariableReferenceExpression(unnestVar)));
finalAssignOp.getInputs().add(new MutableObject<>(unnestOp));
return new Pair<>(finalAssignOp, resultVar);
}
@@ -1099,13 +1101,24 @@
Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(expr, tupSource);
LogicalVariable v1 = context.newVar();
AssignOperator a;
- if (u.getSign() == Sign.POSITIVE) {
- a = new AssignOperator(v1, new MutableObject<>(eo.first));
- } else {
- AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NUMERIC_UNARY_MINUS));
- m.getArguments().add(new MutableObject<>(eo.first));
- a = new AssignOperator(v1, new MutableObject<>(m));
+ switch (u.getExprType()) {
+ case POSITIVE:
+ a = new AssignOperator(v1, new MutableObject<>(eo.first));
+ break;
+ case NEGATIVE:
+ AbstractFunctionCallExpression m = new ScalarFunctionCallExpression(
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NUMERIC_UNARY_MINUS));
+ m.getArguments().add(new MutableObject<>(eo.first));
+ a = new AssignOperator(v1, new MutableObject<>(m));
+ break;
+ case EXISTS:
+ a = processExists(eo.first, v1, false);
+ break;
+ case NOT_EXISTS:
+ a = processExists(eo.first, v1, true);
+ break;
+ default:
+ throw new AsterixException("Unsupported operator: " + u);
}
a.getInputs().add(eo.second);
return new Pair<>(a, v1);
@@ -1231,8 +1244,8 @@
Mutable<ILogicalOperator> topOpRef) throws AsterixException {
switch (expr.getKind()) {
case VARIABLE_EXPRESSION: {
- VariableReferenceExpression ve = new VariableReferenceExpression(
- context.getVar(((VariableExpr) expr).getVar().getId()));
+ VariableReferenceExpression ve =
+ new VariableReferenceExpression(context.getVar(((VariableExpr) expr).getVar().getId()));
return new Pair<>(ve, topOpRef);
}
case LITERAL_EXPRESSION: {
@@ -1432,8 +1445,8 @@
if (opRefSet.contains(childRef)) {
// There is a shared operator reference in the query plan.
// Deep copies the child plan.
- LogicalOperatorDeepCopyWithNewVariablesVisitor visitor = new LogicalOperatorDeepCopyWithNewVariablesVisitor(
- context, null);
+ LogicalOperatorDeepCopyWithNewVariablesVisitor visitor =
+ new LogicalOperatorDeepCopyWithNewVariablesVisitor(context, null);
ILogicalOperator newChild = childRef.getValue().accept(visitor, null);
Map<LogicalVariable, LogicalVariable> cloneVarMap = visitor.getInputToOutputVariableMapping();
@@ -1448,8 +1461,8 @@
// Recursively eliminate shared operator reference for the operator subtree,
// even if it is a deep copy of some other one.
- Map<LogicalVariable, LogicalVariable> childVarMap = eliminateSharedOperatorReference(childRef,
- opRefSet);
+ Map<LogicalVariable, LogicalVariable> childVarMap =
+ eliminateSharedOperatorReference(childRef, opRefSet);
// Substitute variables according to the new subtree.
VariableUtilities.substituteVariables(currentOperator, childVarMap, null);
@@ -1492,8 +1505,8 @@
context.enterSubplan();
SubplanOperator subplanOp = new SubplanOperator();
subplanOp.getInputs().add(new MutableObject<>(inputOp));
- Mutable<ILogicalOperator> nestedSource = new MutableObject<>(
- new NestedTupleSourceOperator(new MutableObject<>(subplanOp)));
+ Mutable<ILogicalOperator> nestedSource =
+ new MutableObject<>(new NestedTupleSourceOperator(new MutableObject<>(subplanOp)));
SelectOperator select = new SelectOperator(selectExpr, false, null);
// The select operator cannot be moved up and down, otherwise it will cause typing issues (ASTERIXDB-1203).
OperatorPropertiesUtil.markMovable(select, false);
@@ -1510,4 +1523,17 @@
context.exitSubplan();
return new Pair<>(subplanOp, branchVar);
}
+
+ // Processes EXISTS and NOT EXISTS.
+ private AssignOperator processExists(ILogicalExpression inputExpr, LogicalVariable v1, boolean not) {
+ AbstractFunctionCallExpression count =
+ new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.SCALAR_COUNT));
+ count.getArguments().add(new MutableObject<>(inputExpr));
+ AbstractFunctionCallExpression comparison = new ScalarFunctionCallExpression(
+ FunctionUtil.getFunctionInfo(not ? AsterixBuiltinFunctions.EQ : AsterixBuiltinFunctions.NEQ));
+ comparison.getArguments().add(new MutableObject<>(count));
+ comparison.getArguments()
+ .add(new MutableObject<>(new ConstantExpression(new AsterixConstantValue(new AInt64(0L)))));
+ return new AssignOperator(v1, new MutableObject<>(comparison));
+ }
}
diff --git a/asterixdb/asterix-algebra/src/main/javacc/AQLPlus.jj b/asterixdb/asterix-algebra/src/main/javacc/AQLPlus.jj
index c2ed8e1..0e1e7a1 100644
--- a/asterixdb/asterix-algebra/src/main/javacc/AQLPlus.jj
+++ b/asterixdb/asterix-algebra/src/main/javacc/AQLPlus.jj
@@ -79,7 +79,6 @@
import org.apache.asterix.lang.common.expression.TypeExpression;
import org.apache.asterix.lang.common.expression.TypeReferenceExpression;
import org.apache.asterix.lang.common.expression.UnaryExpr;
-import org.apache.asterix.lang.common.expression.UnaryExpr.Sign;
import org.apache.asterix.lang.common.expression.UnorderedListTypeDefinition;
import org.apache.asterix.lang.common.expression.VariableExpr;
import org.apache.asterix.lang.common.literal.DoubleLiteral;
@@ -542,7 +541,11 @@
op.setCurrentop(true);
}
Token t = getToken(0);
- op.addOperator(t.toString());
+ try{
+ op.addOperator(t.toString());
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = AndExpr()
@@ -574,7 +577,11 @@
op.setCurrentop(true);
}
Token t = getToken(0);
- op.addOperator(t.toString());
+ try{
+ op.addOperator(t.toString());
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = RelExpr()
@@ -618,7 +625,11 @@
broadcast = false;
}
Token t = getToken(0);
- op.addOperator(t.toString());
+ try{
+ op.addOperator(t.toString());
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = AddExpr()
@@ -655,7 +666,11 @@
op.setCurrentop(true);
}
Token t = getToken(0);
- ((OperatorExpr)op).addOperator(t.toString());
+ try{
+ ((OperatorExpr)op).addOperator(t.toString());
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = MultExpr()
@@ -685,7 +700,11 @@
op.setCurrentop(true);
}
Token t = getToken(0);
- op.addOperator(t.toString());
+ try{
+ op.addOperator(t.toString());
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = UnionExpr()
{
@@ -721,20 +740,18 @@
Expression UnaryExpr() throws ParseException:
{
- Expression uexpr = null;
+ UnaryExpr uexpr = null;
Expression expr = null;
}
{
- (( "+"|"-")
+ ( ("+"|"-")
{
uexpr = new UnaryExpr();
- Token t = getToken(0);
- if("+".equals(t.toString()))
- ((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
- else if("-".equals(t.toString()))
- ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
- else
- throw new ParseException();
+ try{
+ uexpr.setExprType(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
)?
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/subquery/exists.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/subquery/exists.sqlpp
new file mode 100644
index 0000000..d045b75
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/subquery/exists.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+CREATE EXTERNAL TABLE Customer(CustomerType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+CREATE EXTERNAL TABLE Orders(OrderType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+WITH q22_customer_tmp AS
+(
+ SELECT c_acctbal, c_custkey, substring(c_phone,1,2) AS cntrycode
+ FROM Customer
+)
+,
+avg AS (
+ SELECT ELEMENT AVG(c_acctbal)
+ FROM Customer
+ WHERE c_acctbal > 0.0
+)[0]
+SELECT cntrycode, count(ct) AS numcust, SUM(c_acctbal) AS totacctbal
+FROM q22_customer_tmp AS ct
+WHERE c_acctbal > avg
+ AND EXISTS (SELECT * FROM Orders o WHERE o.o_custkey = ct.c_custkey)
+GROUP BY cntrycode
+ORDER BY cntrycode
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/subquery/not_exists.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/subquery/not_exists.sqlpp
new file mode 100644
index 0000000..6c189e2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/subquery/not_exists.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+CREATE EXTERNAL TABLE Customer(CustomerType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+CREATE EXTERNAL TABLE Orders(OrderType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+WITH q22_customer_tmp AS
+(
+ SELECT c_acctbal, c_custkey, substring(c_phone,1,2) AS cntrycode
+ FROM Customer
+)
+,
+avg AS (
+ SELECT ELEMENT AVG(c_acctbal)
+ FROM Customer
+ WHERE c_acctbal > 0.0
+)[0]
+SELECT cntrycode, count(ct) AS numcust, SUM(c_acctbal) AS totacctbal
+FROM q22_customer_tmp AS ct
+WHERE c_acctbal > avg
+ AND NOT EXISTS (SELECT * FROM Orders o WHERE o.o_custkey = ct.c_custkey)
+GROUP BY cntrycode
+ORDER BY cntrycode
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/subquery/exists.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/subquery/exists.plan
new file mode 100644
index 0000000..cd0a17e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/subquery/exists.plan
@@ -0,0 +1,74 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- SORT_MERGE_EXCHANGE [$$8(ASC) ] |PARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$82] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$82(ASC)] HASH:[$$82] |PARTITIONED|
+ -- SORT_GROUP_BY[$$59] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$79] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$79(ASC)] HASH:[$$79] |PARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$72] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- STREAM_SELECT |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STABLE_SORT [$$72(ASC)] |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- HYBRID_HASH_JOIN [$$67][$$64] |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$67] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- NESTED_LOOP |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |UNPARTITIONED|
+ -- ASSIGN |UNPARTITIONED|
+ -- AGGREGATE |UNPARTITIONED|
+ -- AGGREGATE |UNPARTITIONED|
+ -- RANDOM_MERGE_EXCHANGE |PARTITIONED|
+ -- AGGREGATE |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$64] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/subquery/not_exists.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/subquery/not_exists.plan
new file mode 100644
index 0000000..2a9841f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/subquery/not_exists.plan
@@ -0,0 +1,74 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- SORT_MERGE_EXCHANGE [$$8(ASC) ] |PARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$83] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$83(ASC)] HASH:[$$83] |PARTITIONED|
+ -- SORT_GROUP_BY[$$60] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$80] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- HASH_PARTITION_MERGE_EXCHANGE MERGE:[$$80(ASC)] HASH:[$$80] |PARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$73] |PARTITIONED|
+ {
+ -- AGGREGATE |LOCAL|
+ -- STREAM_SELECT |LOCAL|
+ -- NESTED_TUPLE_SOURCE |LOCAL|
+ }
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STABLE_SORT [$$73(ASC)] |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- HYBRID_HASH_JOIN [$$68][$$65] |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$68] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- NESTED_LOOP |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |UNPARTITIONED|
+ -- ASSIGN |UNPARTITIONED|
+ -- AGGREGATE |UNPARTITIONED|
+ -- AGGREGATE |UNPARTITIONED|
+ -- RANDOM_MERGE_EXCHANGE |PARTITIONED|
+ -- AGGREGATE |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$65] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast
index 78a13aa..c99d0cc 100644
--- a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast
+++ b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast
@@ -1,6 +1,6 @@
Query:
OperatorExpr [
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
+
LiteralExpr [LONG] [1]
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/exists/exists.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/exists/exists.3.query.sqlpp
new file mode 100644
index 0000000..edfd180
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/exists/exists.3.query.sqlpp
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+SELECT [EXISTS [1], NOT EXISTS [], EXISTS [], NOT EXISTS [1]];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.1.ddl.sqlpp
new file mode 100644
index 0000000..0d6dc7d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+
+CREATE EXTERNAL TABLE Customer(CustomerType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+CREATE EXTERNAL TABLE Orders(OrderType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.2.update.sqlpp
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.2.update.sqlpp
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.3.query.sqlpp
new file mode 100644
index 0000000..8f89da4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/exists/exists.3.query.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+USE test;
+
+WITH q22_customer_tmp AS
+(
+ SELECT c_acctbal, c_custkey, substring(c_phone,1,2) AS cntrycode
+ FROM Customer
+)
+,
+avg AS (
+ SELECT ELEMENT AVG(c_acctbal)
+ FROM Customer
+ WHERE c_acctbal > 0.0
+)[0]
+SELECT cntrycode, count(ct) AS numcust, SUM(c_acctbal) AS totacctbal
+FROM q22_customer_tmp AS ct
+WHERE c_acctbal > avg
+ AND EXISTS (SELECT * FROM Orders o WHERE o.o_custkey = ct.c_custkey)
+GROUP BY cntrycode
+ORDER BY cntrycode
+;
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.1.ddl.sqlpp
new file mode 100644
index 0000000..0d6dc7d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+
+CREATE EXTERNAL TABLE Customer(CustomerType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+CREATE EXTERNAL TABLE Orders(OrderType) USING `localfs`
+((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),
+(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.2.update.sqlpp
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.2.update.sqlpp
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.3.query.sqlpp
new file mode 100644
index 0000000..c47aad3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/not_exists/not_exists.3.query.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+USE test;
+
+WITH q22_customer_tmp AS
+(
+ SELECT c_acctbal, c_custkey, substring(c_phone,1,2) AS cntrycode
+ FROM Customer
+)
+,
+avg AS (
+ SELECT ELEMENT AVG(c_acctbal)
+ FROM Customer
+ WHERE c_acctbal > 0.0
+)[0]
+SELECT cntrycode, count(ct) AS numcust, SUM(c_acctbal) AS totacctbal
+FROM q22_customer_tmp AS ct
+WHERE c_acctbal > avg
+ AND NOT EXISTS (SELECT * FROM Orders o WHERE o.o_custkey = ct.c_custkey)
+GROUP BY cntrycode
+ORDER BY cntrycode
+;
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.1.ddl.sqlpp
new file mode 100644
index 0000000..78d754a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+
+CREATE TABLE Customer(CustomerType) PRIMARY KEY c_custkey;
+
+CREATE TABLE Orders(OrderType) PRIMARY KEY o_orderkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.2.update.sqlpp
new file mode 100644
index 0000000..e09d9e5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.2.update.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.
+ */
+USE test;
+
+load table Orders using localfs ((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load table Customer using localfs ((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.3.query.sqlpp
new file mode 100644
index 0000000..e0307ac
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division/relational_division.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+USE test;
+
+SELECT DISTINCT c.c_custkey
+FROM Customer c
+WHERE NOT EXISTS (
+ SELECT *
+ FROM Orders o1
+ WHERE NOT EXISTS (
+ SELECT *
+ FROM Orders o2
+ WHERE c.c_custkey=o2.o_custkey AND o1.o_orderpriority=o2.o_orderpriority
+ )
+ )
+ORDER BY c.c_custkey
+;
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.1.ddl.sqlpp
new file mode 100644
index 0000000..78d754a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+
+CREATE TABLE Customer(CustomerType) PRIMARY KEY c_custkey;
+
+CREATE TABLE Orders(OrderType) PRIMARY KEY o_orderkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.2.update.sqlpp
new file mode 100644
index 0000000..e09d9e5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.2.update.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.
+ */
+USE test;
+
+load table Orders using localfs ((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load table Customer using localfs ((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.3.query.sqlpp
new file mode 100644
index 0000000..45f924a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division2/relational_division2.3.query.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+USE test;
+
+/** Finds customers whose orders have all possible priorities.*/
+
+WITH priorities AS
+COLL_COUNT((
+ SELECT DISTINCT o.o_orderpriority FROM Orders o
+))
+,
+cust_priorities AS (
+ SELECT co.c_custkey, COUNT(1) AS priority_count
+ FROM (
+ SELECT DISTINCT c.c_custkey, o.o_orderpriority
+ FROM Customer c LEFT JOIN Orders o ON c.c_custkey=o.o_custkey
+ ) co
+ GROUP BY co.c_custkey
+)
+
+SELECT c_custkey
+FROM cust_priorities
+WHERE priority_count = priorities
+ORDER BY c_custkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.1.ddl.sqlpp
new file mode 100644
index 0000000..78d754a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+DROP DATABASE test IF EXISTS;
+CREATE DATABASE test;
+USE test;
+
+
+CREATE TYPE OrderType AS CLOSED {
+ o_orderkey: int32,
+ o_custkey: int32,
+ o_orderstatus: string,
+ o_totalprice: double,
+ o_orderdate: string,
+ o_orderpriority: string,
+ o_clerk: string,
+ o_shippriority: int32,
+ o_comment: string
+}
+
+CREATE TYPE CustomerType AS CLOSED {
+ c_custkey: int32,
+ c_name: string,
+ c_address: string,
+ c_nationkey: int32,
+ c_phone: string,
+ c_acctbal: double,
+ c_mktsegment: string,
+ c_comment: string
+}
+
+
+CREATE TABLE Customer(CustomerType) PRIMARY KEY c_custkey;
+
+CREATE TABLE Orders(OrderType) PRIMARY KEY o_orderkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.2.update.sqlpp
new file mode 100644
index 0000000..e09d9e5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.2.update.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.
+ */
+USE test;
+
+load table Orders using localfs ((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load table Customer using localfs ((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.3.query.sqlpp
new file mode 100644
index 0000000..e75d365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/relational_division3/relational_division3.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+USE test;
+
+/** Finds customers whose orders have all possible priorities.*/
+
+
+
+SELECT c.c_custkey
+FROM Customer c
+WHERE NOT EXISTS (
+ SELECT *
+ FROM Orders o1
+ WHERE o1.o_orderpriority NOT IN (
+ SELECT VALUE o2.o_orderpriority
+ FROM Orders o2
+ WHERE c.c_custkey=o2.o_custkey
+ )
+ )
+ORDER BY c.c_custkey
+;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/list/exists/exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/list/exists/exists.1.adm
new file mode 100644
index 0000000..313ae8a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/list/exists/exists.1.adm
@@ -0,0 +1 @@
+{ "$1": [ true, true, false, false ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/exists/exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/exists/exists.1.adm
new file mode 100644
index 0000000..b815ac2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/exists/exists.1.adm
@@ -0,0 +1,21 @@
+{ "cntrycode": "10", "numcust": 3, "totacctbal": 20747.13 }
+{ "cntrycode": "11", "numcust": 1, "totacctbal": 5266.3 }
+{ "cntrycode": "12", "numcust": 1, "totacctbal": 7470.96 }
+{ "cntrycode": "13", "numcust": 1, "totacctbal": 7865.46 }
+{ "cntrycode": "14", "numcust": 1, "totacctbal": 9963.15 }
+{ "cntrycode": "16", "numcust": 1, "totacctbal": 5744.59 }
+{ "cntrycode": "18", "numcust": 1, "totacctbal": 7508.92 }
+{ "cntrycode": "19", "numcust": 4, "totacctbal": 26638.06 }
+{ "cntrycode": "20", "numcust": 2, "totacctbal": 13993.849999999999 }
+{ "cntrycode": "21", "numcust": 2, "totacctbal": 14225.810000000001 }
+{ "cntrycode": "22", "numcust": 3, "totacctbal": 20332.18 }
+{ "cntrycode": "23", "numcust": 2, "totacctbal": 16227.39 }
+{ "cntrycode": "25", "numcust": 3, "totacctbal": 19038.36 }
+{ "cntrycode": "26", "numcust": 4, "totacctbal": 31589.67 }
+{ "cntrycode": "27", "numcust": 2, "totacctbal": 13248.06 }
+{ "cntrycode": "28", "numcust": 3, "totacctbal": 27945.0 }
+{ "cntrycode": "29", "numcust": 2, "totacctbal": 18863.93 }
+{ "cntrycode": "30", "numcust": 1, "totacctbal": 9889.89 }
+{ "cntrycode": "31", "numcust": 1, "totacctbal": 9280.71 }
+{ "cntrycode": "32", "numcust": 3, "totacctbal": 19248.96 }
+{ "cntrycode": "33", "numcust": 2, "totacctbal": 14032.05 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/not_exists/not_exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/not_exists/not_exists.1.adm
new file mode 100644
index 0000000..fbd6260
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/not_exists/not_exists.1.adm
@@ -0,0 +1,18 @@
+{ "cntrycode": "11", "numcust": 4, "totacctbal": 29942.58 }
+{ "cntrycode": "12", "numcust": 1, "totacctbal": 6264.31 }
+{ "cntrycode": "13", "numcust": 1, "totacctbal": 5679.84 }
+{ "cntrycode": "15", "numcust": 2, "totacctbal": 14624.84 }
+{ "cntrycode": "16", "numcust": 1, "totacctbal": 5494.43 }
+{ "cntrycode": "17", "numcust": 1, "totacctbal": 9127.27 }
+{ "cntrycode": "18", "numcust": 2, "totacctbal": 14647.99 }
+{ "cntrycode": "19", "numcust": 2, "totacctbal": 17120.35 }
+{ "cntrycode": "20", "numcust": 1, "totacctbal": 9091.82 }
+{ "cntrycode": "21", "numcust": 1, "totacctbal": 5174.71 }
+{ "cntrycode": "23", "numcust": 1, "totacctbal": 9255.67 }
+{ "cntrycode": "26", "numcust": 1, "totacctbal": 7354.23 }
+{ "cntrycode": "28", "numcust": 2, "totacctbal": 14755.5 }
+{ "cntrycode": "29", "numcust": 2, "totacctbal": 17195.08 }
+{ "cntrycode": "30", "numcust": 1, "totacctbal": 7638.57 }
+{ "cntrycode": "31", "numcust": 2, "totacctbal": 14318.4 }
+{ "cntrycode": "32", "numcust": 1, "totacctbal": 6505.26 }
+{ "cntrycode": "33", "numcust": 1, "totacctbal": 6327.54 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/relational_division/relational_division.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/relational_division/relational_division.1.adm
new file mode 100644
index 0000000..af8e48b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/relational_division/relational_division.1.adm
@@ -0,0 +1,74 @@
+{ "c_custkey": 4 }
+{ "c_custkey": 7 }
+{ "c_custkey": 8 }
+{ "c_custkey": 10 }
+{ "c_custkey": 13 }
+{ "c_custkey": 16 }
+{ "c_custkey": 17 }
+{ "c_custkey": 19 }
+{ "c_custkey": 22 }
+{ "c_custkey": 23 }
+{ "c_custkey": 25 }
+{ "c_custkey": 28 }
+{ "c_custkey": 29 }
+{ "c_custkey": 31 }
+{ "c_custkey": 32 }
+{ "c_custkey": 34 }
+{ "c_custkey": 37 }
+{ "c_custkey": 40 }
+{ "c_custkey": 43 }
+{ "c_custkey": 44 }
+{ "c_custkey": 46 }
+{ "c_custkey": 47 }
+{ "c_custkey": 49 }
+{ "c_custkey": 52 }
+{ "c_custkey": 53 }
+{ "c_custkey": 55 }
+{ "c_custkey": 56 }
+{ "c_custkey": 58 }
+{ "c_custkey": 61 }
+{ "c_custkey": 64 }
+{ "c_custkey": 65 }
+{ "c_custkey": 67 }
+{ "c_custkey": 70 }
+{ "c_custkey": 73 }
+{ "c_custkey": 74 }
+{ "c_custkey": 76 }
+{ "c_custkey": 79 }
+{ "c_custkey": 80 }
+{ "c_custkey": 82 }
+{ "c_custkey": 85 }
+{ "c_custkey": 88 }
+{ "c_custkey": 89 }
+{ "c_custkey": 91 }
+{ "c_custkey": 94 }
+{ "c_custkey": 95 }
+{ "c_custkey": 97 }
+{ "c_custkey": 98 }
+{ "c_custkey": 100 }
+{ "c_custkey": 101 }
+{ "c_custkey": 103 }
+{ "c_custkey": 104 }
+{ "c_custkey": 106 }
+{ "c_custkey": 109 }
+{ "c_custkey": 112 }
+{ "c_custkey": 115 }
+{ "c_custkey": 118 }
+{ "c_custkey": 119 }
+{ "c_custkey": 121 }
+{ "c_custkey": 122 }
+{ "c_custkey": 124 }
+{ "c_custkey": 125 }
+{ "c_custkey": 127 }
+{ "c_custkey": 130 }
+{ "c_custkey": 131 }
+{ "c_custkey": 133 }
+{ "c_custkey": 134 }
+{ "c_custkey": 136 }
+{ "c_custkey": 137 }
+{ "c_custkey": 139 }
+{ "c_custkey": 140 }
+{ "c_custkey": 142 }
+{ "c_custkey": 145 }
+{ "c_custkey": 148 }
+{ "c_custkey": 149 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast
index 79aa35a..6ec8199 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast
@@ -30,7 +30,7 @@
FunctionCall test.hex@1[
LiteralExpr [STRING] []
]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
]
=
FunctionCall test.hex@1[
@@ -135,7 +135,7 @@
FunctionCall test.hex@1[
LiteralExpr [STRING] [aabbccdd]
]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
]
=
FunctionCall test.hex@1[
@@ -174,7 +174,7 @@
LiteralExpr [STRING] [aabbccdd]
]
LiteralExpr [LONG] [2]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
]
=
FunctionCall test.hex@1[
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast
index 351b4ef..3109b22 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast
@@ -100,7 +100,7 @@
(
LiteralExpr [STRING] [-cashBack]
:
- NEGATIVE FieldAccessor [
+ - FieldAccessor [
Variable [ Name=$c ]
Field=cashBack
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast
index 460fdd3..f2f701b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast
@@ -92,7 +92,7 @@
(
LiteralExpr [STRING] [-age]
:
- NEGATIVE FieldAccessor [
+ - FieldAccessor [
Variable [ Name=$c ]
Field=age
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast
index 7b18d20..effbbb3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast
@@ -31,8 +31,8 @@
LiteralExpr [LONG] [30]
]
OrderedListConstructor [
- NEGATIVE LiteralExpr [LONG] [2]
- NEGATIVE LiteralExpr [LONG] [5]
+ - LiteralExpr [LONG] [2]
+ - LiteralExpr [LONG] [5]
LiteralExpr [LONG] [0]
]
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast
index a27798a..26f4e05 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast
@@ -14,7 +14,7 @@
LiteralExpr [STRING] [f1]
:
FunctionCall test.abs@1[
- NEGATIVE LiteralExpr [DOUBLE] [1.11]
+ - LiteralExpr [DOUBLE] [1.11]
]
)
(
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast
index 7cceff0..4550cfe 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast
@@ -101,7 +101,7 @@
OrderedListConstructor [
LiteralExpr [DOUBLE] [1.0]
]
- Index: NEGATIVE LiteralExpr [LONG] [1]
+ Index: - LiteralExpr [LONG] [1]
]
]
)
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast
index 8f0324f..1179f48 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast
@@ -14,7 +14,7 @@
LiteralExpr [STRING] [f1]
:
FunctionCall test.ceiling@1[
- NEGATIVE LiteralExpr [DOUBLE] [1.11]
+ - LiteralExpr [DOUBLE] [1.11]
]
)
(
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast
index 25b47d0..1bb6af7 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast
@@ -14,7 +14,7 @@
LiteralExpr [STRING] [f1]
:
FunctionCall test.floor@1[
- NEGATIVE LiteralExpr [DOUBLE] [1.11]
+ - LiteralExpr [DOUBLE] [1.11]
]
)
(
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast
index c2d41d9..80b6d09 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast
@@ -48,7 +48,7 @@
FunctionCall test.double@1[
LiteralExpr [STRING] [35612.25]
]
- NEGATIVE LiteralExpr [LONG] [2]
+ - LiteralExpr [LONG] [2]
]
)
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast
index ade34b5..e2e0f27 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast
@@ -14,7 +14,7 @@
LiteralExpr [STRING] [f1]
:
FunctionCall test.round-half-to-even@1[
- NEGATIVE LiteralExpr [DOUBLE] [1.5]
+ - LiteralExpr [DOUBLE] [1.5]
]
)
(
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast
index e372fa9..e446715 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast
@@ -14,7 +14,7 @@
LiteralExpr [STRING] [f1]
:
FunctionCall test.round@1[
- NEGATIVE LiteralExpr [DOUBLE] [1.11]
+ - LiteralExpr [DOUBLE] [1.11]
]
)
(
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast
index 58c8e8b..c74b17a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast
@@ -4,28 +4,28 @@
(
LiteralExpr [STRING] [double1]
:
- NEGATIVE FunctionCall test.double@1[
+ - FunctionCall test.double@1[
LiteralExpr [STRING] [-20.56e-30]
]
)
(
LiteralExpr [STRING] [double2]
:
- NEGATIVE FunctionCall test.double@1[
+ - FunctionCall test.double@1[
LiteralExpr [STRING] [NaN]
]
)
(
LiteralExpr [STRING] [double3]
:
- NEGATIVE FunctionCall test.double@1[
+ - FunctionCall test.double@1[
LiteralExpr [STRING] [INF]
]
)
(
LiteralExpr [STRING] [double4]
:
- NEGATIVE FunctionCall test.double@1[
+ - FunctionCall test.double@1[
LiteralExpr [STRING] [-INF]
]
)
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast
index 27fd67f..cd38a0c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast
@@ -4,28 +4,28 @@
(
LiteralExpr [STRING] [float1]
:
- NEGATIVE FunctionCall test.float@1[
+ - FunctionCall test.float@1[
LiteralExpr [STRING] [-80.20f]
]
)
(
LiteralExpr [STRING] [float2]
:
- NEGATIVE FunctionCall test.float@1[
+ - FunctionCall test.float@1[
LiteralExpr [STRING] [NaN]
]
)
(
LiteralExpr [STRING] [float3]
:
- NEGATIVE FunctionCall test.float@1[
+ - FunctionCall test.float@1[
LiteralExpr [STRING] [INF]
]
)
(
LiteralExpr [STRING] [float4]
:
- NEGATIVE FunctionCall test.float@1[
+ - FunctionCall test.float@1[
LiteralExpr [STRING] [-INF]
]
)
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast
index 682a20d..b37a097 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast
@@ -4,28 +4,28 @@
(
LiteralExpr [STRING] [int8]
:
- NEGATIVE FunctionCall test.int8@1[
+ - FunctionCall test.int8@1[
LiteralExpr [STRING] [+80]
]
)
(
LiteralExpr [STRING] [int16]
:
- NEGATIVE FunctionCall test.int16@1[
+ - FunctionCall test.int16@1[
LiteralExpr [STRING] [160]
]
)
(
LiteralExpr [STRING] [int32]
:
- NEGATIVE FunctionCall test.int32@1[
+ - FunctionCall test.int32@1[
LiteralExpr [STRING] [+320]
]
)
(
LiteralExpr [STRING] [int64]
:
- NEGATIVE FunctionCall test.int64@1[
+ - FunctionCall test.int64@1[
LiteralExpr [STRING] [-640]
]
)
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
index c272a7e..f1b45ae 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
@@ -3,11 +3,11 @@
(
LiteralExpr [STRING] [nullField]
:
- NEGATIVE LiteralExpr [NULL]
+ - LiteralExpr [NULL]
)
(
LiteralExpr [STRING] [missingField]
:
- NEGATIVE LiteralExpr [MISSING]
+ - LiteralExpr [MISSING]
)
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast
index f996b27..353cad6 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast
@@ -18,7 +18,7 @@
LiteralExpr [LONG] [44]
LiteralExpr [LONG] [22]
LiteralExpr [LONG] [66]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
LiteralExpr [LONG] [0]
LiteralExpr [DOUBLE] [99.9]
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast
index 72b2823..c099316 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast
@@ -21,7 +21,7 @@
(
LiteralExpr [STRING] [f]
:
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
)
]
RecordConstructor [
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast
index d65a7a2..ab48d43 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast
@@ -13,8 +13,8 @@
LiteralExpr [LONG] [2]
]
OrderedListConstructor [
- NEGATIVE LiteralExpr [LONG] [1]
- NEGATIVE LiteralExpr [LONG] [3]
+ - LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [3]
LiteralExpr [LONG] [0]
]
OrderedListConstructor [
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast
index 16141da..d734065 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast
@@ -5,7 +5,7 @@
]
FROM [ OrderedListConstructor [
LiteralExpr [LONG] [10]
- NEGATIVE LiteralExpr [LONG] [30]
+ - LiteralExpr [LONG] [30]
]
AS Variable [ Name=$x ]
]
@@ -14,8 +14,8 @@
[Variable [ Name=$y ]
In
OrderedListConstructor [
- NEGATIVE LiteralExpr [LONG] [20]
- NEGATIVE LiteralExpr [LONG] [10]
+ - LiteralExpr [LONG] [20]
+ - LiteralExpr [LONG] [10]
]
]
Satifies [
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast
index 2584e26..fce8f80 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast
@@ -5,8 +5,8 @@
]
FROM [ OrderedListConstructor [
LiteralExpr [LONG] [10]
- NEGATIVE LiteralExpr [LONG] [30]
- NEGATIVE LiteralExpr [LONG] [21]
+ - LiteralExpr [LONG] [30]
+ - LiteralExpr [LONG] [21]
LiteralExpr [LONG] [50]
]
AS Variable [ Name=$x ]
@@ -16,8 +16,8 @@
[Variable [ Name=$y ]
In
OrderedListConstructor [
- NEGATIVE LiteralExpr [LONG] [20]
- NEGATIVE LiteralExpr [LONG] [40]
+ - LiteralExpr [LONG] [20]
+ - LiteralExpr [LONG] [40]
]
]
Satifies [
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast
index 238633c..657dce3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast
@@ -81,7 +81,7 @@
]
FunctionCall test.create-point@2[
LiteralExpr [DOUBLE] [24.5]
- NEGATIVE LiteralExpr [DOUBLE] [125.5]
+ - LiteralExpr [DOUBLE] [125.5]
]
LiteralExpr [DOUBLE] [3.0]
LiteralExpr [DOUBLE] [3.0]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast
index b9c5f4f..44be116 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast
@@ -8,8 +8,8 @@
LiteralExpr [DOUBLE] [999.4]
]
FunctionCall test.create-point@2[
- NEGATIVE LiteralExpr [DOUBLE] [872.0]
- NEGATIVE LiteralExpr [DOUBLE] [876.9]
+ - LiteralExpr [DOUBLE] [872.0]
+ - LiteralExpr [DOUBLE] [876.9]
]
]
Let Variable [ Name=$line_list ]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast
index d71d157..cb1d05b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast
@@ -29,7 +29,7 @@
LiteralExpr [DOUBLE] [9.0]
]
FunctionCall test.create-point@2[
- NEGATIVE LiteralExpr [DOUBLE] [1.0]
+ - LiteralExpr [DOUBLE] [1.0]
LiteralExpr [DOUBLE] [5.0]
]
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast
index c2b1ad2..9e8f66d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast
@@ -37,7 +37,7 @@
:
FunctionCall null.substring@2[
LiteralExpr [STRING] [This is a test string]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
]
)
(
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast
index 95d87e4..414ad6e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast
@@ -6,7 +6,7 @@
:
FunctionCall test.substring@2[
LiteralExpr [STRING] [HEllow]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
]
)
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast
index 15eb8e3..4ace9af 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast
@@ -1,7 +1,7 @@
Query:
SELECT ELEMENT [
FunctionCall test.computeBonus@2[
- NEGATIVE LiteralExpr [LONG] [1]
- NEGATIVE LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
+ - LiteralExpr [LONG] [1]
]
]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index f66e3a8..e3d3102 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -2758,6 +2758,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="list">
+ <compilation-unit name="exists">
+ <output-dir compare="Text">exists</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="list">
<compilation-unit name="get-item_01">
<output-dir compare="Text">get-item_01</output-dir>
</compilation-unit>
@@ -5302,6 +5307,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="subquery">
+ <compilation-unit name="exists">
+ <output-dir compare="Text">exists</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="subquery">
<compilation-unit name="in">
<output-dir compare="Text">in</output-dir>
</compilation-unit>
@@ -5312,6 +5322,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="subquery">
+ <compilation-unit name="not_exists">
+ <output-dir compare="Text">not_exists</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="subquery">
<compilation-unit name="not_in">
<output-dir compare="Text">not_in</output-dir>
</compilation-unit>
@@ -5320,6 +5335,21 @@
<compilation-unit name="alias_negative">
<output-dir compare="Text">alias_negative</output-dir>
<expected-error>Need an alias for the enclosed expression</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="subquery">
+ <compilation-unit name="relational_division">
+ <output-dir compare="Text">relational_division</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="subquery">
+ <compilation-unit name="relational_division2">
+ <output-dir compare="Text">relational_division</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="subquery">
+ <compilation-unit name="relational_division3">
+ <output-dir compare="Text">relational_division</output-dir>
</compilation-unit>
</test-case>
</test-group>
diff --git a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
index ba837b5..2af2816 100644
--- a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
+++ b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/visitor/AQLToSQLPPPrintVisitor.java
@@ -119,8 +119,8 @@
String generated = generateVariableSymbol();
if (unnestClauseList.size() > 0) {
- Map<VariableExpr, Expression> varExprMap = extractDefinedCollectionVariables(clauseList, cuttingGbyClause,
- generated);
+ Map<VariableExpr, Expression> varExprMap =
+ extractDefinedCollectionVariables(clauseList, cuttingGbyClause, generated);
returnExpr = (Expression) AQLVariableSubstitutionUtil.substituteVariable(returnExpr, varExprMap);
List<Clause> newUnnestClauses = new ArrayList<Clause>();
@@ -560,7 +560,7 @@
}
// Merge consecutive "where" clauses.
- private void mergeConsecutiveWhereClauses(List<Clause> clauses) {
+ private void mergeConsecutiveWhereClauses(List<Clause> clauses) throws AsterixException {
List<Clause> results = new ArrayList<Clause>();
int size = clauses.size();
for (int index = 0; index < size;) {
diff --git a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
index fcb6eb4..586464c 100644
--- a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
+++ b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
@@ -83,7 +83,6 @@
import org.apache.asterix.lang.common.expression.UnaryExpr;
import org.apache.asterix.lang.common.expression.UnorderedListTypeDefinition;
import org.apache.asterix.lang.common.expression.VariableExpr;
-import org.apache.asterix.lang.common.expression.UnaryExpr.Sign;
import org.apache.asterix.lang.common.literal.DoubleLiteral;
import org.apache.asterix.lang.common.literal.FalseLiteral;
import org.apache.asterix.lang.common.literal.FloatLiteral;
@@ -1582,7 +1581,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- op.addOperator(token.image);
+ try{
+ op.addOperator(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = AndExpr()
@@ -1613,7 +1616,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- op.addOperator(token.image);
+ try{
+ op.addOperator(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = RelExpr()
@@ -1665,7 +1672,11 @@
op.setCurrentop(true);
broadcast = false;
}
- op.addOperator(token.image);
+ try{
+ op.addOperator(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = AddExpr()
@@ -1704,7 +1715,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- ((OperatorExpr)op).addOperator(token.image);
+ try{
+ ((OperatorExpr)op).addOperator(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = MultExpr()
@@ -1733,7 +1748,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- op.addOperator(token.image);
+ try{
+ op.addOperator(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = UnionExpr()
{
@@ -1769,19 +1788,18 @@
Expression UnaryExpr() throws ParseException:
{
- Expression uexpr = null;
+ UnaryExpr uexpr = null;
Expression expr = null;
}
{
( (<PLUS> | <MINUS>)
{
uexpr = new UnaryExpr();
- if("+".equals(token.image))
- ((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
- else if("-".equals(token.image))
- ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
- else
- throw new ParseException();
+ try{
+ uexpr.setExprType(token.image);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
)?
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
index fb64ad8..1418be7 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/OperatorExpr.java
@@ -91,12 +91,12 @@
return cmp;
}
- public void addOperator(String strOp) {
+ public void addOperator(String strOp) throws AsterixException {
Optional<OperatorType> op = OperatorType.fromSymbol(strOp);
if (op.isPresent()) {
opList.add(op.get());
} else {
- throw new UnsupportedOperationException("Unsupported operator: " + strOp);
+ throw new AsterixException("Unsupported operator: " + strOp);
}
}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/UnaryExpr.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/UnaryExpr.java
index eef8f1c..929587c 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/UnaryExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/UnaryExpr.java
@@ -18,30 +18,38 @@
*/
package org.apache.asterix.lang.common.expression;
+import java.util.Optional;
+
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.lang.common.base.Expression;
+import org.apache.asterix.lang.common.struct.UnaryExprType;
import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
import org.apache.commons.lang3.ObjectUtils;
public class UnaryExpr implements Expression {
- private Sign sign;
+ private UnaryExprType unaryExprType;
private Expression expr;
public UnaryExpr() {
// default constructor
}
- public UnaryExpr(Sign sign, Expression expr) {
- this.sign = sign;
+ public UnaryExpr(UnaryExprType type, Expression expr) {
+ this.unaryExprType = type;
this.expr = expr;
}
- public Sign getSign() {
- return sign;
+ public UnaryExprType getExprType() {
+ return unaryExprType;
}
- public void setSign(Sign sign) {
- this.sign = sign;
+ public void setExprType(String strType) throws AsterixException {
+ Optional<UnaryExprType> exprType = UnaryExprType.fromSymbol(strType);
+ if (exprType.isPresent()) {
+ this.unaryExprType = exprType.get();
+ } else {
+ throw new AsterixException("Unsupported operator: " + strType);
+ }
}
public Expression getExpr() {
@@ -57,11 +65,6 @@
return Kind.UNARY_EXPRESSION;
}
- public enum Sign {
- POSITIVE,
- NEGATIVE
- }
-
@Override
public <R, T> R accept(ILangVisitor<R, T> visitor, T arg) throws AsterixException {
return visitor.visit(this, arg);
@@ -69,7 +72,7 @@
@Override
public int hashCode() {
- return ObjectUtils.hashCodeMulti(expr, sign);
+ return ObjectUtils.hashCodeMulti(expr, unaryExprType);
}
@Override
@@ -81,6 +84,6 @@
return false;
}
UnaryExpr target = (UnaryExpr) object;
- return ObjectUtils.equals(expr, target.expr) && ObjectUtils.equals(sign, target.sign);
+ return ObjectUtils.equals(expr, target.expr) && ObjectUtils.equals(unaryExprType, target.unaryExprType);
}
}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/UnaryExprType.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/UnaryExprType.java
new file mode 100644
index 0000000..554a659
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/struct/UnaryExprType.java
@@ -0,0 +1,44 @@
+/*
+3 * 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.lang.common.struct;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+public enum UnaryExprType {
+ POSITIVE("+"),
+ NEGATIVE("-"),
+ EXISTS("exists"),
+ NOT_EXISTS("not_exists");
+
+ private final String symbol;
+
+ UnaryExprType(String s) {
+ symbol = s;
+ }
+
+ @Override
+ public String toString() {
+ return symbol;
+ }
+
+ public static Optional<UnaryExprType> fromSymbol(String symbol) {
+ return Arrays.stream(UnaryExprType.values()).filter(o -> o.symbol.equals(symbol)).findFirst();
+ }
+}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/CloneAndSubstituteVariablesVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/CloneAndSubstituteVariablesVisitor.java
index 57264be..667878c 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/CloneAndSubstituteVariablesVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/CloneAndSubstituteVariablesVisitor.java
@@ -260,7 +260,7 @@
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(UnaryExpr u,
VariableSubstitutionEnvironment env) throws AsterixException {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = u.getExpr().accept(this, env);
- UnaryExpr newU = new UnaryExpr(u.getSign(), (Expression) p1.first);
+ UnaryExpr newU = new UnaryExpr(u.getExprType(), (Expression) p1.first);
return new Pair<>(newU, env);
}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
index b9c583d..54795bc 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
@@ -58,7 +58,6 @@
import org.apache.asterix.lang.common.expression.TypeExpression;
import org.apache.asterix.lang.common.expression.TypeReferenceExpression;
import org.apache.asterix.lang.common.expression.UnaryExpr;
-import org.apache.asterix.lang.common.expression.UnaryExpr.Sign;
import org.apache.asterix.lang.common.expression.UnorderedListTypeDefinition;
import org.apache.asterix.lang.common.expression.VariableExpr;
import org.apache.asterix.lang.common.statement.CompactStatement;
@@ -95,6 +94,7 @@
import org.apache.asterix.lang.common.struct.Identifier;
import org.apache.asterix.lang.common.struct.OperatorType;
import org.apache.asterix.lang.common.struct.QuantifiedPair;
+import org.apache.asterix.lang.common.struct.UnaryExprType;
import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation;
@@ -363,7 +363,7 @@
@Override
public Void visit(UnaryExpr u, Integer step) throws AsterixException {
- out.print(u.getSign() == Sign.NEGATIVE ? "-" : "");
+ out.print(u.getExprType() == UnaryExprType.NEGATIVE ? "-" : "");
u.getExpr().accept(this, 0);
return null;
}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
index ba2f52c..a32a3c8 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
@@ -284,8 +284,8 @@
@Override
public Void visit(UnaryExpr u, Integer step) throws AsterixException {
- if (u.getSign() != null) {
- out.print(skip(step) + u.getSign() + " ");
+ if (u.getExprType() != null) {
+ out.print(skip(step) + u.getExprType() + " ");
u.getExpr().accept(this, 0);
} else {
u.getExpr().accept(this, step);
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
index c591d72..815e020 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
@@ -76,7 +76,7 @@
new ArrayList<Expression>(Collections.singletonList(likeExpr)));
}
- private Expression processInOperator(OperatorExpr operatorExpr, OperatorType opType) {
+ private Expression processInOperator(OperatorExpr operatorExpr, OperatorType opType) throws AsterixException {
VariableExpr bindingVar = new VariableExpr(context.newVariable());
Expression itemExpr = operatorExpr.getExprList().get(0);
Expression collectionExpr = operatorExpr.getExprList().get(1);
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/DeepCopyVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/DeepCopyVisitor.java
index 6c48c64..bafb8c0 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/DeepCopyVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/DeepCopyVisitor.java
@@ -402,7 +402,7 @@
@Override
public UnaryExpr visit(UnaryExpr u, Void arg) throws AsterixException {
- return new UnaryExpr(u.getSign(), (Expression) u.getExpr().accept(this, arg));
+ return new UnaryExpr(u.getExprType(), (Expression) u.getExpr().accept(this, arg));
}
@Override
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppCloneAndSubstituteVariablesVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppCloneAndSubstituteVariablesVisitor.java
index 445c835..d380cad 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppCloneAndSubstituteVariablesVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/visitor/SqlppCloneAndSubstituteVariablesVisitor.java
@@ -187,6 +187,9 @@
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(Projection projection,
VariableSubstitutionEnvironment env) throws AsterixException {
+ if (projection.star()) {
+ return new Pair<>(projection, env);
+ }
Projection newProjection = new Projection((Expression) projection.getExpression().accept(this, env).first,
projection.getName(), projection.star(), projection.exprStar());
return new Pair<>(newProjection, env);
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.html b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.html
index c651146..8d093d9 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.html
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.html
@@ -684,60 +684,65 @@
<TR>
<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod66">AndExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod67">RelExpr</A> ( <AND> <A HREF="#prod67">RelExpr</A> )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod67">NotExpr</A> ( <AND> <A HREF="#prod67">NotExpr</A> )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod67">RelExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod67">NotExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod68">IsExpr</A> ( ( <LT> | <GT> | <LE> | <GE> | <EQ> | <NE> | <SIMILAR> | ( <NOT> )? ( <LIKE> | <IN> ) ) <A HREF="#prod68">IsExpr</A> )?</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <NOT> )? <A HREF="#prod68">RelExpr</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod68">IsExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod68">RelExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod69">AddExpr</A> ( <IS> ( <NOT> )? ( <NULL> | <MISSING> | <UNKOWN> ) )?</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod69">IsExpr</A> ( ( <LT> | <GT> | <LE> | <GE> | <EQ> | <NE> | <SIMILAR> | ( <NOT> )? ( <LIKE> | <IN> ) ) <A HREF="#prod69">IsExpr</A> )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod69">AddExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod69">IsExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod70">MultExpr</A> ( ( <PLUS> | <MINUS> ) <A HREF="#prod70">MultExpr</A> )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod70">AddExpr</A> ( <IS> ( <NOT> )? ( <NULL> | <MISSING> | <UNKOWN> ) )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod70">MultExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod70">AddExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod71">UnaryExpr</A> ( ( <MUL> | <DIV> | <MOD> | <CARET> | <IDIV> ) <A HREF="#prod71">UnaryExpr</A> )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod71">MultExpr</A> ( ( <PLUS> | <MINUS> ) <A HREF="#prod71">MultExpr</A> )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod71">UnaryExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod71">MultExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( ( <PLUS> | <MINUS> | <NOT> ) )? <A HREF="#prod72">ValueExpr</A></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod72">UnaryExpr</A> ( ( <MUL> | <DIV> | <MOD> | <CARET> | <IDIV> ) <A HREF="#prod72">UnaryExpr</A> )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod72">ValueExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod72">UnaryExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod73">PrimaryExpr</A> ( <A HREF="#prod74">Field</A> | <A HREF="#prod75">Index</A> )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( ( <PLUS> | <MINUS> | ( <NOT> )? <EXISTS> ) )? <A HREF="#prod73">ValueExpr</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod74">Field</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod73">ValueExpr</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod74">PrimaryExpr</A> ( <A HREF="#prod75">Field</A> | <A HREF="#prod76">Index</A> )*</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod75">Field</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><DOT> <A HREF="#prod18">Identifier</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod75">Index</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod76">Index</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><LEFTBRACKET> ( <A HREF="#prod44">Expression</A> | <QUES> ) <RIGHTBRACKET></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod73">PrimaryExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod74">PrimaryExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod76">FunctionCallExpr</A> | <A HREF="#prod77">Literal</A> | <A HREF="#prod78">VariableRef</A> | <A HREF="#prod79">ListConstructor</A> | <A HREF="#prod80">RecordConstructor</A> | <A HREF="#prod81">ParenthesizedExpression</A> )</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod77">FunctionCallExpr</A> | <A HREF="#prod78">Literal</A> | <A HREF="#prod79">VariableRef</A> | <A HREF="#prod80">ListConstructor</A> | <A HREF="#prod81">RecordConstructor</A> | <A HREF="#prod82">ParenthesizedExpression</A> )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod77">Literal</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod78">Literal</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod54">StringLiteral</A> | <INTEGER_LITERAL> | <FLOAT_LITERAL> | <DOUBLE_LITERAL> | <MISSING> | <NULL> | <TRUE> | <FALSE> )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod78">VariableRef</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod79">VariableRef</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE>( <IDENTIFIER> | <A HREF="#prod61">QuotedString</A> )</TD>
</TR>
@@ -747,49 +752,49 @@
<TD ALIGN=LEFT VALIGN=BASELINE>( <IDENTIFIER> | <A HREF="#prod61">QuotedString</A> )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod79">ListConstructor</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod80">ListConstructor</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod82">OrderedListConstructor</A> | <A HREF="#prod83">UnorderedListConstructor</A> )</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod83">OrderedListConstructor</A> | <A HREF="#prod84">UnorderedListConstructor</A> )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod82">OrderedListConstructor</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod83">OrderedListConstructor</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><LEFTBRACKET> <A HREF="#prod84">ExpressionList</A> <RIGHTBRACKET></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><LEFTBRACKET> <A HREF="#prod85">ExpressionList</A> <RIGHTBRACKET></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod83">UnorderedListConstructor</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod84">UnorderedListConstructor</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><LEFTDBLBRACE> <A HREF="#prod84">ExpressionList</A> <RIGHTDBLBRACE></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><LEFTDBLBRACE> <A HREF="#prod85">ExpressionList</A> <RIGHTDBLBRACE></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod84">ExpressionList</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod85">ExpressionList</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod44">Expression</A> ( <COMMA> <A HREF="#prod84">ExpressionList</A> )? )? ( <A HREF="#prod85">Comma</A> )?</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod44">Expression</A> ( <COMMA> <A HREF="#prod85">ExpressionList</A> )? )? ( <A HREF="#prod86">Comma</A> )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod85">Comma</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod86">Comma</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><COMMA></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod80">RecordConstructor</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod81">RecordConstructor</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><LEFTBRACE> ( <A HREF="#prod86">FieldBinding</A> ( <COMMA> <A HREF="#prod86">FieldBinding</A> )* )? <RIGHTBRACE></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><LEFTBRACE> ( <A HREF="#prod87">FieldBinding</A> ( <COMMA> <A HREF="#prod87">FieldBinding</A> )* )? <RIGHTBRACE></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod86">FieldBinding</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod87">FieldBinding</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod44">Expression</A> <COLON> <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod76">FunctionCallExpr</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod77">FunctionCallExpr</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod42">FunctionName</A> <LEFTPAREN> ( <A HREF="#prod44">Expression</A> ( <COMMA> <A HREF="#prod44">Expression</A> )* )? <RIGHTPAREN></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod81">ParenthesizedExpression</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod82">ParenthesizedExpression</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( <LEFTPAREN> <A HREF="#prod44">Expression</A> <RIGHTPAREN> | <A HREF="#prod87">Subquery</A> )</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <LEFTPAREN> <A HREF="#prod44">Expression</A> <RIGHTPAREN> | <A HREF="#prod88">Subquery</A> )</TD>
</TR>
<TR>
<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod64">IfThenElse</A></TD>
@@ -799,95 +804,95 @@
<TR>
<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod62">SelectExpression</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod88">LetClause</A> )? <A HREF="#prod89">SelectSetOperation</A> ( <A HREF="#prod90">OrderbyClause</A> )? ( <A HREF="#prod91">LimitClause</A> )?</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod89">LetClause</A> )? <A HREF="#prod90">SelectSetOperation</A> ( <A HREF="#prod91">OrderbyClause</A> )? ( <A HREF="#prod92">LimitClause</A> )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod89">SelectSetOperation</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod90">SelectSetOperation</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod92">SelectBlock</A> ( ( <UNION> | <INTERSECT> | <EXCEPT> ) ( <ALL> )? ( <A HREF="#prod92">SelectBlock</A> | <A HREF="#prod87">Subquery</A> ) )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod93">SelectBlock</A> ( ( <UNION> | <INTERSECT> | <EXCEPT> ) ( <ALL> )? ( <A HREF="#prod93">SelectBlock</A> | <A HREF="#prod88">Subquery</A> ) )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod87">Subquery</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod88">Subquery</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><LEFTPAREN> <A HREF="#prod62">SelectExpression</A> <RIGHTPAREN></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod92">SelectBlock</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod93">SelectBlock</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod93">SelectClause</A> ( <A HREF="#prod94">FromClause</A> ( <A HREF="#prod88">LetClause</A> )? )? ( <A HREF="#prod95">WhereClause</A> )? ( <A HREF="#prod96">GroupbyClause</A> ( <A HREF="#prod88">LetClause</A> )? ( <A HREF="#prod97">HavingClause</A> )? )? | <A HREF="#prod94">FromClause</A> ( <A HREF="#prod88">LetClause</A> )? ( <A HREF="#prod95">WhereClause</A> )? ( <A HREF="#prod96">GroupbyClause</A> ( <A HREF="#prod88">LetClause</A> )? ( <A HREF="#prod97">HavingClause</A> )? )? <A HREF="#prod93">SelectClause</A> )</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod94">SelectClause</A> ( <A HREF="#prod95">FromClause</A> ( <A HREF="#prod89">LetClause</A> )? )? ( <A HREF="#prod96">WhereClause</A> )? ( <A HREF="#prod97">GroupbyClause</A> ( <A HREF="#prod89">LetClause</A> )? ( <A HREF="#prod98">HavingClause</A> )? )? | <A HREF="#prod95">FromClause</A> ( <A HREF="#prod89">LetClause</A> )? ( <A HREF="#prod96">WhereClause</A> )? ( <A HREF="#prod97">GroupbyClause</A> ( <A HREF="#prod89">LetClause</A> )? ( <A HREF="#prod98">HavingClause</A> )? )? <A HREF="#prod94">SelectClause</A> )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod93">SelectClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod94">SelectClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><SELECT> ( <ALL> | <DISTINCT> )? ( <A HREF="#prod98">SelectRegular</A> | <A HREF="#prod99">SelectElement</A> )?</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><SELECT> ( <ALL> | <DISTINCT> )? ( <A HREF="#prod99">SelectRegular</A> | <A HREF="#prod100">SelectElement</A> )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod98">SelectRegular</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod99">SelectRegular</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod100">Projection</A> ( <COMMA> <A HREF="#prod100">Projection</A> )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod101">Projection</A> ( <COMMA> <A HREF="#prod101">Projection</A> )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod99">SelectElement</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod100">SelectElement</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE>( <RAW> | <ELEMENT> | <VALUE> ) <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod100">Projection</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod101">Projection</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod18">Identifier</A> )? | <A HREF="#prod44">Expression</A> <DOT> <MUL> | <MUL> )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod94">FromClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod95">FromClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><FROM> <A HREF="#prod101">FromTerm</A> ( <COMMA> <A HREF="#prod101">FromTerm</A> )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><FROM> <A HREF="#prod102">FromTerm</A> ( <COMMA> <A HREF="#prod102">FromTerm</A> )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod101">FromTerm</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod102">FromTerm</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? ( <AT> <A HREF="#prod50">Variable</A> )? ( ( <A HREF="#prod102">JoinType</A> )? ( <A HREF="#prod103">JoinClause</A> | <A HREF="#prod104">UnnestClause</A> ) )*</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? ( <AT> <A HREF="#prod50">Variable</A> )? ( ( <A HREF="#prod103">JoinType</A> )? ( <A HREF="#prod104">JoinClause</A> | <A HREF="#prod105">UnnestClause</A> ) )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod103">JoinClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod104">JoinClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><JOIN> <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? ( <AT> <A HREF="#prod50">Variable</A> )? <ON> <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod104">UnnestClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod105">UnnestClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE>( <UNNEST> | <CORRELATE> | <FLATTEN> ) <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> ) ( <AT> <A HREF="#prod50">Variable</A> )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod102">JoinType</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod103">JoinType</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE>( <INNER> | <LEFT> ( <OUTER> )? )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod88">LetClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod89">LetClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE>( ( <LET> | <LETTING> ) <A HREF="#prod105">LetElement</A> ( <COMMA> <A HREF="#prod105">LetElement</A> )* | <WITH> <A HREF="#prod106">WithElement</A> ( <COMMA> <A HREF="#prod106">WithElement</A> )* )</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( ( <LET> | <LETTING> ) <A HREF="#prod106">LetElement</A> ( <COMMA> <A HREF="#prod106">LetElement</A> )* | <WITH> <A HREF="#prod107">WithElement</A> ( <COMMA> <A HREF="#prod107">WithElement</A> )* )</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod95">WhereClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod96">WhereClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><WHERE> <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod90">OrderbyClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod91">OrderbyClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><ORDER> <BY> <A HREF="#prod44">Expression</A> ( ( <ASC> ) | ( <DESC> ) )? ( <COMMA> <A HREF="#prod44">Expression</A> ( ( <ASC> ) | ( <DESC> ) )? )*</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod96">GroupbyClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod97">GroupbyClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
-<TD ALIGN=LEFT VALIGN=BASELINE><GROUP> <BY> ( <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? ( <COMMA> <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? )* ) ( <GROUP> <AS> <A HREF="#prod50">Variable</A> ( <LEFTPAREN> <A HREF="#prod78">VariableRef</A> <AS> <A HREF="#prod18">Identifier</A> ( <COMMA> <A HREF="#prod78">VariableRef</A> <AS> <A HREF="#prod18">Identifier</A> )* <RIGHTPAREN> )? )?</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><GROUP> <BY> ( <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? ( <COMMA> <A HREF="#prod44">Expression</A> ( ( <AS> )? <A HREF="#prod50">Variable</A> )? )* ) ( <GROUP> <AS> <A HREF="#prod50">Variable</A> ( <LEFTPAREN> <A HREF="#prod79">VariableRef</A> <AS> <A HREF="#prod18">Identifier</A> ( <COMMA> <A HREF="#prod79">VariableRef</A> <AS> <A HREF="#prod18">Identifier</A> )* <RIGHTPAREN> )? )?</TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod97">HavingClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod98">HavingClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><HAVING> <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod91">LimitClause</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod92">LimitClause</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><LIMIT> <A HREF="#prod44">Expression</A> ( <OFFSET> <A HREF="#prod44">Expression</A> )?</TD>
</TR>
@@ -897,12 +902,12 @@
<TD ALIGN=LEFT VALIGN=BASELINE>( ( <SOME> ) | ( <EVERY> ) ) <A HREF="#prod50">Variable</A> <IN> <A HREF="#prod44">Expression</A> ( <COMMA> <A HREF="#prod50">Variable</A> <IN> <A HREF="#prod44">Expression</A> )* <SATISFIES> <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod105">LetElement</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod106">LetElement</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod50">Variable</A> <EQ> <A HREF="#prod44">Expression</A></TD>
</TR>
<TR>
-<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod106">WithElement</A></TD>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod107">WithElement</A></TD>
<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod50">Variable</A> <AS> <A HREF="#prod44">Expression</A></TD>
</TR>
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 06b067e..99b875a 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -77,7 +77,6 @@
import org.apache.asterix.lang.common.expression.TypeExpression;
import org.apache.asterix.lang.common.expression.TypeReferenceExpression;
import org.apache.asterix.lang.common.expression.UnaryExpr;
-import org.apache.asterix.lang.common.expression.UnaryExpr.Sign;
import org.apache.asterix.lang.common.expression.UnorderedListTypeDefinition;
import org.apache.asterix.lang.common.expression.VariableExpr;
import org.apache.asterix.lang.common.literal.DoubleLiteral;
@@ -1618,7 +1617,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- op.addOperator(token.image.toLowerCase());
+ try{
+ op.addOperator(token.image.toLowerCase());
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = AndExpr()
@@ -1639,7 +1642,7 @@
Expression operand = null;
}
{
- operand = RelExpr()
+ operand = NotExpr()
(
<AND>
@@ -1647,12 +1650,16 @@
if (op == null) {
op = new OperatorExpr();
op.addOperand(operand);
- op.setCurrentop(true);
+ op.setCurrentop(true);
}
- op.addOperator(token.image.toLowerCase());
+ try{
+ op.addOperator(token.image.toLowerCase());
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
- operand = RelExpr()
+ operand = NotExpr()
{
op.addOperand(operand);
}
@@ -1664,7 +1671,22 @@
}
}
-
+Expression NotExpr()throws ParseException:
+{
+ Expression inputExpr;
+ boolean not = false;
+}
+{
+ (<NOT> { not = true; } )? inputExpr = RelExpr()
+ {
+ if(not){
+ FunctionSignature signature = new FunctionSignature(null, "not", 1);
+ return new CallExpr(signature, new ArrayList<Expression>(Collections.singletonList(inputExpr)));
+ } else {
+ return inputExpr;
+ }
+ }
+}
Expression RelExpr()throws ParseException:
{
@@ -1706,7 +1728,11 @@
op.setCurrentop(true);
broadcast = false;
}
- op.addOperator(operator);
+ try{
+ op.addOperator(operator);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = IsExpr()
@@ -1771,7 +1797,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- ((OperatorExpr)op).addOperator(token.image);
+ try{
+ ((OperatorExpr)op).addOperator(token.image);
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = MultExpr()
@@ -1800,7 +1830,11 @@
op.addOperand(operand);
op.setCurrentop(true);
}
- op.addOperator(token.image);
+ try{
+ op.addOperator(token.image);
+ } catch (Exception e){
+ throw new ParseException(e.getMessage());
+ }
}
operand = UnaryExpr()
{
@@ -1815,39 +1849,33 @@
Expression UnaryExpr() throws ParseException:
{
- Expression uexpr = null;
+ boolean not = false;
+ UnaryExpr uexpr = null;
Expression expr = null;
- FunctionSignature signature = null;
}
{
- ( (<PLUS> | <MINUS> | <NOT>)
+ ( (<PLUS> | <MINUS> | (<NOT> { not = true; } )? <EXISTS> )
{
- switch(token.image){
- case "+":
- uexpr = new UnaryExpr();
- ((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
- break;
- case "-":
- uexpr = new UnaryExpr();
- ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
- break;
- default:
- signature = new FunctionSignature(null, "not", 1);
- break;
+ String exprType = token.image.toLowerCase();
+ if(not){
+ exprType = "not_" + exprType;
+ }
+ uexpr = new UnaryExpr();
+ try{
+ uexpr.setExprType(exprType);
+ } catch (AsterixException e){
+ throw new ParseException(e.getMessage());
}
}
)?
expr = ValueExpr()
{
- if(uexpr!=null){
- ((UnaryExpr)uexpr).setExpr(expr);
- return uexpr;
- } else if (signature!=null){
- return new CallExpr(signature, new ArrayList<Expression>(Collections.singletonList(expr)));
- } else{
+ if(uexpr==null){
return expr;
- }
+ }
+ uexpr.setExpr(expr);
+ return uexpr;
}
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
index 33da4f9..8f55632 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
@@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -33,7 +34,7 @@
public final class ConstantExpression extends AbstractLogicalExpression {
private IAlgebricksConstantValue value;
- public final static ConstantExpression TRUE = new ConstantExpression(new IAlgebricksConstantValue() {
+ public static final ConstantExpression TRUE = new ConstantExpression(new IAlgebricksConstantValue() {
@Override
public boolean isTrue() {
@@ -60,7 +61,7 @@
return "TRUE";
}
});
- public final static ConstantExpression FALSE = new ConstantExpression(new IAlgebricksConstantValue() {
+ public static final ConstantExpression FALSE = new ConstantExpression(new IAlgebricksConstantValue() {
@Override
public boolean isTrue() {
@@ -87,7 +88,7 @@
return "FALSE";
}
});
- public final static ConstantExpression MISSING = new ConstantExpression(new IAlgebricksConstantValue() {
+ public static final ConstantExpression MISSING = new ConstantExpression(new IAlgebricksConstantValue() {
@Override
public boolean isTrue() {
@@ -115,7 +116,7 @@
}
});
- private Map<Object, IExpressionAnnotation> annotationMap = new HashMap<Object, IExpressionAnnotation>();
+ private Map<Object, IExpressionAnnotation> annotationMap = new HashMap<>();
public ConstantExpression(IAlgebricksConstantValue value) {
this.value = value;
@@ -170,10 +171,10 @@
@Override
public AbstractLogicalExpression cloneExpression() {
- Map<Object, IExpressionAnnotation> m = new HashMap<Object, IExpressionAnnotation>();
- for (Object k : annotationMap.keySet()) {
- IExpressionAnnotation annot2 = annotationMap.get(k).copy();
- m.put(k, annot2);
+ Map<Object, IExpressionAnnotation> m = new HashMap<>();
+ for (Entry<Object, IExpressionAnnotation> entry : annotationMap.entrySet()) {
+ IExpressionAnnotation annot2 = entry.getValue().copy();
+ m.put(entry.getKey(), annot2);
}
ConstantExpression c = new ConstantExpression(value);
c.annotationMap = m;