Merge branch 'cheshire-cat'
Change-Id: Iaa3ab431d3225c9f95ec530b8099bf211684c34f
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/AnalysisUtil.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/AnalysisUtil.java
index 7eea595..8b5c8bc 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/AnalysisUtil.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/AnalysisUtil.java
@@ -28,6 +28,7 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.optimizer.rules.am.AccessMethodUtils;
import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
@@ -127,7 +128,7 @@
return new Pair<>(srcId.getDataverseName(), srcId.getDatasourceName());
}
- public static Pair<DataverseName, String> getExternalDatasetInfo(UnnestMapOperator op) {
+ public static Pair<DataverseName, String> getExternalDatasetInfo(UnnestMapOperator op) throws AlgebricksException {
AbstractFunctionCallExpression unnestExpr = (AbstractFunctionCallExpression) op.getExpressionRef().getValue();
DataverseName dataverseName = DataverseName
.createFromCanonicalForm(AccessMethodUtils.getStringConstant(unnestExpr.getArguments().get(0)));
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceMaterializationForInsertWithSelfScanRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceMaterializationForInsertWithSelfScanRule.java
index d838d71..5e60b6f 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceMaterializationForInsertWithSelfScanRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceMaterializationForInsertWithSelfScanRule.java
@@ -83,7 +83,8 @@
}
- private boolean checkIfInsertAndScanDatasetsSame(AbstractLogicalOperator op, String insertDatasetName) {
+ private boolean checkIfInsertAndScanDatasetsSame(AbstractLogicalOperator op, String insertDatasetName)
+ throws AlgebricksException {
boolean sameDataset = false;
for (int i = 0; i < op.getInputs().size(); ++i) {
AbstractLogicalOperator descendantOp = (AbstractLogicalOperator) op.getInputs().get(i).getValue();
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoPrimarySearchRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoPrimarySearchRule.java
index 22dad3a..d95a952 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoPrimarySearchRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoPrimarySearchRule.java
@@ -156,7 +156,7 @@
return changed;
}
- private boolean setLimitForScanOrUnnestMap(ILogicalOperator op, int outputLimit) {
+ private boolean setLimitForScanOrUnnestMap(ILogicalOperator op, int outputLimit) throws AlgebricksException {
if (op.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) {
DataSourceScanOperator scan = (DataSourceScanOperator) op;
if (isScanPushable(scan, Collections.emptySet())) {
@@ -173,7 +173,8 @@
return false;
}
- private boolean isUnnestMapPushable(UnnestMapOperator op, Set<LogicalVariable> selectedVariables) {
+ private boolean isUnnestMapPushable(UnnestMapOperator op, Set<LogicalVariable> selectedVariables)
+ throws AlgebricksException {
if (op.getOutputLimit() >= 0) {
// already pushed
return false;
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodJobGenParams.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodJobGenParams.java
index a4795ba..c4f1487 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodJobGenParams.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodJobGenParams.java
@@ -26,6 +26,7 @@
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
@@ -69,7 +70,7 @@
funcArgs.add(new MutableObject<>(AccessMethodUtils.createBooleanConstant(requiresBroadcast)));
}
- public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) {
+ public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) throws AlgebricksException {
indexName = AccessMethodUtils.getStringConstant(funcArgs.get(0));
indexType = IndexType.values()[AccessMethodUtils.getInt32Constant(funcArgs.get(1))];
dataverseName = DataverseName.createFromCanonicalForm(AccessMethodUtils.getStringConstant(funcArgs.get(2)));
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeJobGenParams.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeJobGenParams.java
index 2eefc8c..7bcaaac 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeJobGenParams.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeJobGenParams.java
@@ -25,6 +25,7 @@
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
@@ -88,7 +89,7 @@
writeBoolean(isEqCondition, funcArgs);
}
- public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) {
+ public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) throws AlgebricksException {
super.readFromFuncArgs(funcArgs);
int index = super.getNumParams();
lowKeyVarList = new ArrayList<LogicalVariable>();
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexJobGenParams.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexJobGenParams.java
index 26350d8..550b130 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexJobGenParams.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexJobGenParams.java
@@ -27,6 +27,7 @@
import org.apache.asterix.optimizer.rules.am.InvertedIndexAccessMethod.SearchModifierType;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
@@ -105,7 +106,7 @@
}
@Override
- public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) {
+ public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) throws AlgebricksException {
super.readFromFuncArgs(funcArgs);
int index = super.getNumParams();
// Read search modifier type.
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
index b765bd0..d45e7f2 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
@@ -145,7 +145,7 @@
return initializeDataSource(searchOpRef);
}
- private boolean initializeDataSource(Mutable<ILogicalOperator> subTreeOpRef) {
+ private boolean initializeDataSource(Mutable<ILogicalOperator> subTreeOpRef) throws AlgebricksException {
AbstractLogicalOperator subTreeOp = (AbstractLogicalOperator) subTreeOpRef.getValue();
if (subTreeOp.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) {
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeJobGenParams.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeJobGenParams.java
index d58766e..1e5983a 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeJobGenParams.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeJobGenParams.java
@@ -24,6 +24,7 @@
import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
@@ -48,7 +49,7 @@
writeVarList(keyVarList, funcArgs);
}
- public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) {
+ public void readFromFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) throws AlgebricksException {
super.readFromFuncArgs(funcArgs);
int index = super.getNumParams();
keyVarList = new ArrayList<LogicalVariable>();
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractNCUdfServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractNCUdfServlet.java
index eb424af..cf287d9 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractNCUdfServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractNCUdfServlet.java
@@ -151,7 +151,8 @@
return field == null || !field.getHttpDataType().equals(InterfaceHttpData.HttpDataType.Attribute);
}
- protected Pair<DataverseName, String> decodeDvAndLibFromLocalPath(String localPath) throws RuntimeDataException {
+ protected Pair<DataverseName, String> decodeDvAndLibFromLocalPath(String localPath)
+ throws RuntimeDataException, AlgebricksException {
String[] pathSegments = StringUtils.split(localPath, '/');
if (pathSegments.length != 2) {
throw RuntimeDataException.create(ErrorCode.PARAMETERS_REQUIRED,
@@ -205,7 +206,7 @@
}
if (IFormattedException.matchesAny(e, ErrorCode.LIBRARY_EXTERNAL_FUNCTION_UNKNOWN_KIND,
ErrorCode.LIBRARY_EXTERNAL_FUNCTION_UNSUPPORTED_KIND, ErrorCode.INVALID_REQ_PARAM_VAL,
- ErrorCode.PARAMETERS_REQUIRED)) {
+ ErrorCode.PARAMETERS_REQUIRED, ErrorCode.INVALID_DATABASE_OBJECT_NAME)) {
return HttpResponseStatus.BAD_REQUEST;
}
if (e instanceof AlgebricksException) {
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/RebalanceApiServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/RebalanceApiServlet.java
index c4d664b..f1652ea 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/RebalanceApiServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/RebalanceApiServlet.java
@@ -48,6 +48,7 @@
import org.apache.asterix.metadata.utils.MetadataConstants;
import org.apache.asterix.rebalance.NoOpDatasetRebalanceCallback;
import org.apache.asterix.utils.RebalanceUtil;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.client.IHyracksClientConnection;
import org.apache.hyracks.http.api.IServletRequest;
import org.apache.hyracks.http.api.IServletResponse;
@@ -105,7 +106,13 @@
protected void post(IServletRequest request, IServletResponse response) {
try {
// Gets dataverse, dataset, and target nodes for rebalance.
- DataverseName dataverseName = ServletUtil.getDataverseName(request, "dataverseName");
+ DataverseName dataverseName;
+ try {
+ dataverseName = ServletUtil.getDataverseName(request, "dataverseName");
+ } catch (AlgebricksException e) {
+ sendResponse(response, HttpResponseStatus.BAD_REQUEST, e.getMessage());
+ return;
+ }
String datasetName = request.getParameter("datasetName");
Set<String> targetNodes = new LinkedHashSet<>(request.getParameterValues("targetNode"));
boolean forceRebalance = true;
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ServletUtil.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ServletUtil.java
index 51fa326..3ac37bf 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ServletUtil.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ServletUtil.java
@@ -29,6 +29,7 @@
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.net.URLCodec;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.client.IHyracksClientConnection;
import org.apache.hyracks.api.result.IResultSet;
import org.apache.hyracks.client.result.ResultSet;
@@ -53,7 +54,8 @@
return resultSet;
}
- public static DataverseName getDataverseName(IServletRequest request, String dataverseParameterName) {
+ public static DataverseName getDataverseName(IServletRequest request, String dataverseParameterName)
+ throws AlgebricksException {
List<String> values = request.getParameterValues(dataverseParameterName);
return !values.isEmpty() ? DataverseName.create(values) : null;
}
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 777f4d5..7154814 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
@@ -484,7 +484,7 @@
outputFile = result.second;
break;
case FUNCTION_DECL:
- handleDeclareFunctionStatement(stmt);
+ handleDeclareFunctionStatement(metadataProvider, stmt);
break;
case EXTENSION:
final ExtensionStatement extStmt = (ExtensionStatement) stmt;
@@ -1784,6 +1784,7 @@
DataverseDropStatement stmtDropDataverse = (DataverseDropStatement) stmt;
SourceLocation sourceLoc = stmtDropDataverse.getSourceLocation();
DataverseName dataverseName = stmtDropDataverse.getDataverseName();
+ metadataProvider.validateDataverseName(dataverseName, sourceLoc);
if (dataverseName.equals(MetadataBuiltinEntities.DEFAULT_DATAVERSE_NAME)
|| dataverseName.equals(MetadataConstants.METADATA_DATAVERSE_NAME)) {
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
@@ -1974,8 +1975,9 @@
IHyracksClientConnection hcc, IRequestParameters requestParameters) throws Exception {
DropDatasetStatement stmtDelete = (DropDatasetStatement) stmt;
SourceLocation sourceLoc = stmtDelete.getSourceLocation();
- DataverseName dataverseName = getActiveDataverseName(stmtDelete.getDataverseName());
String datasetName = stmtDelete.getDatasetName().getValue();
+ metadataProvider.validateDatabaseObjectName(stmtDelete.getDataverseName(), datasetName, sourceLoc);
+ DataverseName dataverseName = getActiveDataverseName(stmtDelete.getDataverseName());
lockUtil.dropDatasetBegin(lockManager, metadataProvider.getLocks(), dataverseName, datasetName);
try {
doDropDataset(dataverseName, datasetName, metadataProvider, stmtDelete.getIfExists(), hcc,
@@ -2072,6 +2074,8 @@
protected void handleIndexDropStatement(MetadataProvider metadataProvider, Statement stmt,
IHyracksClientConnection hcc, IRequestParameters requestParameters) throws Exception {
IndexDropStatement stmtIndexDrop = (IndexDropStatement) stmt;
+ metadataProvider.validateDatabaseObjectName(stmtIndexDrop.getDataverseName(),
+ stmtIndexDrop.getIndexName().getValue(), stmtIndexDrop.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(stmtIndexDrop.getDataverseName());
String datasetName = stmtIndexDrop.getDatasetName().getValue();
lockUtil.dropIndexBegin(lockManager, metadataProvider.getLocks(), dataverseName, datasetName);
@@ -2342,9 +2346,9 @@
protected void handleTypeDropStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
TypeDropStatement stmtTypeDrop = (TypeDropStatement) stmt;
SourceLocation sourceLoc = stmtTypeDrop.getSourceLocation();
- DataverseName dataverseName = getActiveDataverseName(stmtTypeDrop.getDataverseName());
String typeName = stmtTypeDrop.getTypeName().getValue();
-
+ metadataProvider.validateDatabaseObjectName(stmtTypeDrop.getDataverseName(), typeName, sourceLoc);
+ DataverseName dataverseName = getActiveDataverseName(stmtTypeDrop.getDataverseName());
MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
lockUtil.dropTypeBegin(lockManager, metadataProvider.getLocks(), dataverseName, typeName);
@@ -2384,6 +2388,7 @@
NodeGroupDropStatement stmtDelete = (NodeGroupDropStatement) stmt;
SourceLocation sourceLoc = stmtDelete.getSourceLocation();
String nodegroupName = stmtDelete.getNodeGroupName().getValue();
+ metadataProvider.validateDatabaseObjectName(null, nodegroupName, sourceLoc);
MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
lockManager.acquireNodeGroupWriteLock(metadataProvider.getLocks(), nodegroupName);
@@ -2406,9 +2411,11 @@
}
}
- protected void handleDeclareFunctionStatement(Statement stmt) {
+ protected void handleDeclareFunctionStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
FunctionDecl fds = (FunctionDecl) stmt;
FunctionSignature signature = fds.getSignature();
+ metadataProvider.validateDatabaseObjectName(signature.getDataverseName(), signature.getName(),
+ stmt.getSourceLocation());
signature.setDataverseName(getActiveDataverseName(signature.getDataverseName()));
declaredFunctions.add(fds);
}
@@ -2680,6 +2687,8 @@
protected void handleFunctionDropStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
FunctionDropStatement stmtDropFunction = (FunctionDropStatement) stmt;
FunctionSignature signature = stmtDropFunction.getFunctionSignature();
+ metadataProvider.validateDatabaseObjectName(signature.getDataverseName(), signature.getName(),
+ stmtDropFunction.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(signature.getDataverseName());
signature.setDataverseName(dataverseName);
lockUtil.dropFunctionBegin(lockManager, metadataProvider.getLocks(), dataverseName, signature.getName());
@@ -2732,13 +2741,15 @@
protected void handleCreateAdapterStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
CreateAdapterStatement cas = (CreateAdapterStatement) stmt;
+ String adapterName = cas.getAdapterName();
+ metadataProvider.validateDatabaseObjectName(cas.getDataverseName(), adapterName, cas.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(cas.getDataverseName());
DataverseName libraryDataverseName = cas.getLibraryDataverseName();
if (libraryDataverseName == null) {
libraryDataverseName = dataverseName;
}
String libraryName = cas.getLibraryName();
- lockUtil.createAdapterBegin(lockManager, metadataProvider.getLocks(), dataverseName, cas.getAdapterName(),
+ lockUtil.createAdapterBegin(lockManager, metadataProvider.getLocks(), dataverseName, adapterName,
libraryDataverseName, libraryName);
try {
doCreateAdapter(metadataProvider, cas);
@@ -2804,8 +2815,10 @@
protected void handleAdapterDropStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
AdapterDropStatement stmtDropAdapter = (AdapterDropStatement) stmt;
- DataverseName dataverseName = getActiveDataverseName(stmtDropAdapter.getDataverseName());
+ SourceLocation sourceLoc = stmtDropAdapter.getSourceLocation();
String adapterName = stmtDropAdapter.getAdapterName();
+ metadataProvider.validateDatabaseObjectName(stmtDropAdapter.getDataverseName(), adapterName, sourceLoc);
+ DataverseName dataverseName = getActiveDataverseName(stmtDropAdapter.getDataverseName());
lockUtil.dropAdapterBegin(lockManager, metadataProvider.getLocks(), dataverseName, adapterName);
try {
doDropAdapter(metadataProvider, stmtDropAdapter, dataverseName, adapterName);
@@ -2851,6 +2864,8 @@
protected void handleCreateLibraryStatement(MetadataProvider metadataProvider, Statement stmt,
IHyracksClientConnection hcc, IRequestParameters requestParameters) throws Exception {
CreateLibraryStatement cls = (CreateLibraryStatement) stmt;
+ metadataProvider.validateDatabaseObjectName(cls.getDataverseName(), cls.getLibraryName(),
+ cls.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(cls.getDataverseName());
String libraryName = cls.getLibraryName();
String libraryHash = cls.getHash();
@@ -2977,8 +2992,10 @@
protected void handleLibraryDropStatement(MetadataProvider metadataProvider, Statement stmt,
IHyracksClientConnection hcc) throws Exception {
LibraryDropStatement stmtDropLibrary = (LibraryDropStatement) stmt;
- DataverseName dataverseName = getActiveDataverseName(stmtDropLibrary.getDataverseName());
String libraryName = stmtDropLibrary.getLibraryName();
+ metadataProvider.validateDatabaseObjectName(stmtDropLibrary.getDataverseName(), libraryName,
+ stmtDropLibrary.getSourceLocation());
+ DataverseName dataverseName = getActiveDataverseName(stmtDropLibrary.getDataverseName());
lockUtil.dropLibraryBegin(lockManager, metadataProvider.getLocks(), dataverseName, libraryName);
try {
doDropLibrary(metadataProvider, stmtDropLibrary, dataverseName, libraryName, hcc);
@@ -3065,6 +3082,8 @@
protected void handleCreateSynonymStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
CreateSynonymStatement css = (CreateSynonymStatement) stmt;
+ metadataProvider.validateDatabaseObjectName(css.getDataverseName(), css.getSynonymName(),
+ css.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(css.getDataverseName());
String synonymName = css.getSynonymName();
DataverseName objectDataverseName =
@@ -3112,8 +3131,10 @@
protected void handleDropSynonymStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
SynonymDropStatement stmtSynDrop = (SynonymDropStatement) stmt;
- DataverseName dataverseName = getActiveDataverseName(stmtSynDrop.getDataverseName());
String synonymName = stmtSynDrop.getSynonymName();
+ metadataProvider.validateDatabaseObjectName(stmtSynDrop.getDataverseName(), synonymName,
+ stmtSynDrop.getSourceLocation());
+ DataverseName dataverseName = getActiveDataverseName(stmtSynDrop.getDataverseName());
lockUtil.dropSynonymBegin(lockManager, metadataProvider.getLocks(), dataverseName, synonymName);
try {
doDropSynonym(metadataProvider, stmtSynDrop, dataverseName, synonymName);
@@ -3147,8 +3168,10 @@
protected void handleLoadStatement(MetadataProvider metadataProvider, Statement stmt, IHyracksClientConnection hcc)
throws Exception {
LoadStatement loadStmt = (LoadStatement) stmt;
- DataverseName dataverseName = getActiveDataverseName(loadStmt.getDataverseName());
String datasetName = loadStmt.getDatasetName();
+ metadataProvider.validateDatabaseObjectName(loadStmt.getDataverseName(), datasetName,
+ loadStmt.getSourceLocation());
+ DataverseName dataverseName = getActiveDataverseName(loadStmt.getDataverseName());
MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
boolean bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -3183,12 +3206,14 @@
ResultMetadata outMetadata, Stats stats, boolean compileOnly, IRequestParameters requestParameters,
Map<String, IAObject> stmtParams, IStatementRewriter stmtRewriter) throws Exception {
InsertStatement stmtInsertUpsert = (InsertStatement) stmt;
+ String datasetName = stmtInsertUpsert.getDatasetName();
+ metadataProvider.validateDatabaseObjectName(stmtInsertUpsert.getDataverseName(), datasetName,
+ stmtInsertUpsert.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(stmtInsertUpsert.getDataverseName());
final IMetadataLocker locker = new IMetadataLocker() {
@Override
public void lock() throws AlgebricksException {
- lockUtil.insertDeleteUpsertBegin(lockManager, metadataProvider.getLocks(), dataverseName,
- stmtInsertUpsert.getDatasetName());
+ lockUtil.insertDeleteUpsertBegin(lockManager, metadataProvider.getLocks(), dataverseName, datasetName);
}
@Override
@@ -3245,17 +3270,18 @@
IHyracksClientConnection hcc, boolean compileOnly, Map<String, IAObject> stmtParams,
IStatementRewriter stmtRewriter) throws Exception {
DeleteStatement stmtDelete = (DeleteStatement) stmt;
+ String datasetName = stmtDelete.getDatasetName();
+ metadataProvider.validateDatabaseObjectName(stmtDelete.getDataverseName(), datasetName,
+ stmt.getSourceLocation());
DataverseName dataverseName = getActiveDataverseName(stmtDelete.getDataverseName());
MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
boolean bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
- lockUtil.insertDeleteUpsertBegin(lockManager, metadataProvider.getLocks(), dataverseName,
- stmtDelete.getDatasetName());
+ lockUtil.insertDeleteUpsertBegin(lockManager, metadataProvider.getLocks(), dataverseName, datasetName);
try {
metadataProvider.setWriteTransaction(true);
CompiledDeleteStatement clfrqs = new CompiledDeleteStatement(stmtDelete.getVariableExpr(), dataverseName,
- stmtDelete.getDatasetName(), stmtDelete.getCondition(), stmtDelete.getVarCounter(),
- stmtDelete.getQuery());
+ datasetName, stmtDelete.getCondition(), stmtDelete.getVarCounter(), stmtDelete.getQuery());
clfrqs.setSourceLocation(stmt.getSourceLocation());
JobSpecification jobSpec =
rewriteCompileQuery(hcc, metadataProvider, clfrqs.getQuery(), clfrqs, stmtParams, stmtRewriter);
@@ -3438,8 +3464,9 @@
IHyracksClientConnection hcc) throws Exception {
FeedDropStatement stmtFeedDrop = (FeedDropStatement) stmt;
SourceLocation sourceLoc = stmtFeedDrop.getSourceLocation();
- DataverseName dataverseName = getActiveDataverseName(stmtFeedDrop.getDataverseName());
String feedName = stmtFeedDrop.getFeedName().getValue();
+ metadataProvider.validateDatabaseObjectName(stmtFeedDrop.getDataverseName(), feedName, sourceLoc);
+ DataverseName dataverseName = getActiveDataverseName(stmtFeedDrop.getDataverseName());
MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
lockUtil.dropFeedBegin(lockManager, metadataProvider.getLocks(), dataverseName, feedName);
@@ -3488,12 +3515,13 @@
}
protected void handleDropFeedPolicyStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
- MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
FeedPolicyDropStatement stmtFeedPolicyDrop = (FeedPolicyDropStatement) stmt;
SourceLocation sourceLoc = stmtFeedPolicyDrop.getSourceLocation();
- DataverseName dataverseName = getActiveDataverseName(stmtFeedPolicyDrop.getDataverseName());
String policyName = stmtFeedPolicyDrop.getPolicyName().getValue();
+ metadataProvider.validateDatabaseObjectName(stmtFeedPolicyDrop.getDataverseName(), policyName, sourceLoc);
+ DataverseName dataverseName = getActiveDataverseName(stmtFeedPolicyDrop.getDataverseName());
+ MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+ metadataProvider.setMetadataTxnContext(mdTxnCtx);
lockUtil.dropFeedPolicyBegin(lockManager, metadataProvider.getLocks(), dataverseName, policyName);
try {
FeedPolicyEntity feedPolicy = MetadataManager.INSTANCE.getFeedPolicy(mdTxnCtx, dataverseName, policyName);
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/CheckpointInSecondaryIndexTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/CheckpointInSecondaryIndexTest.java
index d60702f..1913233 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/CheckpointInSecondaryIndexTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/CheckpointInSecondaryIndexTest.java
@@ -108,7 +108,7 @@
private static final List<Integer> KEY_INDICATORS_LIST = Collections.singletonList(Index.RECORD_INDICATOR);
private static final int RECORDS_PER_COMPONENT = 500;
private static final int DATASET_ID = 101;
- private static final DataverseName DATAVERSE_NAME = DataverseName.createSinglePartName("TestDV");
+ private static final String DATAVERSE_NAME = "TestDV";
private static final String DATASET_NAME = "TestDS";
private static final String INDEX_NAME = "TestIdx";
private static final String DATA_TYPE_NAME = "DUMMY";
@@ -163,13 +163,14 @@
@Before
public void createIndex() throws Exception {
+ DataverseName dvName = DataverseName.createSinglePartName(DATAVERSE_NAME);
List<List<String>> partitioningKeys = new ArrayList<>();
partitioningKeys.add(Collections.singletonList("key"));
- dataset = new TestDataset(DATAVERSE_NAME, DATASET_NAME, DATAVERSE_NAME, DATA_TYPE_NAME, NODE_GROUP_NAME,
+ dataset = new TestDataset(dvName, DATASET_NAME, dvName, DATA_TYPE_NAME, NODE_GROUP_NAME,
NoMergePolicyFactory.NAME, null, new InternalDatasetDetails(null, PartitioningStrategy.HASH,
partitioningKeys, null, null, null, false, null, null),
null, DatasetType.INTERNAL, DATASET_ID, 0);
- secondaryIndex = new Index(DATAVERSE_NAME, DATASET_NAME, INDEX_NAME, INDEX_TYPE, INDEX_FIELD_NAMES,
+ secondaryIndex = new Index(dvName, DATASET_NAME, INDEX_NAME, INDEX_TYPE, INDEX_FIELD_NAMES,
INDEX_FIELD_INDICATORS, INDEX_FIELD_TYPES, false, false, false, 0);
taskCtx = null;
primaryIndexDataflowHelper = null;
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/GlobalVirtualBufferCacheTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/GlobalVirtualBufferCacheTest.java
index abfe2ec..b056bbe 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/GlobalVirtualBufferCacheTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/GlobalVirtualBufferCacheTest.java
@@ -32,6 +32,7 @@
import org.apache.asterix.common.api.IDatasetLifecycleManager;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.config.StorageProperties.Option;
+import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.common.transactions.ITransactionContext;
import org.apache.asterix.common.transactions.ITransactionManager;
import org.apache.asterix.common.transactions.TransactionOptions;
@@ -190,15 +191,15 @@
}
private void createIndex() throws Exception {
- dataset = new TestDataset(StorageTestUtils.DATAVERSE_NAME, "ds", StorageTestUtils.DATAVERSE_NAME,
- StorageTestUtils.DATA_TYPE_NAME, StorageTestUtils.NODE_GROUP_NAME, NoMergePolicyFactory.NAME,
+ DataverseName dvName = DataverseName.createSinglePartName(StorageTestUtils.DATAVERSE_NAME);
+ dataset = new TestDataset(dvName, "ds", dvName, StorageTestUtils.DATA_TYPE_NAME,
+ StorageTestUtils.NODE_GROUP_NAME, NoMergePolicyFactory.NAME,
null, new InternalDatasetDetails(null, PartitioningStrategy.HASH, StorageTestUtils.PARTITIONING_KEYS,
null, null, null, false, null, null),
null, DatasetType.INTERNAL, StorageTestUtils.DATASET_ID, 0);
- filteredDataset = new TestDataset(StorageTestUtils.DATAVERSE_NAME, "filtered_ds",
- StorageTestUtils.DATAVERSE_NAME, StorageTestUtils.DATA_TYPE_NAME, StorageTestUtils.NODE_GROUP_NAME,
- NoMergePolicyFactory.NAME, null,
+ filteredDataset = new TestDataset(dvName, "filtered_ds", dvName, StorageTestUtils.DATA_TYPE_NAME,
+ StorageTestUtils.NODE_GROUP_NAME, NoMergePolicyFactory.NAME, null,
new InternalDatasetDetails(null, PartitioningStrategy.HASH, StorageTestUtils.PARTITIONING_KEYS, null,
null, null, false, 0, Collections.singletonList("value")),
null, DatasetType.INTERNAL, StorageTestUtils.DATASET_ID + 1, 0);
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/MultiPartitionLSMIndexTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/MultiPartitionLSMIndexTest.java
index 41b889d..ef3a7cb 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/MultiPartitionLSMIndexTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/MultiPartitionLSMIndexTest.java
@@ -103,7 +103,7 @@
private static final int TOTAL_NUM_OF_RECORDS = 5000;
private static final int RECORDS_PER_COMPONENT = 500;
private static final int DATASET_ID = 101;
- private static final DataverseName DATAVERSE_NAME = DataverseName.createSinglePartName("TestDV");
+ private static final String DATAVERSE_NAME = "TestDV";
private static final String DATASET_NAME = "TestDS";
private static final String INDEX_NAME = "TestIdx";
private static final String DATA_TYPE_NAME = "DUMMY";
@@ -153,13 +153,14 @@
@Before
public void createIndex() throws Exception {
+ DataverseName dvName = DataverseName.createSinglePartName(DATAVERSE_NAME);
List<List<String>> partitioningKeys = new ArrayList<>();
partitioningKeys.add(Collections.singletonList("key"));
- dataset = new TestDataset(DATAVERSE_NAME, DATASET_NAME, DATAVERSE_NAME, DATA_TYPE_NAME, NODE_GROUP_NAME,
+ dataset = new TestDataset(dvName, DATASET_NAME, dvName, DATA_TYPE_NAME, NODE_GROUP_NAME,
NoMergePolicyFactory.NAME, null, new InternalDatasetDetails(null, PartitioningStrategy.HASH,
partitioningKeys, null, null, null, false, null, null),
null, DatasetType.INTERNAL, DATASET_ID, 0);
- secondaryIndex = new Index(DATAVERSE_NAME, DATASET_NAME, INDEX_NAME, INDEX_TYPE, INDEX_FIELD_NAMES,
+ secondaryIndex = new Index(dvName, DATASET_NAME, INDEX_NAME, INDEX_TYPE, INDEX_FIELD_NAMES,
INDEX_FIELD_INDICATORS, INDEX_FIELD_TYPES, false, false, false, 0);
taskCtxs = new IHyracksTaskContext[NUM_PARTITIONS];
primaryIndexDataflowHelpers = new IIndexDataflowHelper[NUM_PARTITIONS];
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/SearchCursorComponentSwitchTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/SearchCursorComponentSwitchTest.java
index a9e86cb..24379a3 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/SearchCursorComponentSwitchTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/SearchCursorComponentSwitchTest.java
@@ -88,7 +88,7 @@
private static final int TOTAL_NUM_OF_RECORDS = 2000;
private static final int RECORDS_PER_COMPONENT = 1000;
private static final int DATASET_ID = 101;
- private static final DataverseName DATAVERSE_NAME = DataverseName.createSinglePartName("TestDV");
+ private static final String DATAVERSE_NAME = "TestDV";
private static final String DATASET_NAME = "TestDS";
private static final String DATA_TYPE_NAME = "DUMMY";
private static final String NODE_GROUP_NAME = "DEFAULT";
@@ -122,9 +122,10 @@
@Before
public void createIndex() throws Exception {
+ DataverseName dvName = DataverseName.createSinglePartName(DATAVERSE_NAME);
List<List<String>> partitioningKeys = new ArrayList<>();
partitioningKeys.add(Collections.singletonList("key"));
- dataset = new TestDataset(DATAVERSE_NAME, DATASET_NAME, DATAVERSE_NAME, DATA_TYPE_NAME, NODE_GROUP_NAME,
+ dataset = new TestDataset(dvName, DATASET_NAME, dvName, DATA_TYPE_NAME, NODE_GROUP_NAME,
NoMergePolicyFactory.NAME, null, new InternalDatasetDetails(null, PartitioningStrategy.HASH,
partitioningKeys, null, null, null, false, null, null),
null, DatasetType.INTERNAL, DATASET_ID, 0);
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/StorageTestUtils.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/StorageTestUtils.java
index 3ef1e62..ec778ed 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/StorageTestUtils.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/StorageTestUtils.java
@@ -42,6 +42,7 @@
import org.apache.asterix.common.context.PrimaryIndexOperationTracker;
import org.apache.asterix.common.dataflow.LSMInsertDeleteOperatorNodePushable;
import org.apache.asterix.common.exceptions.ACIDException;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.file.StorageComponentProvider;
import org.apache.asterix.metadata.entities.Dataset;
@@ -85,18 +86,26 @@
public static final int TOTAL_NUM_OF_RECORDS = 10000;
public static final int RECORDS_PER_COMPONENT = 1000;
public static final int DATASET_ID = 101;
- public static final DataverseName DATAVERSE_NAME = DataverseName.createSinglePartName("TestDV");
+ public static final String DATAVERSE_NAME = "TestDV";
public static final String DATASET_NAME = "TestDS";
public static final String DATA_TYPE_NAME = "DUMMY";
public static final String NODE_GROUP_NAME = "DEFAULT";
public static final StorageComponentProvider STORAGE_MANAGER = new StorageComponentProvider();
public static final List<List<String>> PARTITIONING_KEYS =
new ArrayList<>(Collections.singletonList(Collections.singletonList(RECORD_TYPE.getFieldNames()[0])));
- public static final TestDataset DATASET =
- new TestDataset(DATAVERSE_NAME, DATASET_NAME, DATAVERSE_NAME, DATA_TYPE_NAME, NODE_GROUP_NAME,
+ public static final TestDataset DATASET;
+
+ static {
+ try {
+ DataverseName dvName = DataverseName.createSinglePartName(DATAVERSE_NAME);
+ DATASET = new TestDataset(dvName, DATASET_NAME, dvName, DATA_TYPE_NAME, NODE_GROUP_NAME,
NoMergePolicyFactory.NAME, null, new InternalDatasetDetails(null, PartitioningStrategy.HASH,
PARTITIONING_KEYS, null, null, null, false, null, null),
null, DatasetType.INTERNAL, DATASET_ID, 0);
+ } catch (AsterixException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
private StorageTestUtils() {
}
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerTest.java
index eed9ae1..b0e2046 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerTest.java
@@ -175,22 +175,21 @@
public void testInvalidCharacters() throws Exception {
TestCaseContext.OutputFormat cleanJson = TestCaseContext.OutputFormat.CLEAN_JSON;
- List<DataverseName> dvNameBadCharsList = Arrays.asList(
+ List<List<String>> dvNameBadCharsList = Arrays.asList(
// #1. nul characters
- DataverseName.createSinglePartName("abc\u0000def"),
+ Collections.singletonList("abc\u0000def"),
// #2. leading whitespace
- DataverseName.createSinglePartName(" abcdef"),
+ Collections.singletonList(" abcdef"),
// #3. file separator
- DataverseName.createSinglePartName("abc" + File.separatorChar + "def"),
+ Collections.singletonList("abc" + File.separatorChar + "def"),
// #4. single-part starting with ^
- DataverseName.createSinglePartName(StoragePathUtil.DATAVERSE_CONTINUATION_MARKER + "abcdef"),
+ Collections.singletonList(StoragePathUtil.DATAVERSE_CONTINUATION_MARKER + "abcdef"),
// #5. multi-part w/ first part starting with ^
- DataverseName
- .create(Arrays.asList(StoragePathUtil.DATAVERSE_CONTINUATION_MARKER + "abcdef", "abcdef")));
+ Arrays.asList(StoragePathUtil.DATAVERSE_CONTINUATION_MARKER + "abcdef", "abcdef"));
ErrorCode invalidNameErrCode = ErrorCode.INVALID_DATABASE_OBJECT_NAME;
- for (DataverseName dvNameOk : dvNameBadCharsList) {
- String sql = String.format("create dataverse %s;", dvNameOk);
+ for (List<String> dvName : dvNameBadCharsList) {
+ String sql = String.format("create dataverse `%s`;", StringUtils.join(dvName, "`.`"));
try {
testExecutor.executeSqlppUpdateOrDdl(sql, cleanJson);
Assert.fail("Expected failure: " + invalidNameErrCode);
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerWindowsOsTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerWindowsOsTest.java
index b9f25e1..20ea90a 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerWindowsOsTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataManagerWindowsOsTest.java
@@ -24,7 +24,6 @@
import org.apache.asterix.api.common.AsterixHyracksIntegrationUtil;
import org.apache.asterix.common.config.GlobalConfig;
import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.test.common.TestExecutor;
import org.apache.asterix.testframework.context.TestCaseContext;
import org.apache.commons.lang3.SystemUtils;
@@ -60,21 +59,21 @@
public void testInvalidCharacters() throws Exception {
TestCaseContext.OutputFormat cleanJson = TestCaseContext.OutputFormat.CLEAN_JSON;
- List<DataverseName> dvNameBadCharsList = new ArrayList<>();
+ List<String> dvNameBadCharsList = new ArrayList<>();
for (char c = 0; c <= 0x1F; c++) {
dvNameBadCharsList.add(badCharName(c));
}
dvNameBadCharsList.add(badCharName('\u007f'));
- dvNameBadCharsList.add(badCharName('\\'));
+ dvNameBadCharsList.add(badCharName("\\\\"));
dvNameBadCharsList.add(badCharName('/'));
dvNameBadCharsList.add(badCharName('>'));
dvNameBadCharsList.add(badCharName('\n'));
dvNameBadCharsList.add(badCharName('|'));
ErrorCode invalidNameErrCode = ErrorCode.INVALID_DATABASE_OBJECT_NAME;
- for (DataverseName dvNameOk : dvNameBadCharsList) {
- String sql = String.format("create dataverse %s;", dvNameOk);
+ for (String dvName : dvNameBadCharsList) {
+ String sql = String.format("create dataverse `%s`;", dvName);
try {
testExecutor.executeSqlppUpdateOrDdl(sql, cleanJson);
Assert.fail("Expected failure: " + invalidNameErrCode);
@@ -86,7 +85,12 @@
}
@NotNull
- protected DataverseName badCharName(char c) {
- return DataverseName.createSinglePartName("abc" + c + "def");
+ protected String badCharName(char c) {
+ return badCharName(String.valueOf(c));
+ }
+
+ @NotNull
+ protected String badCharName(String s) {
+ return "abc" + s + "def";
}
}
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/storage/IndexDropOperatorNodePushableTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/storage/IndexDropOperatorNodePushableTest.java
index 5bacd41..3624a33 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/storage/IndexDropOperatorNodePushableTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/storage/IndexDropOperatorNodePushableTest.java
@@ -71,7 +71,7 @@
private static final int[] KEY_INDEXES = { 0 };
private static final List<Integer> KEY_INDICATORS_LIST = Arrays.asList(new Integer[] { Index.RECORD_INDICATOR });
private static final int DATASET_ID = 101;
- private static final DataverseName DATAVERSE_NAME = DataverseName.createSinglePartName("TestDV");
+ private static final String DATAVERSE_NAME = "TestDV";
private static final String DATASET_NAME = "TestDS";
private static final String DATA_TYPE_NAME = "DUMMY";
private static final String NODE_GROUP_NAME = "DEFAULT";
@@ -102,9 +102,10 @@
try {
nc.init();
StorageComponentProvider storageManager = new StorageComponentProvider();
+ DataverseName dvName = DataverseName.createSinglePartName(DATAVERSE_NAME);
List<List<String>> partitioningKeys = new ArrayList<>();
partitioningKeys.add(Collections.singletonList("key"));
- Dataset dataset = new Dataset(DATAVERSE_NAME, DATASET_NAME, DATAVERSE_NAME, DATA_TYPE_NAME, NODE_GROUP_NAME,
+ Dataset dataset = new Dataset(dvName, DATASET_NAME, dvName, DATA_TYPE_NAME, NODE_GROUP_NAME,
NoMergePolicyFactory.NAME, null,
new InternalDatasetDetails(null, InternalDatasetDetails.PartitioningStrategy.HASH, partitioningKeys,
null, null, null, false, null, null),
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.3.ddl.sqlpp
index fcd7cb1..2ec7e87 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.3.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.3.ddl.sqlpp
@@ -21,4 +21,9 @@
* Invalid dataverse name in CREATE DATASET -> Error
*/
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
create dataset ` invalid`.a(id int not unknown) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.4.ddl.sqlpp
index dc10acd..91d4ec5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.4.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.4.ddl.sqlpp
@@ -17,4 +17,13 @@
* under the License.
*/
+/*
+ * Invalid dataverse name in CREATE DATASET -> Error
+ */
+
drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create dataset `a/b`.a(id int not unknown) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.5.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.5.ddl.sqlpp
new file mode 100644
index 0000000..7a9926f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataset-name/invalid-dataset-name.5.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid dataverse name in DROP DATASET -> Error
+ */
+
+drop dataverse c.d if exists;
+create dataverse c.d;
+
+use c.d;
+
+create dataset e(id int not unknown) primary key id;
+
+drop dataset `c/d`.e;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataverse-name/invalid-dataverse-name.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataverse-name/invalid-dataverse-name.6.ddl.sqlpp
new file mode 100644
index 0000000..84a5205
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataverse-name/invalid-dataverse-name.6.ddl.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.
+ */
+
+/*
+ * Empty dataverse name in DROP -> Error
+ */
+
+drop dataverse ``;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataverse-name/invalid-dataverse-name.7.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataverse-name/invalid-dataverse-name.7.ddl.sqlpp
new file mode 100644
index 0000000..ad941fd
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-dataverse-name/invalid-dataverse-name.7.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid dataverse name in DROP -> Error
+ */
+
+drop dataverse a.b if exists;
+create dataverse a.b;
+
+drop dataverse `a/b`;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.4.ddl.sqlpp
index dc10acd..1cf4ada 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.4.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.4.ddl.sqlpp
@@ -17,4 +17,24 @@
* under the License.
*/
+/*
+ * Invalid dataverse name in CREATE FEED -> Error
+ */
+
drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create type Tweet as closed
+{
+ id: int64
+};
+
+create feed `a/b`.a with {
+ "adapter-name" : "socket_adapter",
+ "sockets" : "127.0.0.1:10001",
+ "address-type" : "IP",
+ "type-name" : "Tweet",
+ "format" : "adm"
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.5.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.5.ddl.sqlpp
new file mode 100644
index 0000000..226850e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-name/invalid-feed-name.5.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid dataverse name in DROP FEED -> Error
+ */
+
+drop dataverse c.d if exists;
+create dataverse c.d;
+
+use c.d;
+
+create type Tweet as closed
+{
+ id: int64
+};
+
+create feed e with {
+ "adapter-name" : "socket_adapter",
+ "sockets" : "127.0.0.1:10001",
+ "address-type" : "IP",
+ "type-name" : "Tweet",
+ "format" : "adm"
+};
+
+drop feed `c/d`.e;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.3.ddl.sqlpp
index dc10acd..44b1163 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.3.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.3.ddl.sqlpp
@@ -17,4 +17,14 @@
* under the License.
*/
+/*
+ * Invalid feed policy name -> Error
+ */
+
drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create ingestion policy `a/b` from path 'data/feed-policy/policy.properties'
+ definition 'someString';
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.4.ddl.sqlpp
new file mode 100644
index 0000000..2e88dfe
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-feed-policy-name/invalid-feed-policy-name.4.ddl.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid feed policy name in DROP -> Error
+ */
+
+drop dataverse c.d if exists;
+create dataverse c.d;
+
+use c.d;
+
+create ingestion policy e from path 'data/feed-policy/policy.properties'
+ definition 'someString';
+
+drop ingestion policy `c/d`.e;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.3.ddl.sqlpp
index 4799420..b585dcb 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.3.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.3.ddl.sqlpp
@@ -21,4 +21,9 @@
* Invalid dataverse name in CREATE INDEX -> Error
*/
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
create index a on ` invalid`.t1(x);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.4.ddl.sqlpp
index dc10acd..49bd20c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.4.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.4.ddl.sqlpp
@@ -17,4 +17,13 @@
* under the License.
*/
+/*
+ * Invalid dataverse name in CREATE INDEX -> Error
+ */
+
drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create index a on `a/b`.t1(x);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.5.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.5.ddl.sqlpp
new file mode 100644
index 0000000..8e7f6c3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-index-name/invalid-index-name.5.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid dataverse name in DROP INDEX -> Error
+ */
+
+drop dataverse c.d if exists;
+create dataverse c.d;
+
+use c.d;
+
+create dataset e(id int not unknown, v int not unknown) primary key id;
+
+create index i1 on e(v);
+
+drop index `c/d`.e.i1;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.3.ddl.sqlpp
index ed322ef..6666975 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.3.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.3.ddl.sqlpp
@@ -21,6 +21,11 @@
* Invalid dataverse name in CREATE TYPE -> Error
*/
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
create type ` invalid`.a as closed {
id: int
};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.4.ddl.sqlpp
index dc10acd..22b4efb 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.4.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.4.ddl.sqlpp
@@ -17,4 +17,15 @@
* under the License.
*/
+/*
+ * Invalid dataverse name in CREATE TYPE -> Error
+ */
+
drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create type `a/b`.a as closed {
+ id: int
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.5.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.5.ddl.sqlpp
new file mode 100644
index 0000000..c74ae52
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-type-name/invalid-type-name.5.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid dataverse name in DROP TYPE -> Error
+ */
+
+drop dataverse c.d if exists;
+create dataverse c.d;
+
+use c.d;
+
+create type e as closed {
+ id: int
+};
+
+drop type `c/d`.e;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.3.ddl.sqlpp
index 1d85543..4eba639 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.3.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.3.ddl.sqlpp
@@ -21,6 +21,11 @@
* Invalid dataverse name in CREATE FUNCTION -> Error
*/
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
create function ` invalid`.a() {
1
};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.4.ddl.sqlpp
index dc10acd..dd65669 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.4.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.4.ddl.sqlpp
@@ -17,4 +17,15 @@
* under the License.
*/
+/*
+ * Invalid dataverse name in CREATE FUNCTION -> Error
+ */
+
drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create function `a/b`.a() {
+ 1
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.5.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.5.ddl.sqlpp
new file mode 100644
index 0000000..ab33494
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/invalid-udf-name/invalid-udf-name.5.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+/*
+ * Invalid dataverse name in DROP FUNCTION -> Error
+ */
+
+drop dataverse c.d if exists;
+create dataverse c.d;
+
+use c.d;
+
+create function e() {
+ 1
+};
+
+drop function `c/d`.e();
\ No newline at end of file
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 7277c0b..f8f2597 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4033,65 +4033,79 @@
<test-case FilePath="ddl">
<compilation-unit name="invalid-dataverse-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " invalid"</expected-error>
<expected-error>ASX1079: Compilation error: Invalid operation - Cannot create dataverse: asterix</expected-error>
<expected-error>ASX1079: Compilation error: Invalid operation - Cannot create dataverse: algebricks</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "" (in line 24, at column 16)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 27, at column 16)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-dataset-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " invalid"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 29, at column 16)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "c/d" (in line 31, at column 14)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-feed-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " invalid"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 34, at column 13)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "c/d" (in line 42, at column 11)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-feed-policy-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 29, at column 1)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "c/d" (in line 32, at column 23)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-index-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " invalid"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 29, at column 19)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "c/d" (in line 33, at column 12)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-nodegroup-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-type-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " invalid"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 29, at column 13)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "c/d" (in line 33, at column 11)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
<compilation-unit name="invalid-udf-name">
<output-dir compare="Text">none</output-dir>
- <expected-error>ASX1115: Invalid name for a database object: "<empty>"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: ""</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " a"</expected-error>
<expected-error>ASX1115: Invalid name for a database object: " invalid"</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "a/b" (in line 29, at column 17)</expected-error>
+ <expected-error>ASX1115: Invalid name for a database object: "c/d" (in line 33, at column 15)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
index 1efdd42..f3b1605 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/functions/FunctionSignature.java
@@ -21,6 +21,7 @@
import java.io.Serializable;
import java.util.Objects;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -132,7 +133,11 @@
case AlgebricksBuiltinFunctions.ALGEBRICKS_NS:
return FunctionConstants.ALGEBRICKS_DV;
default:
- return DataverseName.createFromCanonicalForm(dataverseCanonicalName);
+ try {
+ return DataverseName.createFromCanonicalForm(dataverseCanonicalName);
+ } catch (AsterixException e) {
+ throw new IllegalArgumentException(dataverseCanonicalName);
+ }
}
}
}
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DataverseName.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DataverseName.java
index f943dea..f492fd1 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DataverseName.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DataverseName.java
@@ -24,9 +24,9 @@
import java.util.Collection;
import java.util.List;
import java.util.Objects;
-import java.util.function.BiConsumer;
-import org.apache.commons.lang3.StringUtils;
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
/**
* This class represents a dataverse name.
@@ -36,7 +36,7 @@
* <p>
* Each dataverse name can be encoded into a single string (called a canonical form) by
* {@link #getCanonicalForm()} and decoded back from it with {@link #createFromCanonicalForm(String)}.
- * The canonical form encoding concatenates name parts together with {@link #CANONICAL_FORM_SEPARATOR_CHAR '/'}
+ * The canonical form encoding concatenates name parts together with {@link #CANONICAL_FORM_PART_SEPARATOR '/'}
* character.
* <p>
* E.g. the canonical form for a dataverse name {@code ["a", "b", "c"]} is {@code "a/b/c"}
@@ -58,9 +58,9 @@
*/
public final class DataverseName implements Serializable, Comparable<DataverseName> {
- private static final long serialVersionUID = 2L;
+ private static final long serialVersionUID = 3L;
- public static final char CANONICAL_FORM_SEPARATOR_CHAR = '/';
+ public static final String CANONICAL_FORM_PART_SEPARATOR = "/";
public static final char DISPLAY_FORM_SEPARATOR_CHAR = '.';
@@ -68,25 +68,12 @@
private static final char DISPLAY_FORM_ESCAPE_CHAR = '\\';
- private static final char[] CANONICAL_FORM_SEPARATOR_AND_ESCAPE_CHARS =
- new char[] { CANONICAL_FORM_SEPARATOR_CHAR };
-
- private final boolean isMultiPart;
-
private final String canonicalForm;
private transient volatile String displayForm;
- private DataverseName(String canonicalForm, boolean isMultiPart) {
+ private DataverseName(String canonicalForm) {
this.canonicalForm = Objects.requireNonNull(canonicalForm);
- this.isMultiPart = isMultiPart;
- }
-
- /**
- * Returns whether this dataverse name contains multiple name parts or not.
- */
- public boolean isMultiPart() {
- return isMultiPart;
}
/**
@@ -104,7 +91,7 @@
* Returns a new list containing dataverse name parts
*/
public List<String> getParts() {
- List<String> parts = new ArrayList<>(isMultiPart ? 4 : 1);
+ List<String> parts = new ArrayList<>(4);
getParts(parts);
return parts;
}
@@ -113,28 +100,32 @@
* Appends dataverse name parts into a given output collection
*/
public void getParts(Collection<? super String> outParts) {
- getPartsFromCanonicalForm(canonicalForm, isMultiPart, outParts);
+ getPartsFromCanonicalFormImpl(canonicalForm, outParts);
}
/**
* Appends dataverse name parts into a given output collection
*/
- public static void getPartsFromCanonicalForm(String canonicalForm, Collection<? super String> outParts) {
- getPartsFromCanonicalForm(canonicalForm, isMultiPartCanonicalForm(canonicalForm), outParts);
- }
-
- /**
- * Appends dataverse name parts into a given output collection
- */
- private static void getPartsFromCanonicalForm(String canonicalForm, boolean isMultiPart,
- Collection<? super String> outParts) {
- if (isMultiPart) {
- decodeCanonicalForm(canonicalForm, DataverseName::addPartToCollection, outParts);
- } else {
- outParts.add(decodeSinglePartNameFromCanonicalForm(canonicalForm));
+ public static void getPartsFromCanonicalForm(String canonicalForm, Collection<? super String> outParts)
+ throws AsterixException {
+ int partCount = getPartsFromCanonicalFormImpl(canonicalForm, outParts);
+ if (partCount <= 0) {
+ throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, canonicalForm);
}
}
+ public int getPartCount() {
+ return getPartCountFromCanonicalFormImpl(canonicalForm);
+ }
+
+ public static int getPartCountFromCanonicalForm(String canonicalForm) throws AsterixException {
+ int partCount = getPartCountFromCanonicalFormImpl(canonicalForm);
+ if (partCount <= 0) {
+ throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, canonicalForm);
+ }
+ return partCount;
+ }
+
/**
* Returns a display form which suitable for error messages, and is a valid SQL++ multi-part identifier.
*/
@@ -154,21 +145,31 @@
}
public void getDisplayForm(StringBuilder out) {
- getDisplayFormFromCanonicalForm(canonicalForm, isMultiPart, out);
+ getDisplayFormFromCanonicalFormImpl(canonicalForm, out);
}
- public static void getDisplayFormFromCanonicalForm(String canonicalForm, StringBuilder out) {
- getDisplayFormFromCanonicalForm(canonicalForm, isMultiPartCanonicalForm(canonicalForm), out);
- }
-
- private static void getDisplayFormFromCanonicalForm(String canonicalForm, boolean isMultiPart, StringBuilder out) {
- if (isMultiPart) {
- decodeCanonicalForm(canonicalForm, DataverseName::addPartToDisplayForm, out);
- } else {
- String singlePart = decodeSinglePartNameFromCanonicalForm(canonicalForm);
- addPartToDisplayForm(singlePart, out);
+ public static void getDisplayFormFromCanonicalForm(String canonicalForm, StringBuilder out)
+ throws AsterixException {
+ int partCount = getDisplayFormFromCanonicalFormImpl(canonicalForm, out);
+ if (partCount <= 0) {
+ throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, canonicalForm);
}
- out.setLength(out.length() - 1); // remove last separator char
+ }
+
+ private static int getPartsFromCanonicalFormImpl(String canonicalForm, Collection<? super String> outParts) {
+ return decodeCanonicalForm(canonicalForm, DataverseName::addPartToCollection, outParts);
+ }
+
+ private static int getPartCountFromCanonicalFormImpl(String canonicalForm) {
+ return decodeCanonicalForm(canonicalForm, null, null);
+ }
+
+ private static int getDisplayFormFromCanonicalFormImpl(String canonicalForm, StringBuilder out) {
+ int partCount = decodeCanonicalForm(canonicalForm, DataverseName::addPartToDisplayForm, out);
+ if (partCount > 0) {
+ out.setLength(out.length() - 1); // remove last separator char
+ }
+ return partCount;
}
@Override
@@ -194,7 +195,7 @@
* Creates a new dataverse name from a given list of name parts.
* Equivalent to {@code create(parts, 0, parts.size())}.
*/
- public static DataverseName create(List<String> parts) {
+ public static DataverseName create(List<String> parts) throws AsterixException {
return create(parts, 0, parts.size());
}
@@ -208,7 +209,7 @@
* @param toIndex
* index to stop at (exclusive, value at that index is not used)
*/
- public static DataverseName create(List<String> parts, int fromIndex, int toIndex) {
+ public static DataverseName create(List<String> parts, int fromIndex, int toIndex) throws AsterixException {
int partCount = toIndex - fromIndex;
return partCount == 1 ? createSinglePartName(parts.get(fromIndex))
: createMultiPartName(parts, fromIndex, toIndex);
@@ -217,18 +218,21 @@
/**
* Creates a new dataverse name from its scalar encoding (canonical form) returned by {@link #getCanonicalForm()}
*/
- public static DataverseName createFromCanonicalForm(String canonicalForm) {
- boolean isMultiPart = isMultiPartCanonicalForm(canonicalForm);
- return new DataverseName(canonicalForm, isMultiPart);
+ public static DataverseName createFromCanonicalForm(String canonicalForm) throws AsterixException {
+ int partCount = getPartCountFromCanonicalFormImpl(canonicalForm);
+ if (partCount <= 0) {
+ throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, canonicalForm);
+ }
+ return new DataverseName(canonicalForm);
}
/**
* Creates a single-part dataverse name.
* Equivalent to {@code create(Collections.singletonList(singlePart))}, but performs faster.
*/
- public static DataverseName createSinglePartName(String singlePart) {
+ public static DataverseName createSinglePartName(String singlePart) throws AsterixException {
String canonicalForm = encodeSinglePartNamePartIntoCanonicalForm(singlePart);
- return new DataverseName(canonicalForm, false);
+ return new DataverseName(canonicalForm);
}
/**
@@ -236,87 +240,90 @@
* Validates that the canonical form of the created dataverse name is the same as its given single name part.
*/
public static DataverseName createBuiltinDataverseName(String singlePart) {
- if (StringUtils.containsAny(singlePart, CANONICAL_FORM_SEPARATOR_AND_ESCAPE_CHARS)) {
- throw new IllegalArgumentException(singlePart);
+ try {
+ return createSinglePartName(singlePart); // 1-part name
+ } catch (AsterixException e) {
+ throw new IllegalArgumentException(e.getMessage(), e);
}
- DataverseName dataverseName = createSinglePartName(singlePart); // 1-part name
- String canonicalForm = dataverseName.getCanonicalForm();
- if (!canonicalForm.equals(singlePart)) {
- throw new IllegalStateException(canonicalForm + "!=" + singlePart);
- }
- return dataverseName;
}
- private static DataverseName createMultiPartName(List<String> parts, int fromIndex, int toIndex) {
+ private static DataverseName createMultiPartName(List<String> parts, int fromIndex, int toIndex)
+ throws AsterixException {
String canonicalForm = encodeMultiPartNameIntoCanonicalForm(parts, fromIndex, toIndex);
- return new DataverseName(canonicalForm, true);
+ return new DataverseName(canonicalForm);
}
- private static String encodeMultiPartNameIntoCanonicalForm(List<String> parts, int fromIndex, int toIndex) {
+ private static String encodeMultiPartNameIntoCanonicalForm(List<String> parts, int fromIndex, int toIndex)
+ throws AsterixException {
Objects.requireNonNull(parts);
int partCount = toIndex - fromIndex;
if (partCount <= 0) {
throw new IllegalArgumentException(fromIndex + "," + toIndex);
}
- StringBuilder sb = new StringBuilder(32);
- for (int i = 0; i < partCount; i++) {
- if (i > 0) {
- sb.append(CANONICAL_FORM_SEPARATOR_CHAR);
- }
- encodePartIntoCanonicalForm(parts.get(fromIndex + i), sb);
+ int canonicalFormLength = (partCount - 1) * CANONICAL_FORM_PART_SEPARATOR.length();
+ for (int i = fromIndex; i < toIndex; i++) {
+ canonicalFormLength += parts.get(i).length();
+ }
+ String sep = "";
+ StringBuilder sb = new StringBuilder(canonicalFormLength);
+ for (int i = fromIndex; i < toIndex; i++) {
+ sb.append(sep);
+ encodePartIntoCanonicalForm(parts.get(i), sb);
+ sep = CANONICAL_FORM_PART_SEPARATOR;
}
return sb.toString();
}
- private static String encodeSinglePartNamePartIntoCanonicalForm(String singlePart) {
- if (StringUtils.indexOfAny(singlePart, CANONICAL_FORM_SEPARATOR_AND_ESCAPE_CHARS) < 0) {
- // no escaping needed
- return singlePart;
- }
- StringBuilder sb = new StringBuilder(singlePart.length() + 4);
- encodePartIntoCanonicalForm(singlePart, sb);
- return sb.toString();
+ private static String encodeSinglePartNamePartIntoCanonicalForm(String singlePart) throws AsterixException {
+ validatePart(singlePart);
+ return singlePart;
}
- private static void encodePartIntoCanonicalForm(String part, StringBuilder out) {
+ private static void encodePartIntoCanonicalForm(String part, StringBuilder out) throws AsterixException {
+ validatePart(part);
out.append(part);
}
- private static <T> void decodeCanonicalForm(String canonicalForm, BiConsumer<CharSequence, T> partConsumer,
+ private static void validatePart(String part) throws AsterixException {
+ if (part.isEmpty() || part.contains(CANONICAL_FORM_PART_SEPARATOR)) {
+ throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, part);
+ }
+ }
+
+ private static <T> int decodeCanonicalForm(String canonicalForm, DataverseNamePartConsumer<T> partConsumer,
T partConsumerArg) {
- int ln = canonicalForm.length();
- StringBuilder sb = new StringBuilder(ln);
- for (int i = 0; i < ln; i++) {
- char c = canonicalForm.charAt(i);
- if (c == CANONICAL_FORM_SEPARATOR_CHAR) {
- partConsumer.accept(sb, partConsumerArg);
- sb.setLength(0);
- } else {
- sb.append(c);
+ int partCount = 0, from = 0, to;
+ while ((to = canonicalForm.indexOf(CANONICAL_FORM_PART_SEPARATOR, from)) > from) {
+ if (partConsumer != null) {
+ partConsumer.accept(canonicalForm, from, to, partConsumerArg);
}
+ partCount++;
+ from = to + CANONICAL_FORM_PART_SEPARATOR.length();
}
- if (sb.length() > 0) {
- partConsumer.accept(sb, partConsumerArg);
+ boolean hasOneMore = from != to && from < canonicalForm.length();
+ if (!hasOneMore) {
+ return 0;
}
+ if (partConsumer != null) {
+ partConsumer.accept(canonicalForm, from, canonicalForm.length(), partConsumerArg);
+ }
+ partCount++;
+ return partCount;
}
- // optimization for a single part name
- private static String decodeSinglePartNameFromCanonicalForm(String canonicalForm) {
- return canonicalForm;
+ @FunctionalInterface
+ private interface DataverseNamePartConsumer<T> {
+ void accept(String canonicalForm, int from, int to, T arg);
}
- private static boolean isMultiPartCanonicalForm(String canonicalForm) {
- return canonicalForm.indexOf(CANONICAL_FORM_SEPARATOR_CHAR) != -1;
+ private static void addPartToCollection(String canonicalForm, int from, int to, Collection<? super String> out) {
+ out.add(canonicalForm.substring(from, to));
}
- private static void addPartToCollection(CharSequence part, Collection<? super String> out) {
- out.add(part.toString());
- }
-
- private static void addPartToDisplayForm(CharSequence part, StringBuilder out) {
+ private static void addPartToDisplayForm(String canonicalForm, int from, int to, StringBuilder out) {
boolean needQuote = false;
- for (int i = 0, ln = part.length(); i < ln; i++) {
- char c = part.charAt(i);
+ for (int i = from; i < to; i++) {
+ char c = canonicalForm.charAt(i);
boolean noQuote = isLetter(c) || c == '_' || (i > 0 && (isDigit(c) || c == '$'));
if (!noQuote) {
needQuote = true;
@@ -326,8 +333,8 @@
if (needQuote) {
out.append(DISPLAY_FORM_QUOTE_CHAR);
}
- for (int i = 0, ln = part.length(); i < ln; i++) {
- char c = part.charAt(i);
+ for (int i = from; i < to; i++) {
+ char c = canonicalForm.charAt(i);
if (c == DISPLAY_FORM_ESCAPE_CHAR || c == DISPLAY_FORM_QUOTE_CHAR) {
out.append(DISPLAY_FORM_ESCAPE_CHAR);
}
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/storage/ResourceReference.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/storage/ResourceReference.java
index 94a5f2a..ebf212b 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/storage/ResourceReference.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/storage/ResourceReference.java
@@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.List;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.common.utils.StorageConstants;
import org.apache.asterix.common.utils.StoragePathUtil;
@@ -67,14 +68,22 @@
String probablyPartition = tokens[--offset];
if (dvParts.isEmpty()) {
// root/partition/dataverse/dataset/rebalanceCount/index/fileName
- dataverse = DataverseName.createSinglePartName(dvPart);
+ try {
+ dataverse = DataverseName.createSinglePartName(dvPart);
+ } catch (AsterixException e) {
+ throw new IllegalArgumentException("unable to parse path: '" + path + "'!", e);
+ }
partition = probablyPartition;
root = tokens[--offset];
} else if (probablyPartition.startsWith(StorageConstants.PARTITION_DIR_PREFIX)) {
// root/partition/dataverse_p1/^dataverse_p2/.../^dataverse_pn/dataset/rebalanceCount/index/fileName
dvParts.add(dvPart);
Collections.reverse(dvParts);
- dataverse = DataverseName.create(dvParts);
+ try {
+ dataverse = DataverseName.create(dvParts);
+ } catch (AsterixException e) {
+ throw new IllegalArgumentException("unable to parse path: '" + path + "'!", e);
+ }
partition = probablyPartition;
root = tokens[--offset];
} else if (dvPart.startsWith(StorageConstants.PARTITION_DIR_PREFIX)) {
@@ -82,8 +91,12 @@
if (dvParts.size() != 1) {
throw new IllegalArgumentException("unable to parse path: '" + path + "'!");
}
- dataverse =
- DataverseName.createSinglePartName(StoragePathUtil.DATAVERSE_CONTINUATION_MARKER + dvParts.get(0));
+ try {
+ dataverse = DataverseName
+ .createSinglePartName(StoragePathUtil.DATAVERSE_CONTINUATION_MARKER + dvParts.get(0));
+ } catch (AsterixException e) {
+ throw new IllegalArgumentException("unable to parse path: '" + path + "'!", e);
+ }
LOGGER.info("legacy dataverse starting with ^ found: '{}'; this is not supported for new dataverses",
dataverse);
partition = dvPart;
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/common/metadata/DataverseNameTest.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/common/metadata/DataverseNameTest.java
index 75b3989..faf1960 100644
--- a/asterixdb/asterix-common/src/test/java/org/apache/asterix/common/metadata/DataverseNameTest.java
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/common/metadata/DataverseNameTest.java
@@ -25,8 +25,9 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.function.Supplier;
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.commons.collections4.ListUtils;
import org.apache.hyracks.algebricks.common.utils.Triple;
import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
@@ -49,10 +50,6 @@
// dataverse for Asterix functions
ASTERIX_NS);
- private static final List<String> TEST_BUILTIN_DATAVERSE_INVALID_NAME_PARAMS = Arrays.asList(
- // separator character is not allowed
- "a/b");
-
private static final List<Triple<String, String, String>> TEST_SINGLE_PART_NAME_PARAMS = Arrays.asList(
// <1-part-name, canonical-form, display-form>
new Triple<>("abz", "abz", "abz"),
@@ -86,6 +83,15 @@
// with display form escape character
new Triple<>(Arrays.asList("a\\b", "c\\d"), "a\\b/c\\d", "`a\\\\b`.`c\\\\d`"));
+ private static final List<String> TEST_INVALID_SINGLE_PART_PARAMS =
+ Arrays.asList("", "/", "//", "///", "a/", "a/b", "a/b/");
+
+ private static final List<List<String>> TEST_INVALID_MULTI_PART_PARAMS =
+ Arrays.asList(Arrays.asList("", ""), Arrays.asList("a", "", "d"), Arrays.asList("a", "b/c", "d"));
+
+ private static final List<String> TEST_INVALID_CANONICAL_FORM_PARAMS =
+ Arrays.asList("", "/", "//", "///", "/a", "a/", "a/b/");
+
@Test
public void testBuiltinDataverseName() throws Exception {
for (String p : TEST_BUILTIN_DATAVERSE_NAME_PARAMS) {
@@ -161,8 +167,7 @@
protected void testDataverseNameImpl(DataverseName dataverseName, List<String> parts, String expectedCanonicalForm,
String expectedDisplayForm) throws Exception {
- boolean isMultiPart = parts.size() > 1;
- Assert.assertEquals("is-multipart", isMultiPart, dataverseName.isMultiPart());
+ Assert.assertEquals("get-part-count", parts.size(), dataverseName.getPartCount());
// test getParts()
Assert.assertArrayEquals("get-parts-0", parts.toArray(), dataverseName.getParts().toArray());
@@ -184,7 +189,7 @@
}
@Test
- public void testCompare() {
+ public void testCompare() throws Exception {
List<DataverseName> dvList =
Arrays.asList(DataverseName.createSinglePartName("a"), DataverseName.create(Arrays.asList("a", "a")),
DataverseName.createSinglePartName("aa"), DataverseName.createSinglePartName("b"));
@@ -205,11 +210,7 @@
@Test
public void testExceptions() {
- // 1. Invalid names for builtin dataverses
- for (String p : TEST_BUILTIN_DATAVERSE_INVALID_NAME_PARAMS) {
- testInvalidBuiltinDataverseNameImpl(p);
- }
- // 2. NullPointerException
+ // 1. NullPointerException
testRuntimeException(() -> DataverseName.create(null), NullPointerException.class);
testRuntimeException(() -> DataverseName.create(null, 0, 0), NullPointerException.class);
testRuntimeException(() -> DataverseName.create(null, 0, 1), NullPointerException.class);
@@ -218,19 +219,61 @@
testRuntimeException(() -> DataverseName.createBuiltinDataverseName(null), NullPointerException.class);
testRuntimeException(() -> DataverseName.createFromCanonicalForm(null), NullPointerException.class);
testRuntimeException(() -> DataverseName.create(Collections.singletonList(null)), NullPointerException.class);
- // 3. IndexOutOfBoundsException
+
+ // 2. IndexOutOfBoundsException
testRuntimeException(() -> DataverseName.create(Collections.emptyList(), 0, 1),
IndexOutOfBoundsException.class);
testRuntimeException(() -> DataverseName.create(Collections.emptyList(), 0, 2),
IndexOutOfBoundsException.class);
- // 4. IllegalArgumentException
+
+ // 3.1 IllegalArgumentException
testRuntimeException(() -> DataverseName.create(Collections.emptyList()), IllegalArgumentException.class);
testRuntimeException(() -> DataverseName.create(Collections.emptyList(), 0, 0), IllegalArgumentException.class);
testRuntimeException(() -> DataverseName.create(Arrays.asList("a", "b", "c"), 2, 1),
IllegalArgumentException.class);
+
+ // 3.2 IllegalArgumentException -> invalid builtin dataverse name
+ for (String invalidForm : TEST_INVALID_SINGLE_PART_PARAMS) {
+ testRuntimeException(() -> DataverseName.createBuiltinDataverseName(invalidForm),
+ IllegalArgumentException.class);
+ }
+
+ // 4.1 ErrorCode.INVALID_DATABASE_OBJECT_NAME (invalid single part name)
+ for (String invalidForm : TEST_INVALID_SINGLE_PART_PARAMS) {
+ testAsterixException(invalidForm, DataverseName::createSinglePartName,
+ ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ }
+
+ // 4.2 ErrorCode.INVALID_DATABASE_OBJECT_NAME (invalid multi part name)
+ for (List<String> invalidForm : TEST_INVALID_MULTI_PART_PARAMS) {
+ testAsterixException(invalidForm, DataverseName::create, ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ }
+ testAsterixException(Arrays.asList("a", "", "d"), (arg) -> DataverseName.create(arg, 0, 2),
+ ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ testAsterixException(Arrays.asList("a", "b/c", "d"), (arg) -> DataverseName.create(arg, 0, 2),
+ ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+
+ // 4.3 ErrorCode.INVALID_DATABASE_OBJECT_NAME (invalid canonical form)
+ for (String invalidForm : TEST_INVALID_CANONICAL_FORM_PARAMS) {
+ testAsterixException(invalidForm, DataverseName::createFromCanonicalForm,
+ ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ testAsterixException(invalidForm, DataverseName::getPartCountFromCanonicalForm,
+ ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ testAsterixException(invalidForm, this::getPartsFromCanonicalForm, ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ testAsterixException(invalidForm, this::getDisplayFormFromCanonicalForm,
+ ErrorCode.INVALID_DATABASE_OBJECT_NAME);
+ }
}
- private <E extends RuntimeException> void testRuntimeException(Supplier<DataverseName> supplier,
+ private interface DataverseNameSupplier<R> {
+ R get() throws AsterixException;
+ }
+
+ private interface DataverseNameFunction<V, R> {
+ R get(V value) throws AsterixException;
+ }
+
+ private <R, E extends RuntimeException> void testRuntimeException(DataverseNameSupplier<R> supplier,
Class<E> exceptionClass) {
try {
supplier.get();
@@ -245,15 +288,38 @@
throw ae;
}
}
+ } catch (AsterixException e) {
+ Assert.fail("Expected to catch " + exceptionClass.getName() + ", but caught " + e.getClass().getName());
}
}
- private void testInvalidBuiltinDataverseNameImpl(String singlePart) {
+ private <V, R> void testAsterixException(V supplierArg, DataverseNameFunction<V, R> supplier, ErrorCode errorCode) {
try {
- DataverseName.createBuiltinDataverseName(singlePart);
- Assert.fail(singlePart);
- } catch (IllegalArgumentException e) {
- // this error is expected
+ supplier.get(supplierArg);
+ Assert.fail(
+ "Did not get expected exception with error code " + errorCode.intValue() + " for " + supplierArg);
+ } catch (AsterixException e) {
+ if (e.getErrorCode() != errorCode.intValue()) {
+ try {
+ Assert.fail("Expected to catch exception with error code " + errorCode.intValue()
+ + ", but caught exceptionn with error code " + e.getErrorCode());
+ } catch (AssertionError ae) {
+ ae.initCause(e);
+ throw ae;
+ }
+ }
}
}
+
+ private List<String> getPartsFromCanonicalForm(String canonicalForm) throws AsterixException {
+ ArrayList<String> list = new ArrayList<>();
+ DataverseName.getPartsFromCanonicalForm(canonicalForm, list);
+ return list;
+ }
+
+ private String getDisplayFormFromCanonicalForm(String canonicalForm) throws AsterixException {
+ StringBuilder sb = new StringBuilder();
+ DataverseName.getDisplayFormFromCanonicalForm(canonicalForm, sb);
+ return sb.toString();
+ }
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
index dce5503..e54b729 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
@@ -282,7 +282,13 @@
return FileVisitResult.SKIP_SUBTREE;
}
String candidateLib = tokens[currToken];
- DataverseName candidateDv = DataverseName.create(dvParts);
+ DataverseName candidateDv;
+ try {
+ candidateDv = DataverseName.create(dvParts);
+ } catch (AsterixException e) {
+ // shouldn't happen
+ throw HyracksDataException.create(e);
+ }
FileReference candidateLibPath = findLibraryRevDir(candidateDv, candidateLib);
if (candidateLibPath != null) {
libs.add(new Pair<>(candidateDv, candidateLib));
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
index 4beb932..2c29e60 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
@@ -201,7 +201,7 @@
}
}
- public static DataverseName getDatasetDataverse(Map<String, String> configuration) {
+ public static DataverseName getDatasetDataverse(Map<String, String> configuration) throws AsterixException {
return DataverseName.createFromCanonicalForm(configuration.get(ExternalDataConstants.KEY_DATASET_DATAVERSE));
}
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java
index 2c64ce3..30d3266 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java
@@ -31,6 +31,7 @@
import org.apache.asterix.active.ActiveRuntimeId;
import org.apache.asterix.active.EntityId;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.memory.ConcurrentFramePool;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.external.feed.dataflow.FeedRuntimeInputHandler;
@@ -60,7 +61,7 @@
private static final int DEFAULT_FRAME_SIZE = 32768;
private static final int NUM_FRAMES = 128;
private static final long FEED_MEM_BUDGET = DEFAULT_FRAME_SIZE * NUM_FRAMES;
- private static final DataverseName DATAVERSE = DataverseName.createSinglePartName("dataverse");
+ private static final String DATAVERSE_NAME = "dataverse";
private static final String DATASET = "dataset";
private static final String FEED = "feed";
private static final String NODE_ID = "NodeId";
@@ -69,9 +70,10 @@
private volatile static HyracksDataException cause = null;
private FeedRuntimeInputHandler createInputHandler(IHyracksTaskContext ctx, IFrameWriter writer,
- FeedPolicyAccessor fpa, ConcurrentFramePool framePool) throws HyracksDataException {
+ FeedPolicyAccessor fpa, ConcurrentFramePool framePool) throws HyracksDataException, AsterixException {
+ DataverseName dvName = DataverseName.createSinglePartName(DATAVERSE_NAME);
FrameTupleAccessor fta = Mockito.mock(FrameTupleAccessor.class);
- EntityId feedId = new EntityId(FeedUtils.FEED_EXTENSION_NAME, DATAVERSE, FEED);
+ EntityId feedId = new EntityId(FeedUtils.FEED_EXTENSION_NAME, dvName, FEED);
FeedConnectionId connectionId = new FeedConnectionId(feedId, DATASET);
ActiveRuntimeId runtimeId = new ActiveRuntimeId(feedId, FeedRuntimeType.COLLECT.toString(), 0);
return new FeedRuntimeInputHandler(ctx, connectionId, runtimeId, writer, fpa, fta, framePool);
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
index 50a4bf2..ded91af 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
@@ -31,6 +31,7 @@
import java.util.Set;
import java.util.function.BiFunction;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.common.functions.FunctionConstants;
@@ -326,8 +327,12 @@
if (dataverseNameArg == null) {
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, "Invalid argument to dataset()");
}
- DataverseName dataverseName = DataverseName.createFromCanonicalForm(dataverseNameArg);
-
+ DataverseName dataverseName;
+ try {
+ dataverseName = DataverseName.createFromCanonicalForm(dataverseNameArg);
+ } catch (AsterixException e) {
+ throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, e, "Invalid argument to dataset()");
+ }
String datasetName = argExtractFunction.apply(datasetFnArgs.get(startPos + 1));
if (datasetName == null) {
throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, "Invalid argument to dataset()");
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 8e8cfc7..bbf1a46 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
@@ -25,6 +25,7 @@
import java.util.Map;
import java.util.Set;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.common.functions.FunctionSignature;
@@ -91,7 +92,13 @@
} else {
String dataverseNamePart =
SqlppVariableUtil.toUserDefinedVariableName(leadingVarExpr.getVar().getValue()).getValue();
- DataverseName dataverseName = DataverseName.createSinglePartName(dataverseNamePart); // 1-part name
+ DataverseName dataverseName; // 1-part name
+ try {
+ dataverseName = DataverseName.createSinglePartName(dataverseNamePart);
+ } catch (AsterixException e) {
+ throw new CompilationException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, fa.getSourceLocation(),
+ dataverseNamePart);
+ }
String datasetName = fa.getIdent().getValue();
CallExpr datasetExpr = resolveAsDataset(dataverseName, datasetName, parent, leadingVarExpr);
if (datasetExpr != null) {
@@ -110,7 +117,13 @@
if (resolveAsVariableReference(topVarExpr)) {
return fa;
} else {
- DataverseName dataverseName = DataverseName.create(dataverseNameParts);
+ DataverseName dataverseName;
+ try {
+ dataverseName = DataverseName.create(dataverseNameParts);
+ } catch (AsterixException e) {
+ throw new CompilationException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, fa.getSourceLocation(),
+ dataverseNameParts.toString());
+ }
String datasetName = fa.getIdent().getValue();
CallExpr datasetExpr = resolveAsDataset(dataverseName, datasetName, parent, topVarExpr);
if (datasetExpr != null) {
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index d8fd123..c4c86f4 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -67,6 +67,7 @@
import org.apache.asterix.common.annotations.UndeclaredFieldsDataGen;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.config.DatasetConfig.IndexType;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.common.exceptions.WarningCollector;
@@ -374,7 +375,7 @@
return parseImpl(new ParseFunction<List<String>>() {
@Override
public List<String> parse() throws ParseException {
- return SQLPPParser.this.MultipartIdentifier();
+ return SQLPPParser.this.MultipartIdentifier().first;
}
});
}
@@ -420,7 +421,15 @@
try {
return parseFunction.parse();
} catch (SqlppParseException e) {
- throw new CompilationException(ErrorCode.PARSE_ERROR, e.getSourceLocation(), LogRedactionUtil.userData(getMessage(e)));
+ if (e.getCause() instanceof AlgebricksException) {
+ AlgebricksException cause = (AlgebricksException) e.getCause();
+ if (cause.getError().isPresent() && cause.getError().get() instanceof ErrorCode) {
+ throw new CompilationException((ErrorCode) cause.getError().get(), e.getSourceLocation(),
+ cause.getParams());
+ }
+ }
+ throw new CompilationException(ErrorCode.PARSE_ERROR, e.getSourceLocation(),
+ LogRedactionUtil.userData(getMessage(e)));
} catch (ParseException e) {
throw new CompilationException(ErrorCode.PARSE_ERROR, LogRedactionUtil.userData(getMessage(e)));
} catch (Error e) {
@@ -669,6 +678,17 @@
throw new SqlppParseException(expr.getSourceLocation(), errorPrefix + " should be an INTEGER");
}
}
+
+ private DataverseName createDataverseName(List<String> parts, int fromIndex, int toIndex, Token startToken)
+ throws SqlppParseException {
+ try {
+ return DataverseName.create(parts, fromIndex, toIndex);
+ } catch (AsterixException e) {
+ SqlppParseException pe = new SqlppParseException(getSourceLocation(startToken), e.getMessage());
+ pe.initCause(e);
+ throw pe;
+ }
+ }
}
PARSER_END(SQLPPParser)
@@ -745,12 +765,12 @@
DataverseDecl DataverseDeclaration() throws ParseException:
{
Token startToken = null;
- List<String> dvName = null;
+ DataverseName dvName = null;
}
{
- <USE> { startToken = token; } dvName = MultipartIdentifier()
+ <USE> { startToken = token; } dvName = DataverseName()
{
- defaultDataverse = DataverseName.create(dvName);
+ defaultDataverse = dvName;
DataverseDecl dvDecl = new DataverseDecl(defaultDataverse);
return addSourceLocation(dvDecl, startToken);
}
@@ -1187,14 +1207,14 @@
Pair<List<List<String>>, List<Pair<List<String>, IndexedTypeExpression>>> IndexedElementUnnestSelectBody()
throws ParseException:
{
- List<String> path = null;
+ Triple<List<String>, Token, Token> path = null;
IndexedTypeExpression type = null;
List<List<String>> unnestList = new ArrayList();
List<Pair<List<String>, IndexedTypeExpression>> projectList = new ArrayList();
}
{
- path = MultipartIdentifier() { unnestList.add(path); }
- ( <UNNEST> path = MultipartIdentifier() { unnestList.add(path); })*
+ path = MultipartIdentifier() { unnestList.add(path.first); }
+ ( <UNNEST> path = MultipartIdentifier() { unnestList.add(path.first); })*
(
( <COLON> type = IndexedTypeExpr(false)
{
@@ -1204,11 +1224,11 @@
(
<SELECT> path = MultipartIdentifier() ( <COLON> type = IndexedTypeExpr(false) )?
{
- projectList.add(new Pair<List<String>, IndexedTypeExpression>(path, type));
+ projectList.add(new Pair<List<String>, IndexedTypeExpression>(path.first, type));
}
( <COMMA> path = MultipartIdentifier() ( <COLON> type = IndexedTypeExpr(false) )?
{
- projectList.add(new Pair<List<String>, IndexedTypeExpression>(path, type));
+ projectList.add(new Pair<List<String>, IndexedTypeExpression>(path.first, type));
}
)*
)
@@ -1225,13 +1245,13 @@
Pair<List<String>, IndexedTypeExpression> IndexedField() throws ParseException:
{
- List<String> path = null;
+ Triple<List<String>, Token, Token> path = null;
IndexedTypeExpression type = null;
}
{
path = MultipartIdentifier() ( <COLON> type = IndexedTypeExpr(true) )?
{
- return new Pair<List<String>, IndexedTypeExpression>(path, type);
+ return new Pair<List<String>, IndexedTypeExpression>(path.first, type);
}
}
@@ -1320,13 +1340,13 @@
CreateDataverseStatement DataverseSpecification(Token startStmtToken) throws ParseException :
{
- List<String> dvName = null;
+ DataverseName dvName = null;
boolean ifNotExists = false;
}
{
- dvName = MultipartIdentifier() ifNotExists = IfNotExists()
+ dvName = DataverseName() ifNotExists = IfNotExists()
{
- CreateDataverseStatement stmt = new CreateDataverseStatement(DataverseName.create(dvName), null, ifNotExists);
+ CreateDataverseStatement stmt = new CreateDataverseStatement(dvName, null, ifNotExists);
return addSourceLocation(stmt, startStmtToken);
}
}
@@ -1991,13 +2011,13 @@
DataverseDropStatement DropDataverseSpecification(Token startStmtToken) throws ParseException:
{
- List<String> multipartId = null;
+ DataverseName dvName = null;
boolean ifExists = false;
}
{
- multipartId = MultipartIdentifier() ifExists = IfExists()
+ dvName = DataverseName() ifExists = IfExists()
{
- DataverseDropStatement stmt = new DataverseDropStatement(DataverseName.create(multipartId), ifExists);
+ DataverseDropStatement stmt = new DataverseDropStatement(dvName, ifExists);
return addSourceLocation(stmt, startStmtToken);
}
}
@@ -2690,7 +2710,7 @@
FunctionName FunctionName() throws ParseException:
{
- Triple<List<String>, SourceLocation, Token> prefix = null;
+ Triple<List<String>, Token, Token> prefix = null;
String suffix = null;
}
{
@@ -2702,8 +2722,9 @@
)
(<SHARP> suffix = Identifier())?
{
+ Token startToken = prefix.second;
FunctionName result = new FunctionName();
- result.sourceLoc = prefix.second;
+ result.sourceLoc = getSourceLocation(startToken);
result.hintToken = prefix.third;
List<String> list = prefix.first;
int ln = list.size();
@@ -2719,7 +2740,7 @@
result.function = suffix;
}
if (ln > 1) {
- result.dataverse = DataverseName.create(list, 0, ln - 1);
+ result.dataverse = createDataverseName(list, 0, ln - 1, startToken);
} else {
result.dataverse = defaultDataverse;
}
@@ -2861,49 +2882,64 @@
}
}
-List<String> MultipartIdentifier() throws ParseException:
+Triple<List<String>, Token, Token> MultipartIdentifier() throws ParseException:
{
- Triple<List<String>, SourceLocation, Token> result = null;
+ Triple<List<String>, Token, Token> result = null;
}
{
result = MultipartIdentifierWithHints(null)
{
- return result.first;
+ return result;
}
}
-Triple<List<String>, SourceLocation, Token> MultipartIdentifierWithHints(SqlppHint... expectedHints)
+Triple<List<String>, Token, Token> MultipartIdentifierWithHints(SqlppHint... expectedHints)
throws ParseException:
{
List<String> list = new ArrayList<String>();
SourceLocation sourceLoc = null;
- Token hint = null;
+ Token startToken, hintToken = null;
String item = null;
}
{
item = Identifier()
{
list.add(item);
- sourceLoc = getSourceLocation(token);
+ startToken = token;
if (expectedHints != null && expectedHints.length > 0) {
- hint = fetchHint(token, expectedHints);
+ hintToken = fetchHint(token, expectedHints);
}
}
(<DOT> item = Identifier() { list.add(item); } )*
{
- return new Triple<List<String>, SourceLocation, Token>(list, sourceLoc, hint);
+ return new Triple<List<String>, Token, Token>(list, startToken, hintToken);
+ }
+}
+
+DataverseName DataverseName() throws ParseException:
+{
+ Triple<List<String>, Token, Token> ident = null;
+}
+{
+ ident = MultipartIdentifier()
+ {
+ List<String> list = ident.first;
+ Token startToken = ident.second;
+ return createDataverseName(list, 0, list.size(), startToken);
}
}
Pair<DataverseName,Identifier> QualifiedName() throws ParseException:
{
- List<String> list = null;
+ Triple<List<String>, Token, Token> ident = null;
}
{
- list = MultipartIdentifier()
+ ident = MultipartIdentifier()
{
+ List<String> list = ident.first;
+ Token startToken = ident.second;
int len = list.size();
- DataverseName id1 = len > 1 ? DataverseName.create(list, 0, len - 1) : null;
+ DataverseName id1 = len > 1 ? createDataverseName(list, 0, len - 1, startToken) : null;
Identifier id2 = new Identifier(list.get(len - 1));
return new Pair<DataverseName,Identifier>(id1, id2);
}
@@ -2913,13 +2949,14 @@
{
List<String> list = new ArrayList<String>();
String item = null;
+ Token startToken = null;
}
{
- item = Identifier() { list.add(item); }
+ item = Identifier() { list.add(item); startToken = token; }
(<DOT> item = Identifier() { list.add(item); } )+
{
int len = list.size();
- DataverseName id1 = len > 2 ? DataverseName.create(list, 0, len - 2) : null;
+ DataverseName id1 = len > 2 ? createDataverseName(list, 0, len - 2, startToken) : null;
Identifier id2 = new Identifier(list.get(len - 2));
Identifier id3 = new Identifier(list.get(len - 1));
return new Triple<DataverseName,Identifier,Identifier>(id1, id2, id3);
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/LoadableDataSource.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/LoadableDataSource.java
index f766da3..79a9d00 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/LoadableDataSource.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/LoadableDataSource.java
@@ -52,7 +52,7 @@
public class LoadableDataSource extends DataSource {
- private static final DataverseName LOADABLE_DV = DataverseName.createSinglePartName("loadable_dv"); // 1-part name
+ private static final String LOADABLE_DV = "loadable_dv";
private static final String LOADABLE_DS = "loadable_ds";
private final Dataset targetDataset;
@@ -63,7 +63,8 @@
public LoadableDataSource(Dataset targetDataset, IAType itemType, IAType metaItemType, String adapter,
Map<String, String> properties) throws AlgebricksException, IOException {
- super(new DataSourceId(LOADABLE_DV, LOADABLE_DS), itemType, metaItemType, Type.LOADABLE, null);
+ super(new DataSourceId(DataverseName.createSinglePartName(LOADABLE_DV), LOADABLE_DS), itemType, metaItemType,
+ Type.LOADABLE, null);
this.targetDataset = targetDataset;
this.adapter = adapter;
this.adapterProperties = properties;
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
index 3ab295e..281e59c 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
@@ -1896,7 +1896,7 @@
private void validateDatabaseObjectNameImpl(String name, SourceLocation sourceLoc) throws AlgebricksException {
if (name == null || name.isEmpty()) {
- throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, sourceLoc, "<empty>");
+ throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, sourceLoc, "");
}
if (Character.isWhitespace(name.codePointAt(0)) || METADATA_OBJECT_NAME_INVALID_CHARS.matcher(name).find()) {
throw new AsterixException(ErrorCode.INVALID_DATABASE_OBJECT_NAME, sourceLoc, name);
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/CompactionPolicyTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/CompactionPolicyTupleTranslator.java
index 1d8e408..0acc91d 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/CompactionPolicyTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/CompactionPolicyTupleTranslator.java
@@ -25,6 +25,7 @@
import org.apache.asterix.metadata.entities.CompactionPolicy;
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -41,7 +42,8 @@
}
@Override
- protected CompactionPolicy createMetadataEntityFromARecord(ARecord compactionPolicyRecord) {
+ protected CompactionPolicy createMetadataEntityFromARecord(ARecord compactionPolicyRecord)
+ throws AlgebricksException {
String dataverseCanonicalName = ((AString) compactionPolicyRecord
.getValueByPos(MetadataRecordTypes.COMPACTION_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
index e4069c2..19722ef 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
@@ -65,6 +65,7 @@
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.compression.CompressionManager;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -90,7 +91,7 @@
}
@Override
- protected Dataset createMetadataEntityFromARecord(ARecord datasetRecord) {
+ protected Dataset createMetadataEntityFromARecord(ARecord datasetRecord) throws AlgebricksException {
String dataverseCanonicalName =
((AString) datasetRecord.getValueByPos(MetadataRecordTypes.DATASET_ARECORD_DATAVERSENAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
index 5327b22..5d80796 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
@@ -29,6 +29,7 @@
import org.apache.asterix.metadata.entities.DatasourceAdapter;
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -42,7 +43,7 @@
}
@Override
- protected DatasourceAdapter createMetadataEntityFromARecord(ARecord adapterRecord) {
+ protected DatasourceAdapter createMetadataEntityFromARecord(ARecord adapterRecord) throws AlgebricksException {
String dataverseCanonicalName = ((AString) adapterRecord
.getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
index 10fe6bf..77c838a 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
@@ -29,6 +29,7 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -50,7 +51,7 @@
}
@Override
- protected Dataverse createMetadataEntityFromARecord(ARecord dataverseRecord) {
+ protected Dataverse createMetadataEntityFromARecord(ARecord dataverseRecord) throws AlgebricksException {
String dataverseCanonicalName = ((AString) dataverseRecord.getValueByPos(0)).getStringValue();
DataverseName dataverseName = DataverseName.createFromCanonicalForm(dataverseCanonicalName);
String format = ((AString) dataverseRecord.getValueByPos(1)).getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/ExternalFileTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/ExternalFileTupleTranslator.java
index abf3719..8c3cacf 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/ExternalFileTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/ExternalFileTupleTranslator.java
@@ -35,6 +35,7 @@
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.types.BuiltinType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -61,7 +62,7 @@
}
@Override
- protected ExternalFile createMetadataEntityFromARecord(ARecord externalFileRecord) {
+ protected ExternalFile createMetadataEntityFromARecord(ARecord externalFileRecord) throws AlgebricksException {
String dataverseCanonicalName = ((AString) externalFileRecord
.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
DataverseName dataverseName = DataverseName.createFromCanonicalForm(dataverseCanonicalName);
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedConnectionTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedConnectionTupleTranslator.java
index a976e10..11b4cea 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedConnectionTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedConnectionTupleTranslator.java
@@ -36,6 +36,7 @@
import org.apache.asterix.om.base.AUnorderedList;
import org.apache.asterix.om.base.IACursor;
import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -50,7 +51,7 @@
}
@Override
- protected FeedConnection createMetadataEntityFromARecord(ARecord feedConnectionRecord) {
+ protected FeedConnection createMetadataEntityFromARecord(ARecord feedConnectionRecord) throws AlgebricksException {
String dataverseCanonicalName =
((AString) feedConnectionRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_DATAVERSE_NAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedPolicyTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedPolicyTupleTranslator.java
index 2407d22..9ffe5dc 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedPolicyTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedPolicyTupleTranslator.java
@@ -36,6 +36,7 @@
import org.apache.asterix.om.base.AUnorderedList;
import org.apache.asterix.om.base.IACursor;
import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -53,7 +54,7 @@
}
@Override
- protected FeedPolicyEntity createMetadataEntityFromARecord(ARecord feedPolicyRecord) {
+ protected FeedPolicyEntity createMetadataEntityFromARecord(ARecord feedPolicyRecord) throws AlgebricksException {
String dataverseCanonicalName = ((AString) feedPolicyRecord
.getValueByPos(MetadataRecordTypes.FEED_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX)).getStringValue();
DataverseName dataverseName = DataverseName.createFromCanonicalForm(dataverseCanonicalName);
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
index 77a3c92..8834522 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
@@ -37,6 +37,7 @@
import org.apache.asterix.om.base.AUnorderedList;
import org.apache.asterix.om.base.IACursor;
import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -54,7 +55,7 @@
}
@Override
- protected Feed createMetadataEntityFromARecord(ARecord feedRecord) {
+ protected Feed createMetadataEntityFromARecord(ARecord feedRecord) throws AlgebricksException {
String dataverseCanonicalName =
((AString) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_DATAVERSE_NAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FullTextFilterMetadataEntityTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FullTextFilterMetadataEntityTupleTranslator.java
index 4845310..2212e82 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FullTextFilterMetadataEntityTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FullTextFilterMetadataEntityTupleTranslator.java
@@ -89,7 +89,7 @@
}
public FullTextFilterMetadataEntity createStopwordsFilterDescriptorFromARecord(AString dataverseName, AString name,
- ARecord aRecord) {
+ ARecord aRecord) throws AlgebricksException {
ImmutableList.Builder<String> stopwordsBuilder = ImmutableList.<String> builder();
IACursor stopwordsCursor = ((AOrderedList) (aRecord
.getValueByPos(MetadataRecordTypes.FULLTEXT_ENTITY_ARECORD_STOPWORD_LIST_FIELD_INDEX))).getCursor();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
index 81c654b2..ccae8a4 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
@@ -198,7 +198,7 @@
}
private List<TypeSignature> getParamTypes(ARecord functionRecord, DataverseName functionDataverseName)
- throws AsterixException {
+ throws AlgebricksException {
ARecordType functionRecordType = functionRecord.getType();
int paramTypesFieldIdx = functionRecordType.getFieldIndex(FUNCTION_ARECORD_FUNCTION_PARAMTYPES_FIELD_NAME);
if (paramTypesFieldIdx < 0) {
@@ -230,7 +230,7 @@
}
private TypeSignature getTypeSignature(String typeName, String typeDataverseNameCanonical,
- DataverseName functionDataverseName) {
+ DataverseName functionDataverseName) throws AlgebricksException {
// back-compat: handle "any"
if (BuiltinType.ANY.getTypeName().equals(typeName)) {
return null; // == any
@@ -244,7 +244,8 @@
return new TypeSignature(typeDataverseName, typeName);
}
- private Triple<DataverseName, String, String> getDependency(AOrderedList dependencySubnames) {
+ private Triple<DataverseName, String, String> getDependency(AOrderedList dependencySubnames)
+ throws AlgebricksException {
String dataverseCanonicalName = ((AString) dependencySubnames.getItem(0)).getStringValue();
DataverseName dataverseName = DataverseName.createFromCanonicalForm(dataverseCanonicalName);
String second = null, third = null;
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/LibraryTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/LibraryTupleTranslator.java
index 03abec8..e3e879b 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/LibraryTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/LibraryTupleTranslator.java
@@ -35,6 +35,7 @@
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.types.ARecordType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -51,7 +52,7 @@
}
@Override
- protected Library createMetadataEntityFromARecord(ARecord libraryRecord) {
+ protected Library createMetadataEntityFromARecord(ARecord libraryRecord) throws AlgebricksException {
String dataverseCanonicalName =
((AString) libraryRecord.getValueByPos(MetadataRecordTypes.LIBRARY_ARECORD_DATAVERSENAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/SynonymTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/SynonymTupleTranslator.java
index 4a282c3..6bad2d4 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/SynonymTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/SynonymTupleTranslator.java
@@ -25,6 +25,7 @@
import org.apache.asterix.metadata.entities.Synonym;
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -42,7 +43,7 @@
}
@Override
- protected Synonym createMetadataEntityFromARecord(ARecord synonymRecord) {
+ protected Synonym createMetadataEntityFromARecord(ARecord synonymRecord) throws AlgebricksException {
String dataverseCanonicalName =
((AString) synonymRecord.getValueByPos(MetadataRecordTypes.SYNONYM_ARECORD_DATAVERSENAME_FIELD_INDEX))
.getStringValue();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseDisplayNameDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseDisplayNameDescriptor.java
index ddf6ecd..fd78b72 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseDisplayNameDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseDisplayNameDescriptor.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import org.apache.asterix.common.annotations.MissingNullInOutFunction;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -56,12 +57,25 @@
String dataverseCanonicalName = inputString.toString();
sb.setLength(0);
- DataverseName.getDisplayFormFromCanonicalForm(dataverseCanonicalName, sb);
+ try {
+ DataverseName.getDisplayFormFromCanonicalForm(dataverseCanonicalName, sb);
+ } catch (AsterixException e) {
+ return; // writeResult() will emit NULL
+ }
resultBuilder.reset(resultArray, inputString.getUTF8Length());
resultBuilder.appendString(sb);
resultBuilder.finish();
}
+
+ @Override
+ void writeResult(IPointable resultPointable) throws IOException {
+ if (sb.length() == 0) {
+ PointableHelper.setNull(resultPointable);
+ } else {
+ super.writeResult(resultPointable);
+ }
+ }
};
}
};
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseNameDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseNameDescriptor.java
index fbbe5c5..530fe4a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseNameDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DecodeDataverseNameDescriptor.java
@@ -25,6 +25,7 @@
import org.apache.asterix.builders.OrderedListBuilder;
import org.apache.asterix.common.annotations.MissingNullInOutFunction;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableString;
@@ -101,8 +102,13 @@
strPtr.set(bytes, offset + 1, len - 1);
String dataverseCanonicalName = strPtr.toString();
- dataverseNameParts.clear();
- DataverseName.getPartsFromCanonicalForm(dataverseCanonicalName, dataverseNameParts);
+ try {
+ dataverseNameParts.clear();
+ DataverseName.getPartsFromCanonicalForm(dataverseCanonicalName, dataverseNameParts);
+ } catch (AsterixException e) {
+ PointableHelper.setNull(result);
+ return;
+ }
resultStorage.reset();
listBuilder.reset(listType);