[ASTERIXDB-2395][COMP] Source location handling cleanup
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Minor cleanup in source location handling
- Created error codes for unknown node group / function / type / index
Change-Id: Ia5e0b67c49f66dd27c67832707f5003892453fc3
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2676
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FixReplicateOperatorOutputsRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FixReplicateOperatorOutputsRule.java
index e580e65..bd79a38 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FixReplicateOperatorOutputsRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FixReplicateOperatorOutputsRule.java
@@ -24,7 +24,7 @@
import java.util.Map;
import org.apache.asterix.algebra.operators.CommitOperator;
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableInt;
@@ -103,7 +103,7 @@
&& ((DelegateOperator) op).getDelegate() instanceof CommitOperator)) {
for (Map.Entry<AbstractReplicateOperator, MutableInt> entry : replicateOperators.entrySet()) {
if (entry.getKey().getOutputs().size() != entry.getValue().getValue()) {
- throw new AsterixException(ErrorCode.COMPILATION_FAILED_DUE_TO_REPLICATE_OP,
+ throw new CompilationException(ErrorCode.COMPILATION_FAILED_DUE_TO_REPLICATE_OP,
op.getSourceLocation());
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
index 7e2e4ea..ae74832 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
@@ -150,8 +150,8 @@
String datasetName = datasetSource.getId().getDatasourceName();
Dataset dataset = mp.findDataset(dataverseName, datasetName);
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Unknown dataset " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
return false;
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java
index cf8935a..b779c83 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java
@@ -127,8 +127,8 @@
Dataset dataset = mp.findDataset(asid.getDataverseName(), asid.getDatasourceName());
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, scan.getSourceLocation(),
- "Dataset " + asid.getDatasourceName() + " not found.");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, scan.getSourceLocation(),
+ asid.getDatasourceName(), asid.getDataverseName());
}
if (dataset.getDatasetType() != DatasetType.INTERNAL) {
return false;
@@ -300,8 +300,8 @@
MetadataProvider mp = (MetadataProvider) context.getMetadataProvider();
Dataset dataset = mp.findDataset(asid.getDataverseName(), asid.getDatasourceName());
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, scan.getSourceLocation(),
- "Dataset " + asid.getDatasourceName() + " not found.");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, scan.getSourceLocation(),
+ asid.getDatasourceName(), asid.getDataverseName());
}
if (dataset.getDatasetType() != DatasetType.INTERNAL) {
setAsFinal(access, context, finalAnnot);
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 bc2c919..2dbcb36 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
@@ -195,8 +195,8 @@
Dataset dataset = metadataProvider.findDataset(clffs.getDataverseName(), clffs.getDatasetName());
if (dataset == null) {
// This would never happen since we check for this in AqlTranslator
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Unable to load dataset " + clffs.getDatasetName() + " since it does not exist");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, clffs.getDatasetName(),
+ clffs.getDataverseName());
}
IAType itemType = metadataProvider.findType(dataset.getItemTypeDataverseName(), dataset.getItemTypeName());
IAType metaItemType =
@@ -639,8 +639,8 @@
String datasetName, SourceLocation sourceLoc) throws AlgebricksException {
Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Cannot find dataset " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
@@ -773,8 +773,8 @@
}
if (f == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Unknown function " + signature.getName() + "@" + signature.getArity());
+ throw new CompilationException(ErrorCode.UNKNOWN_FUNCTION, sourceLoc,
+ signature.getName() + "@" + signature.getArity());
}
// Put hints into function call expr.
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetResourcesRewriter.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetResourcesRewriter.java
index 77e0310..47c1045 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetResourcesRewriter.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetResourcesRewriter.java
@@ -47,8 +47,8 @@
MetadataProvider metadataProvider = (MetadataProvider) context.getMetadataProvider();
Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, f.getSourceLocation(),
- "Could not find dataset " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, f.getSourceLocation(), datasetName,
+ dataverseName);
}
return new DatasetResourcesDatasource(context.getComputationNodeDomain(), dataset.getDatasetId());
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetRewriter.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetRewriter.java
index 9b4b7c4..590bf54 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetRewriter.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DatasetRewriter.java
@@ -93,8 +93,8 @@
String datasetName = datasetReference.second;
Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, unnest.getSourceLocation(),
- "Could not find dataset " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, unnest.getSourceLocation(),
+ datasetName, dataverseName);
}
DataSourceId asid = new DataSourceId(dataverseName, datasetName);
List<LogicalVariable> variables = new ArrayList<>();
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/StorageComponentsRewriter.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/StorageComponentsRewriter.java
index d1796cf..259e6d7 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/StorageComponentsRewriter.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/StorageComponentsRewriter.java
@@ -47,8 +47,8 @@
MetadataProvider metadataProvider = (MetadataProvider) context.getMetadataProvider();
Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
if (dataset == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, f.getSourceLocation(),
- "Could not find dataset " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, f.getSourceLocation(), datasetName,
+ dataverseName);
}
return new StorageComponentsDatasource(context.getComputationNodeDomain(), dataset.getDatasetId());
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 5cbb85a..bc6fff1 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -403,7 +403,8 @@
resultSetIdCounter);
break;
default:
- throw new IllegalStateException(String.valueOf(stmt.getKind()));
+ throw new CompilationException(ErrorCode.COMPILATION_ILLEGAL_STATE, stmt.getSourceLocation(),
+ "Unexpected statement: " + stmt.getKind());
}
}
} finally {
@@ -441,7 +442,7 @@
try {
Dataverse dv = MetadataManager.INSTANCE.getDataverse(metadataProvider.getMetadataTxnContext(), dvName);
if (dv == null) {
- throw new MetadataException(ErrorCode.NO_DATAVERSE_WITH_NAME, sourceLoc, dvName);
+ throw new MetadataException(ErrorCode.UNKNOWN_DATAVERSE, sourceLoc, dvName);
}
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return dv;
@@ -468,7 +469,7 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return;
} else {
- throw new AsterixException(ErrorCode.DATAVERSE_EXISTS, stmt.getSourceLocation(), dvName);
+ throw new CompilationException(ErrorCode.DATAVERSE_EXISTS, stmt.getSourceLocation(), dvName);
}
}
MetadataManager.INSTANCE.addDataverse(metadataProvider.getMetadataTxnContext(),
@@ -558,8 +559,7 @@
Datatype dt = MetadataManager.INSTANCE.getDatatype(metadataProvider.getMetadataTxnContext(),
itemTypeDataverseName, itemTypeName);
if (dt == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- ": type " + itemTypeName + " could not be found.");
+ throw new CompilationException(ErrorCode.UNKNOWN_TYPE, sourceLoc, itemTypeName);
}
String ngName = ngNameId != null ? ngNameId.getValue()
: configureNodegroupForDataset(appCtx, dd.getHints(), dataverseName, datasetName, metadataProvider,
@@ -622,7 +622,7 @@
break;
default:
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Unknown datatype " + dd.getDatasetType());
+ "Unknown dataset type " + dd.getDatasetType());
}
// #. initialize DatasetIdFactory if it is not initialized.
@@ -774,8 +774,8 @@
try {
ds = metadataProvider.findDataset(dataverseName, datasetName);
if (ds == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no dataset with this name " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
index = MetadataManager.INSTANCE.getIndex(metadataProvider.getMetadataTxnContext(), dataverseName,
@@ -785,8 +785,7 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return;
} else {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "An index with this name " + indexName + " already exists.");
+ throw new CompilationException(ErrorCode.INDEX_EXISTS, sourceLoc, indexName);
}
}
// can't create secondary primary index on an external dataset
@@ -863,8 +862,8 @@
overridesFieldTypes = true;
}
if (fieldType == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Unknown type " + (fieldExpr.second == null ? fieldExpr.first : fieldExpr.second));
+ throw new CompilationException(ErrorCode.UNKNOWN_TYPE, sourceLoc, fieldExpr.second == null
+ ? String.valueOf(fieldExpr.first) : String.valueOf(fieldExpr.second));
}
// try to add the key & its source to the set of keys, if key couldn't be added,
@@ -1180,14 +1179,12 @@
try {
Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dataverseName);
if (dv == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Unknown dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATAVERSE, sourceLoc, dataverseName);
}
Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, dataverseName, typeName);
if (dt != null) {
if (!stmtCreateType.getIfNotExists()) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "A datatype with this name " + typeName + " already exists.");
+ throw new CompilationException(ErrorCode.TYPE_EXISTS, sourceLoc, typeName);
}
} else {
if (BuiltinTypeMap.getBuiltinType(typeName) != null) {
@@ -1233,8 +1230,7 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return;
} else {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no dataverse with this name " + dataverseName + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATAVERSE, sourceLoc, dataverseName);
}
}
// # check whether any function in current dataverse is being used by others
@@ -1408,7 +1404,8 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx.getValue());
return;
} else {
- throw new AsterixException(ErrorCode.NO_DATASET_WITH_NAME, dataverseName, datasetName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
}
ds.drop(metadataProvider, mdTxnCtx, jobsToExecute, bActiveTxn, progress, hcc, dropCorrespondingNodeGroup,
@@ -1471,8 +1468,8 @@
try {
Dataset ds = metadataProvider.findDataset(dataverseName, datasetName);
if (ds == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no dataset with this name " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
ActiveNotificationHandler activeEventHandler =
(ActiveNotificationHandler) appCtx.getActiveNotificationHandler();
@@ -1498,8 +1495,7 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return;
} else {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no index with this name " + indexName + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_INDEX, sourceLoc, indexName);
}
}
ensureNonPrimaryIndexDrop(index, sourceLoc);
@@ -1539,8 +1535,7 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return;
} else {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no index with this name " + indexName + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_INDEX, sourceLoc, indexName);
}
} else if (ExternalIndexingOperations.isFileIndex(index)) {
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
@@ -1663,8 +1658,7 @@
Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, dataverseName, typeName);
if (dt == null) {
if (!stmtTypeDrop.getIfExists()) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no datatype with this name " + typeName + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_TYPE, sourceLoc, typeName);
}
} else {
MetadataManager.INSTANCE.dropDatatype(mdTxnCtx, dataverseName, typeName);
@@ -1689,8 +1683,7 @@
NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodegroupName);
if (ng == null) {
if (!stmtDelete.getIfExists()) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no nodegroup with this name " + nodegroupName + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_NODEGROUP, sourceLoc, nodegroupName);
}
} else {
MetadataManager.INSTANCE.dropNodegroup(mdTxnCtx, nodegroupName, false);
@@ -1719,8 +1712,7 @@
try {
Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dataverse);
if (dv == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no dataverse with this name " + dataverse + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATAVERSE, sourceLoc, dataverse);
}
//Check whether the function is use-able
@@ -1788,7 +1780,7 @@
try {
Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx, signature);
if (function == null && !stmtDropFunction.getIfExists()) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, "Unknown function " + signature);
+ throw new CompilationException(ErrorCode.UNKNOWN_FUNCTION, sourceLoc, signature);
} else if (isFunctionUsed(mdTxnCtx, signature, null)) {
throw new MetadataException(ErrorCode.METADATA_DROP_FUCTION_IN_USE, sourceLoc, signature);
} else {
@@ -2325,8 +2317,8 @@
dataverseName, feedName, datasetName);
Dataset ds = metadataProvider.findDataset(dataverseName, datasetName);
if (ds == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Dataset " + dataverseName + "." + datasetName + " doesn't exist");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
if (fc == null) {
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, "Feed " + feedName
@@ -2360,8 +2352,8 @@
try {
Dataset ds = metadataProvider.findDataset(dataverseName, datasetName);
if (ds == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no dataset with this name " + datasetName + " in dataverse " + dataverseName + ".");
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
// Prepare jobs to compact the datatset and its indexes
List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
@@ -2654,8 +2646,8 @@
ds = metadataProvider.findDataset(dataverseName, datasetName);
// Dataset exists ?
if (ds == null) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "There is no dataset with this name " + datasetName + " in dataverse " + dataverseName);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ dataverseName);
}
// Dataset external ?
if (ds.getDatasetType() != DatasetType.EXTERNAL) {
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestDataset.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestDataset.java
index 4b4595a..bcf68b5 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestDataset.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestDataset.java
@@ -33,7 +33,6 @@
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IPushRuntime;
import org.apache.hyracks.algebricks.runtime.base.IPushRuntimeFactory;
-import org.apache.hyracks.algebricks.runtime.operators.base.AbstractPushRuntimeFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
@@ -57,7 +56,7 @@
@Override
public IPushRuntimeFactory getCommitRuntimeFactory(MetadataProvider metadataProvider,
int[] primaryKeyFieldPermutation, boolean isSink) throws AlgebricksException {
- return new AbstractPushRuntimeFactory() {
+ return new IPushRuntimeFactory() {
@Override
public IPushRuntime[] createPushRuntime(IHyracksTaskContext ctx) throws HyracksDataException {
return new IPushRuntime[] { new CommitRuntime(ctx, new TxnId(ctx.getJobletContext().getJobId().getId()),
diff --git a/asterixdb/asterix-app/src/test/resources/metadata/testsuite.xml b/asterixdb/asterix-app/src/test/resources/metadata/testsuite.xml
index 956cea1..e47c518 100644
--- a/asterixdb/asterix-app/src/test/resources/metadata/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/metadata/testsuite.xml
@@ -399,13 +399,13 @@
<test-case FilePath="exception">
<compilation-unit name="issue_272_create_index_error_1">
<output-dir compare="Text">none</output-dir>
- <expected-error>There is no dataset with this name Foo in dataverse test</expected-error>
+ <expected-error>Cannot find dataset with name Foo in dataverse test</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="exception">
<compilation-unit name="issue_272_create_index_error_2">
<output-dir compare="Text">none</output-dir>
- <expected-error>There is no dataset with this name Foo in dataverse test</expected-error>
+ <expected-error>Cannot find dataset with name Foo in dataverse test</expected-error>
</compilation-unit>
</test-case>
<!-- This case should be fixed to return a proper message rather than NPE -->
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index 4dd6d97..85779fa 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -6575,7 +6575,7 @@
<test-case FilePath="load">
<compilation-unit name="issue650_query">
<output-dir compare="Text">none</output-dir>
- <expected-error>Unable to load dataset Users since it does not exist</expected-error>
+ <expected-error>Cannot find dataset with name Users in dataverse fuzzyjoin</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="load">
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 c1d1db5..013fb77 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3645,7 +3645,7 @@
<compilation-unit name="partition-by-nonexistent-field">
<output-dir compare="Text">partition-by-nonexistent-field</output-dir>
<expected-error>Field "id" is not found</expected-error>
- <expected-error>Cannot find dataset testds in dataverse test</expected-error>
+ <expected-error>Cannot find dataset with name testds in dataverse test</expected-error>
<expected-error>Cannot find dataset testds in dataverse test nor an alias with name testds!</expected-error>
</compilation-unit>
</test-case>
@@ -8478,7 +8478,7 @@
<test-case FilePath="load">
<compilation-unit name="issue650_query">
<output-dir compare="Text">none</output-dir>
- <expected-error>Unable to load dataset Users since it does not exist</expected-error>
+ <expected-error>Cannot find dataset with name Users in dataverse fuzzyjoin</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="load">
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index 55c70f2..807b3e8 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -130,7 +130,7 @@
public static final int UPGRADE_FAILED_LOCK_WAS_NOT_ACQUIRED = 1047;
public static final int DOWNGRADE_FAILED_LOCK_WAS_NOT_ACQUIRED = 1048;
public static final int LOCK_WAS_ACQUIRED_DIFFERENT_OPERATION = 1049;
- public static final int NO_DATASET_WITH_NAME = 1050;
+ public static final int UNKNOWN_DATASET_IN_DATAVERSE = 1050;
public static final int INDEX_ILLEGAL_ENFORCED_ON_CLOSED_FIELD = 1051;
public static final int INDEX_ILLEGAL_REPETITIVE_FIELD = 1052;
public static final int CANNOT_CREATE_SEC_PRIMARY_IDX_ON_EXT_DATASET = 1053;
@@ -143,7 +143,7 @@
public static final int WITH_FIELD_MUST_BE_OF_TYPE = 1060;
public static final int WITH_FIELD_MUST_CONTAIN_SUB_FIELD = 1061;
public static final int MERGE_POLICY_PARAMETER_INVALID_TYPE = 1062;
- public static final int NO_DATAVERSE_WITH_NAME = 1063;
+ public static final int UNKNOWN_DATAVERSE = 1063;
public static final int ERROR_OCCURRED_BETWEEN_TWO_TYPES_CONVERSION = 1064;
public static final int CHOSEN_INDEX_COUNT_SHOULD_BE_GREATER_THAN_ONE = 1065;
public static final int CANNOT_SERIALIZE_A_VALUE = 1066;
@@ -156,10 +156,16 @@
public static final int UNDEFINED_IDENTIFIER = 1073;
public static final int AMBIGUOUS_IDENTIFIER = 1074;
public static final int FORBIDDEN_SCOPE = 1075;
- public static final int UNKNOWN_DATASET = 1076;
- public static final int UNKNOWN_DATASET_IN_DATAVERSE = 1077;
+ public static final int NAME_RESOLVE_UNKNOWN_DATASET = 1076;
+ public static final int NAME_RESOLVE_UNKNOWN_DATASET_IN_DATAVERSE = 1077;
public static final int COMPILATION_UNEXPECTED_OPERATOR = 1078;
public static final int COMPILATION_ERROR = 1079;
+ public static final int UNKNOWN_NODEGROUP = 1080;
+ public static final int UNKNOWN_FUNCTION = 1081;
+ public static final int UNKNOWN_TYPE = 1082;
+ public static final int UNKNOWN_INDEX = 1083;
+ public static final int INDEX_EXISTS = 1084;
+ public static final int TYPE_EXISTS = 1085;
// Feed errors
public static final int DATAFLOW_ILLEGAL_STATE = 3001;
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 21813e3..2fcb85d 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -117,7 +117,7 @@
1047 = Metadata lock cannot be upgraded! because it was not acquired before
1048 = Metadata lock cannot be downgraded! because it was not acquired before
1049 = Metadata lock cannot be acquired for %1$s since it is already acquired for %2$s
-1050 = There is no dataset with name %2$s in dataverse %1$s
+1050 = Cannot find dataset with name %1$s in dataverse %2$s
1051 = Cannot create enforced index on \"%1$s\" field. The field is closed type.
1052 = Cannot create index with the same field \"%1$s\" specified more than once.
1053 = Cannot create primary index on external dataset.
@@ -130,7 +130,7 @@
1060 = Field \"%1$s\" in the with clause must be of type %2$s
1061 = Field \"%1$s\" in the with clause must contain sub field \"%2$s\"
1062 = Merge policy parameters cannot be of type %1$s
-1063 = There is no dataverse with name \"%1$s\"
+1063 = Cannot find dataverse with name %1$s
1064 = An error was occurred while converting type %1$s to type %2$s.
1065 = There should be at least two applicable indexes.
1066 = Cannot serialize a value.
@@ -147,6 +147,12 @@
1077 = Cannot find dataset %1$s in dataverse %2$s nor an alias with name %1$s!
1078 = Unexpected operator %1$s in an OperatorExpr starting with %2$s
1079 = %1$s
+1080 = Cannot find node group with name %1$s
+1081 = Cannot find function with name %1$s
+1082 = Cannot find datatype wit name %1$s
+1083 = Cannot find index with name %1$s
+1084 = An index with this name %1$s already exists
+1085 = A datatype with this name %1$s already exists
# Feed Errors
3001 = Illegal state.
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/AbstractInlineUdfsVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/AbstractInlineUdfsVisitor.java
index 0413fa5..c43824d 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/AbstractInlineUdfsVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/AbstractInlineUdfsVisitor.java
@@ -349,7 +349,7 @@
try {
fnDataverse = metadataProvider.findDataverse(fnNamespace);
} catch (AlgebricksException e) {
- throw new CompilationException(ErrorCode.NO_DATAVERSE_WITH_NAME, e, sourceLoc, fnNamespace);
+ throw new CompilationException(ErrorCode.UNKNOWN_DATAVERSE, e, sourceLoc, fnNamespace);
}
}
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
index eadb4c1..5af284b 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
@@ -161,10 +161,10 @@
throws CompilationException {
String defaultDataverseName = metadataProvider.getDefaultDataverseName();
if (dataverseName == null && defaultDataverseName == null) {
- throw new CompilationException(ErrorCode.UNKNOWN_DATASET, sourceLoc, datasetName);
+ throw new CompilationException(ErrorCode.NAME_RESOLVE_UNKNOWN_DATASET, sourceLoc, datasetName);
}
//If no available dataset nor in-scope variable to resolve to, we throw an error.
- throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
+ throw new CompilationException(ErrorCode.NAME_RESOLVE_UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
dataverseName == null ? defaultDataverseName : dataverseName);
}
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index a7771b9..6d9976a 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -359,8 +359,9 @@
return token != null ? new SourceLocation(token.beginLine, token.beginColumn) : null;
}
- protected static void setSourceLocation(AbstractLangExpression expr, Token sourceLocToken) {
- expr.setSourceLocation(getSourceLocation(sourceLocToken));
+ protected static <T extends AbstractLangExpression> T addSourceLocation(T expr, Token token) {
+ expr.setSourceLocation(getSourceLocation(token));
+ return expr;
}
}
@@ -426,8 +427,7 @@
{
defaultDataverse = dvName;
DataverseDecl dvDecl = new DataverseDecl(new Identifier(dvName));
- setSourceLocation(dvDecl, startToken);
- return dvDecl;
+ return addSourceLocation(dvDecl, startToken);
}
}
@@ -485,8 +485,7 @@
}
TypeDataGen tddg = new TypeDataGen(dgen, filename, numValues);
TypeDecl stmt = new TypeDecl(nameComponents.first, nameComponents.second, typeExpr, tddg, ifNotExists);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -511,8 +510,7 @@
)*
{
NodegroupDecl stmt = new NodegroupDecl(new Identifier(name), ncNames, ifNotExists);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -614,8 +612,7 @@
}
)
{
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -631,8 +628,7 @@
RefreshExternalDatasetStatement stmt = new RefreshExternalDatasetStatement();
stmt.setDataverseName(nameComponents.first);
stmt.setDatasetName(nameComponents.second);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -684,8 +680,7 @@
stmt.setGramLength(indexType.gramLength);
}
stmt.setEnforced(enforced);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -754,8 +749,7 @@
ifNotExists = IfNotExists()
{
CreateDataverseStatement stmt = new CreateDataverseStatement(new Identifier(dvName), null, ifNotExists);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -796,8 +790,7 @@
removeCurrentScope();
defaultDataverse = currentDataverse;
CreateFunctionStatement stmt = new CreateFunctionStatement(signature, paramList, functionBody, functionBodyExpr, ifNotExists);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -817,8 +810,7 @@
{
try {
stmt = new CreateFeedStatement(nameComponents, withRecord, ifNotExists);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
} catch (AlgebricksException e) {
throw new SqlppParseException(getSourceLocation(startStmtToken), e.getMessage());
}
@@ -851,8 +843,7 @@
)
)
{
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -1013,8 +1004,7 @@
}
)
{
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1051,8 +1041,7 @@
query.setTopLevel(true);
InsertStatement stmt = new InsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter(),
var, returnExpression);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1075,8 +1064,7 @@
query.setTopLevel(true);
UpsertStatement stmt = new UpsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter(),
var, returnExpression);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1097,12 +1085,11 @@
varExpr = new VariableExpr();
VarIdentifier var = SqlppVariableUtil.toInternalVariableIdentifier(nameComponents.second.getValue());
varExpr.setVar(var);
- setSourceLocation(varExpr, startToken);
+ addSourceLocation(varExpr, startToken);
}
DeleteStatement stmt = new DeleteStatement(varExpr, nameComponents.first, nameComponents.second,
condition, getVarCounter());
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1129,8 +1116,7 @@
)*) <RIGHTPAREN>
{
UpdateStatement stmt = new UpdateStatement(vars, target, condition, ucs);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1169,8 +1155,7 @@
<SET> { startToken = token; } pn = Identifier() pv = ConstantString()
{
SetStatement stmt = new SetStatement(pn, pv);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1188,8 +1173,7 @@
( <USING> writerClass = ConstantString() )?
{
WriteStatement stmt = new WriteStatement(new Identifier(nodeName), fileName, writerClass);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1217,8 +1201,7 @@
)?
{
LoadStatement stmt = new LoadStatement(dataverseName, datasetName, adapterName, properties, alreadySorted);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1243,8 +1226,7 @@
<COMPACT> { startToken = token; } Dataset() nameComponents = QualifiedName()
{
CompactStatement stmt = new CompactStatement(nameComponents.first, nameComponents.second);
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1275,8 +1257,7 @@
<FEED> feedNameComponents = QualifiedName()
{
stmt = new StartFeedStatement (feedNameComponents);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -1290,8 +1271,7 @@
<FEED> feedNameComponents = QualifiedName()
{
stmt = new StopFeedStatement (feedNameComponents);
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -1310,8 +1290,7 @@
}
)
{
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -1358,8 +1337,7 @@
}
)
{
- setSourceLocation(stmt, startStmtToken);
- return stmt;
+ return addSourceLocation(stmt, startStmtToken);
}
}
@@ -1511,8 +1489,7 @@
recordKind = RecordTypeDefinition.RecordKind.OPEN;
}
recType.setRecordKind(recordKind);
- setSourceLocation(recType, startToken);
- return recType;
+ return addSourceLocation(recType, startToken);
}
}
@@ -1546,8 +1523,7 @@
}
TypeReferenceExpression typeRef = new TypeReferenceExpression(id);
- setSourceLocation(typeRef, token);
- return typeRef;
+ return addSourceLocation(typeRef, token);
}
}
@@ -1562,8 +1538,7 @@
<RIGHTBRACKET>
{
OrderedListTypeDefinition typeDef = new OrderedListTypeDefinition(type);
- setSourceLocation(typeDef, startToken);
- return typeDef;
+ return addSourceLocation(typeDef, startToken);
}
}
@@ -1578,8 +1553,7 @@
<RIGHTDBLBRACE>
{
UnorderedListTypeDefinition typeDef = new UnorderedListTypeDefinition(type);
- setSourceLocation(typeDef, startToken);
- return typeDef;
+ return addSourceLocation(typeDef, startToken);
}
}
@@ -1817,8 +1791,7 @@
getCurrentScope().addFunctionDescriptor(signature, false);
FunctionDecl stmt = new FunctionDecl(signature, paramList, funcBody);
removeCurrentScope();
- setSourceLocation(stmt, startToken);
- return stmt;
+ return addSourceLocation(stmt, startToken);
}
}
@@ -1880,9 +1853,9 @@
{
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
try{
op.addOperator(token.image.toLowerCase());
@@ -1915,9 +1888,9 @@
{
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
try{
op.addOperator(token.image.toLowerCase());
@@ -1950,8 +1923,7 @@
if(not) {
FunctionSignature signature = new FunctionSignature(BuiltinFunctions.NOT);
CallExpr callExpr = new CallExpr(signature, new ArrayList<Expression>(Collections.singletonList(inputExpr)));
- setSourceLocation(callExpr, startToken);
- return callExpr;
+ return addSourceLocation(callExpr, startToken);
} else {
return inputExpr;
}
@@ -1992,9 +1964,9 @@
}
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand, false); // broadcast is always for the right branch
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
try{
op.addOperator(operator);
@@ -2044,9 +2016,9 @@
}
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
try{
op.addOperator(operator);
@@ -2097,11 +2069,11 @@
{
FunctionSignature signature = new FunctionSignature(fn);
expr = new CallExpr(signature, new ArrayList<Expression>(Collections.singletonList(operand)));
- expr.setSourceLocation(getSourceLocation(token));
+ addSourceLocation(expr, token);
if (not) {
FunctionSignature notSignature = new FunctionSignature(BuiltinFunctions.NOT);
expr = new CallExpr(notSignature, new ArrayList<Expression>(Collections.singletonList(expr)));
- expr.setSourceLocation(getSourceLocation(notToken));
+ addSourceLocation(expr, notToken);
}
}
)?
@@ -2123,9 +2095,9 @@
(<NOT> { not = true; })? <LIKE>
{
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
String operator = token.image.toLowerCase();
if (not) {
@@ -2162,9 +2134,9 @@
{
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
op.addOperator(OperatorType.CONCAT);
}
@@ -2193,9 +2165,9 @@
{
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
op.addOperator(opType);
}
@@ -2229,9 +2201,9 @@
{
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
op.addOperator(opType);
}
@@ -2257,9 +2229,9 @@
{
if (op == null) {
op = new OperatorExpr();
- op.setSourceLocation(getSourceLocation(token));
op.addOperand(operand);
op.setCurrentop(true);
+ addSourceLocation(op, token);
}
op.addOperator(OperatorType.CARET);
}
@@ -2287,7 +2259,7 @@
exprType = "not_" + exprType;
}
uexpr = new UnaryExpr();
- uexpr.setSourceLocation(getSourceLocation(token));
+ addSourceLocation(uexpr, token);
try {
uexpr.setExprType(exprType);
} catch (CompilationException e){
@@ -2300,8 +2272,7 @@
{
if (uexpr == null) {
return expr;
- }
- else {
+ } else {
uexpr.setExpr(expr);
return uexpr;
}
@@ -2332,8 +2303,7 @@
<DOT> { startToken = token; } ident = Identifier()
{
FieldAccessor fa = new FieldAccessor(inputExpr, new Identifier(ident));
- setSourceLocation(fa, startToken);
- return fa;
+ return addSourceLocation(fa, startToken);
}
}
@@ -2363,8 +2333,7 @@
<RIGHTBRACKET>
{
IndexAccessor ia = new IndexAccessor(inputExpr, expr);
- setSourceLocation(ia, startToken);
- return ia;
+ return addSourceLocation(ia, startToken);
}
}
@@ -2439,8 +2408,7 @@
}
)
{
- setSourceLocation(lit, token);
- return lit;
+ return addSourceLocation(lit, token);
}
}
@@ -2466,8 +2434,7 @@
varExp.setIsNewVar(false);
var.setValue(id);
}
- setSourceLocation(varExp, token);
- return varExp;
+ return addSourceLocation(varExp, token);
}
}
@@ -2487,8 +2454,7 @@
}
varExp.setVar(var);
var.setValue(id);
- setSourceLocation(varExp, token);
- return varExp;
+ return addSourceLocation(varExp, token);
}
}
@@ -2517,8 +2483,7 @@
<RIGHTBRACKET>
{
ListConstructor expr = new ListConstructor(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR, exprList);
- setSourceLocation(expr, startToken);
- return expr;
+ return addSourceLocation(expr, startToken);
}
}
@@ -2533,8 +2498,7 @@
<RIGHTDBLBRACE>
{
ListConstructor expr = new ListConstructor(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR, exprList);
- setSourceLocation(expr, startToken);
- return expr;
+ return addSourceLocation(expr, startToken);
}
}
@@ -2575,8 +2539,7 @@
<RIGHTBRACE>
{
RecordConstructor expr = new RecordConstructor(fbList);
- setSourceLocation(expr, startToken);
- return expr;
+ return addSourceLocation(expr, startToken);
}
}
@@ -2696,12 +2659,10 @@
{
if (conditionExpr == null) {
LiteralExpr litExpr = new LiteralExpr(TrueLiteral.INSTANCE);
- setSourceLocation(litExpr, startToken);
- conditionExpr = litExpr;
+ conditionExpr = addSourceLocation(litExpr, startToken);
}
CaseExpression caseExpr = new CaseExpression(conditionExpr, whenExprs, thenExprs, elseExpr);
- setSourceLocation(caseExpr, startToken);
- return caseExpr;
+ return addSourceLocation(caseExpr, startToken);
}
}
@@ -2891,8 +2852,7 @@
(<RAW>|<ELEMENT>|<VALUE>) { startToken = token; } expr = Expression()
{
SelectElement selectElement = new SelectElement(expr);
- setSourceLocation(selectElement, startToken);
- return selectElement;
+ return addSourceLocation(selectElement, startToken);
}
}
@@ -2940,8 +2900,7 @@
(LOOKAHEAD(2) <COMMA> fromTerm = FromTerm() { fromTerms.add(fromTerm); } )*
{
FromClause fromClause = new FromClause(fromTerms);
- setSourceLocation(fromClause, startToken);
- return fromClause;
+ return addSourceLocation(fromClause, startToken);
}
}
@@ -2992,8 +2951,7 @@
rightVar = ExpressionToVariableUtil.getGeneratedVariable(rightExpr, true);
}
JoinClause joinClause = new JoinClause(joinType, rightExpr, rightVar, posVar, conditionExpr);
- setSourceLocation(joinClause, startToken);
- return joinClause;
+ return addSourceLocation(joinClause, startToken);
}
}
@@ -3011,8 +2969,7 @@
rightVar = ExpressionToVariableUtil.getGeneratedVariable(rightExpr, true);
}
UnnestClause unnestClause = new UnnestClause(joinType, rightExpr, rightVar, posVar);
- setSourceLocation(unnestClause, startToken);
- return unnestClause;
+ return addSourceLocation(unnestClause, startToken);
}
}
@@ -3052,8 +3009,7 @@
<WHERE> { startToken = token; } whereExpr = Expression()
{
WhereClause wc = new WhereClause(whereExpr);
- setSourceLocation(wc, startToken);
- return wc;
+ return addSourceLocation(wc, startToken);
}
}
@@ -3107,8 +3063,7 @@
{
oc.setModifierList(modifierList);
oc.setOrderbyList(orderbyList);
- setSourceLocation(oc, startToken);
- return oc;
+ return addSourceLocation(oc, startToken);
}
}
@@ -3193,9 +3148,8 @@
gbc.setWithVarMap(new HashMap<Expression, VariableExpr>());
gbc.setGroupVar(groupVar);
gbc.setGroupFieldList(groupFieldList);
- setSourceLocation(gbc, startToken);
replaceCurrentScope(newScope);
- return gbc;
+ return addSourceLocation(gbc, startToken);
}
}
@@ -3208,8 +3162,7 @@
<HAVING> { startToken = token; } filterExpr = Expression()
{
HavingClause havingClause = new HavingClause(filterExpr);
- setSourceLocation(havingClause, startToken);
- return havingClause;
+ return addSourceLocation(havingClause, startToken);
}
}
@@ -3225,9 +3178,8 @@
(<OFFSET> expr = Expression() { lc.setOffset(expr); })?
{
- setSourceLocation(lc, startToken);
popForbiddenScope();
- return lc;
+ return addSourceLocation(lc, startToken);
}
}
@@ -3264,9 +3216,8 @@
{
qc.setSatisfiesExpr(satisfiesExpr);
qc.setQuantifiedList(quantifiedList);
- setSourceLocation(qc, startToken);
removeCurrentScope();
- return qc;
+ return addSourceLocation(qc, startToken);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractIfMissingOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractIfMissingOrNullTypeComputer.java
index 2ec54d1..1d2cb21 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractIfMissingOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractIfMissingOrNullTypeComputer.java
@@ -33,12 +33,14 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+import org.apache.hyracks.api.exceptions.SourceLocation;
abstract class AbstractIfMissingOrNullTypeComputer implements IResultTypeComputer {
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
+ SourceLocation sourceLoc = fce.getSourceLocation();
IAType outPrimeType = null;
ATypeTag outQuantifier = null; // could be 'missing' or 'null'
@@ -66,22 +68,23 @@
} else {
IAType primeType = getOutputPrimeType(unionType);
ATypeTag quantifier = outQuantifier != null ? outQuantifier : getOutputQuantifier(unionType);
- return createOutputType(TypeResolverUtil.resolve(outPrimeType, primeType), quantifier);
+ return createOutputType(TypeResolverUtil.resolve(outPrimeType, primeType), quantifier,
+ sourceLoc);
}
}
} else {
// ANY or no intersection
return outPrimeType == null ? argType
- : createOutputType(TypeResolverUtil.resolve(outPrimeType, argType), outQuantifier);
+ : createOutputType(TypeResolverUtil.resolve(outPrimeType, argType), outQuantifier, sourceLoc);
}
}
if (outPrimeType == null) {
return BuiltinType.ANULL;
}
- IAType outType = createOutputType(outPrimeType, ATypeTag.NULL);
+ IAType outType = createOutputType(outPrimeType, ATypeTag.NULL, sourceLoc);
if (outQuantifier == ATypeTag.MISSING) {
- outType = createOutputType(outType, ATypeTag.MISSING);
+ outType = createOutputType(outType, ATypeTag.MISSING, sourceLoc);
}
return outType;
}
@@ -96,7 +99,8 @@
return type.getActualType();
}
- private IAType createOutputType(IAType primeType, ATypeTag quantifier) {
+ private IAType createOutputType(IAType primeType, ATypeTag quantifier, SourceLocation sourceLoc)
+ throws CompilationException {
if (quantifier == null || primeType.getTypeTag() == ATypeTag.ANY) {
return primeType;
}
@@ -106,7 +110,8 @@
case NULL:
return AUnionType.createNullableType(primeType, null);
default:
- throw new IllegalStateException(String.valueOf(quantifier));
+ throw new CompilationException(ErrorCode.COMPILATION_ILLEGAL_STATE, sourceLoc,
+ "Unexpected quantifier: " + quantifier);
}
}
}