Support for non-enforced secondary indexes - Added support for non-enforced secondary BTree indexes - Added tests - Fixed NonTaggedDataFormat to use code-generated runtime functions
Change-Id: I8f4abddf047e851d44a5f08fe9a210617d3cd018 Reviewed-on: https://asterix-gerrit.ics.uci.edu/1835 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> BAD: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Yingyi Bu <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/8ba59445 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/8ba59445 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/8ba59445 Branch: refs/heads/master Commit: 8ba5944532d84c04001796c6b5b7f5abaf60825c Parents: 7505a79 Author: Dmitry Lychagin <[email protected]> Authored: Fri Jun 16 14:19:45 2017 -0700 Committer: Yingyi Bu <[email protected]> Committed: Fri Jun 16 16:22:21 2017 -0700 ---------------------------------------------------------------------- ...IntroduceSecondaryIndexInsertDeleteRule.java | 6 +- .../optimizer/rules/am/AccessMethodUtils.java | 4 +- .../optimizer/rules/am/BTreeAccessMethod.java | 81 ++++++++++----- .../rules/am/IntroduceJoinAccessMethodRule.java | 22 ++++ .../rules/am/InvertedIndexAccessMethod.java | 8 +- .../optimizer/rules/am/RTreeAccessMethod.java | 4 +- .../LangExpressionToPlanTranslator.java | 2 - .../apache/asterix/api/common/APIFramework.java | 6 ++ .../asterix/app/translator/QueryTranslator.java | 47 ++++++--- .../app/bootstrap/TestNodeController.java | 2 +- .../btree-index-non-enforced-04.sqlpp | 44 ++++++++ .../btree-index-non-enforced-05.sqlpp | 44 ++++++++ .../btree-index-non-enforced-06.sqlpp | 44 ++++++++ .../btree-index-non-enforced-07.sqlpp | 44 ++++++++ .../btree-index-non-enforced-08.sqlpp | 45 +++++++++ .../btree-index-non-enforced-09.sqlpp | 44 ++++++++ .../btree-index-non-enforced-10.sqlpp | 44 ++++++++ .../btree-index-non-enforced-11.sqlpp | 44 ++++++++ .../btree-index-non-enforced-04.plan | 22 ++++ .../btree-index-non-enforced-05.plan | 22 ++++ .../btree-index-non-enforced-06.plan | 22 ++++ .../btree-index-non-enforced-07.plan | 22 ++++ .../btree-index-non-enforced-08.plan | 22 ++++ .../btree-index-non-enforced-09.plan | 22 ++++ .../btree-index-non-enforced-10.plan | 22 ++++ .../btree-index-non-enforced-11.plan | 23 +++++ .../missing-enforce-statement.1.ddl.aql | 2 +- .../missing-enforce-statement.1.ddl.sqlpp | 2 +- .../btree-equi-join-01.1.ddl.sqlpp | 36 +++++++ .../btree-equi-join-01.2.update.sqlpp | 79 +++++++++++++++ .../btree-equi-join-01.3.update.sqlpp | 79 +++++++++++++++ .../btree-equi-join-01.4.ddl.sqlpp | 38 +++++++ .../btree-equi-join-01.5.query.sqlpp | 26 +++++ .../btree-index-01/btree-index-01.1.ddl.sqlpp | 33 ++++++ .../btree-index-01.10.query.sqlpp | 25 +++++ .../btree-index-01.11.query.sqlpp | 25 +++++ .../btree-index-01.2.update.sqlpp | 79 +++++++++++++++ .../btree-index-01/btree-index-01.3.ddl.sqlpp | 28 ++++++ .../btree-index-01/btree-index-01.4.query.sqlpp | 25 +++++ .../btree-index-01/btree-index-01.5.query.sqlpp | 25 +++++ .../btree-index-01/btree-index-01.6.query.sqlpp | 25 +++++ .../btree-index-01/btree-index-01.7.query.sqlpp | 25 +++++ .../btree-index-01/btree-index-01.8.query.sqlpp | 25 +++++ .../btree-index-01/btree-index-01.9.query.sqlpp | 25 +++++ .../btree-equi-join-01/btree-equi-join-01.5.adm | 10 ++ .../btree-index-01/btree-index-01.10.adm | 3 + .../btree-index-01/btree-index-01.11.adm | 2 + .../btree-index-01/btree-index-01.4.adm | 2 + .../btree-index-01/btree-index-01.5.adm | 2 + .../btree-index-01/btree-index-01.6.adm | 2 + .../btree-index-01/btree-index-01.7.adm | 2 + .../btree-index-01/btree-index-01.8.adm | 5 + .../btree-index-01/btree-index-01.9.adm | 4 + .../src/test/resources/runtimets/testsuite.xml | 4 +- .../resources/runtimets/testsuite_sqlpp.xml | 18 +++- .../asterix/common/exceptions/ErrorCode.java | 2 + .../main/resources/asx_errormsg/en.properties | 2 + .../asterix-lang-aql/src/main/javacc/AQL.jj | 19 ++-- .../expression/IndexedTypeExpression.java | 40 ++++++++ .../common/statement/CreateIndexStatement.java | 8 +- .../lang/common/visitor/FormatPrintVisitor.java | 13 ++- .../asterix-lang-sqlpp/src/main/javacc/SQLPP.jj | 19 ++-- asterixdb/asterix-metadata/pom.xml | 5 - .../apache/asterix/metadata/MetadataNode.java | 2 +- .../metadata/MetadataTransactionContext.java | 2 +- .../apache/asterix/metadata/entities/Index.java | 20 ++-- .../IndexTupleTranslator.java | 7 +- .../asterix/metadata/utils/IndexUtil.java | 2 +- .../utils/SecondaryBTreeOperationsHelper.java | 23 +++-- .../utils/SecondaryIndexOperationsHelper.java | 18 ++-- .../SecondaryInvertedIndexOperationsHelper.java | 15 +-- .../utils/SecondaryRTreeOperationsHelper.java | 22 ++-- .../apache/asterix/metadata/utils/TypeUtil.java | 2 +- .../IndexTupleTranslatorTest.java | 2 +- .../asterix/formats/base/IDataFormat.java | 2 +- .../asterix/om/functions/IFunctionManager.java | 4 +- .../evaluators/common/FunctionManagerImpl.java | 5 +- .../runtime/formats/NonTaggedDataFormat.java | 100 ++++++++++--------- 78 files changed, 1507 insertions(+), 195 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java index 8de6b59..a39c84b 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java @@ -289,7 +289,7 @@ public class IntroduceSecondaryIndexInsertDeleteRule implements IAlgebraicRewrit Mutable<ILogicalExpression> filterExpression = (primaryIndexModificationOp .getOperation() == Kind.UPSERT) ? null : createFilterExpression(secondaryKeyVars, context.getOutputTypeEnvironment(currentTop), - index.isEnforcingKeyFields()); + index.isOverridingKeyFieldTypes()); DataSourceIndex dataSourceIndex = new DataSourceIndex(index, dataverseName, datasetName, mp); // Introduce the TokenizeOperator only when doing bulk-load, @@ -572,8 +572,8 @@ public class IntroduceSecondaryIndexInsertDeleteRule implements IAlgebraicRewrit AbstractFunctionCallExpression fieldAccessFunc = getOpenOrNestedFieldAccessFunction(varRef, indexFieldId.fieldName); // create cast - theFieldAccessFunc = new ScalarFunctionCallExpression( - FunctionUtil.getFunctionInfo(BuiltinFunctions.CAST_TYPE)); + theFieldAccessFunc = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo( + index.isEnforced() ? BuiltinFunctions.CAST_TYPE : BuiltinFunctions.CAST_TYPE_LAX)); // The first argument is the field theFieldAccessFunc.getArguments().add(new MutableObject<ILogicalExpression>(fieldAccessFunc)); TypeCastUtils.setRequiredAndInputTypes(theFieldAccessFunc, skTypes.get(i), BuiltinType.ANY); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java index 48367a7..b4b83e5 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java @@ -385,7 +385,7 @@ public class AccessMethodUtils { * * @throws AlgebricksException */ - public static Pair<ILogicalExpression, Boolean> createSearchKeyExpr(IOptimizableFuncExpr optFuncExpr, + public static Pair<ILogicalExpression, Boolean> createSearchKeyExpr(Index index, IOptimizableFuncExpr optFuncExpr, OptimizableOperatorSubTree indexSubTree, OptimizableOperatorSubTree probeSubTree) throws AlgebricksException { if (probeSubTree == null) { @@ -422,7 +422,7 @@ public class AccessMethodUtils { if (constantValueTag != fieldType.getTypeTag() && constantValue != null) { try { replacedConstantValue = ATypeHierarchy.getAsterixConstantValueFromNumericTypeObject( - constantValue.getObject(), fieldType.getTypeTag(), true); + constantValue.getObject(), fieldType.getTypeTag(), index.isEnforced()); } catch (HyracksDataException e) { throw new AlgebricksException(e); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java index 0f6012f..189f238 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java @@ -38,6 +38,9 @@ import org.apache.asterix.metadata.entities.Dataset; import org.apache.asterix.metadata.entities.Index; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.types.ARecordType; +import org.apache.asterix.om.types.AUnionType; +import org.apache.asterix.om.types.IAType; +import org.apache.asterix.om.utils.NonTaggedFormatUtil; import org.apache.asterix.optimizer.rules.util.EquivalenceClassUtils; import org.apache.commons.lang3.mutable.Mutable; import org.apache.commons.lang3.mutable.MutableObject; @@ -259,11 +262,6 @@ public class BTreeAccessMethod implements IAccessMethod { BitSet setHighKeys = new BitSet(numSecondaryKeys); // Go through the func exprs listed as optimizable by the chosen index, // and formulate a range predicate on the secondary-index keys. - - // checks whether a type casting happened from a real (FLOAT, DOUBLE) value to an INT value - // since we have a round issues when dealing with LT(<) OR GT(>) operator. - boolean realTypeConvertedToIntegerType; - for (Pair<Integer, Integer> exprIndex : exprAndVarList) { // Position of the field of matchedFuncExprs.get(exprIndex) in the chosen index's indexed exprs. IOptimizableFuncExpr optFuncExpr = analysisCtx.getMatchedFuncExpr(exprIndex.first); @@ -276,35 +274,24 @@ public class BTreeAccessMethod implements IAccessMethod { throw CompilationException.create(ErrorCode.NO_INDEX_FIELD_NAME_FOR_GIVEN_FUNC_EXPR); } Pair<ILogicalExpression, Boolean> returnedSearchKeyExpr = - AccessMethodUtils.createSearchKeyExpr(optFuncExpr, indexSubTree, probeSubTree); + AccessMethodUtils.createSearchKeyExpr(chosenIndex, optFuncExpr, indexSubTree, probeSubTree); ILogicalExpression searchKeyExpr = returnedSearchKeyExpr.first; if (searchKeyExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { constantAtRuntimeExpressions[keyPos] = searchKeyExpr; constAtRuntimeExprVars[keyPos] = context.newVar(); searchKeyExpr = new VariableReferenceExpression(constAtRuntimeExprVars[keyPos]); - } - realTypeConvertedToIntegerType = returnedSearchKeyExpr.second; LimitType limit = getLimitType(optFuncExpr, probeSubTree); + if (limit == null) { + return null; + } - // If a DOUBLE or FLOAT constant is converted to an INT type value, - // we need to check a corner case where two real values are located between an INT value. - // For example, for the following query, - // - // for $emp in dataset empDataset - // where $emp.age > double("2.3") and $emp.age < double("3.3") - // return $emp.id - // - // It should generate a result if there is a tuple that satisfies the condition, which is 3, - // however, it does not generate the desired result since finding candidates - // fail after truncating the fraction part (there is no INT whose value is greater than 2 and less than 3.) - // - // Therefore, we convert LT(<) to LE(<=) and GT(>) to GE(>=) to find candidates. - // This does not change the result of an actual comparison since this conversion is only applied - // for finding candidates from an index. - // - if (realTypeConvertedToIntegerType) { + // checks whether a type casting happened from a real (FLOAT, DOUBLE) value to an INT value + // since we have a round issues when dealing with LT(<) OR GT(>) operator. + boolean realTypeConvertedToIntegerType = returnedSearchKeyExpr.second; + + if (relaxLimitTypeToInclusive(chosenIndex, keyPos, realTypeConvertedToIntegerType)) { if (limit == LimitType.HIGH_EXCLUSIVE) { limit = LimitType.HIGH_INCLUSIVE; } else if (limit == LimitType.LOW_EXCLUSIVE) { @@ -717,6 +704,50 @@ public class BTreeAccessMethod implements IAccessMethod { return limit; } + private boolean relaxLimitTypeToInclusive(Index chosenIndex, int keyPos, boolean realTypeConvertedToIntegerType) { + // If a DOUBLE or FLOAT constant is converted to an INT type value, + // we need to check a corner case where two real values are located between an INT value. + // For example, for the following query, + // + // for $emp in dataset empDataset + // where $emp.age > double("2.3") and $emp.age < double("3.3") + // return $emp.id + // + // It should generate a result if there is a tuple that satisfies the condition, which is 3, + // however, it does not generate the desired result since finding candidates + // fail after truncating the fraction part (there is no INT whose value is greater than 2 and less than 3.) + // + // Therefore, we convert LT(<) to LE(<=) and GT(>) to GE(>=) to find candidates. + // This does not change the result of an actual comparison since this conversion is only applied + // for finding candidates from an index. + // + // We also need to do this for a non-enforced index that overrides key field type (for a numeric type) + + if (realTypeConvertedToIntegerType) { + return true; + } + + if (chosenIndex.isOverridingKeyFieldTypes() && !chosenIndex.isEnforced()) { + IAType indexedKeyType = chosenIndex.getKeyFieldTypes().get(keyPos); + if (NonTaggedFormatUtil.isOptional(indexedKeyType)) { + indexedKeyType = ((AUnionType) indexedKeyType).getActualType(); + } + switch (indexedKeyType.getTypeTag()) { + case TINYINT: + case SMALLINT: + case INTEGER: + case BIGINT: + case FLOAT: + case DOUBLE: + return true; + default: + break; + } + } + + return false; + } + private boolean probeIsOnLhs(IOptimizableFuncExpr optFuncExpr, OptimizableOperatorSubTree probeSubTree) { if (probeSubTree == null) { if (optFuncExpr.getConstantExpressions().length == 0) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java index 7fc7902..d16eb18 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java @@ -192,6 +192,25 @@ public class IntroduceJoinAccessMethodRule extends AbstractIntroduceAccessMethod } /** + * Removes non-enforced indexes on open types + */ + protected void pruneIndexCandidatesOpenNonEnforced(Map<IAccessMethod, AccessMethodAnalysisContext> analyzedAMs) { + for (Map.Entry<IAccessMethod, AccessMethodAnalysisContext> entry : analyzedAMs.entrySet()) { + AccessMethodAnalysisContext amCtx = entry.getValue(); + + // Fetch index + Iterator<Map.Entry<Index, List<Pair<Integer, Integer>>>> indexIt = amCtx.getIteratorForIndexExprsAndVars(); + + while (indexIt.hasNext()) { + Index index = indexIt.next().getKey(); + if (index.isOverridingKeyFieldTypes() && !index.isEnforced()) { + indexIt.remove(); + } + } + } + } + + /** * Checks whether the given operator is LEFTOUTERJOIN. * If so, also checks that GROUPBY is placed after LEFTOUTERJOIN. */ @@ -347,6 +366,9 @@ public class IntroduceJoinAccessMethodRule extends AbstractIntroduceAccessMethod // Remove the indexes from the outer branch in the optimizer's consideration list for this rule. pruneIndexCandidatesFromOuterBranch(analyzedAMs); + // Remove non-enforced indexes on open types as they currently can't be used with joins + pruneIndexCandidatesOpenNonEnforced(analyzedAMs); + // We are going to use indexes from the inner branch. // If no index is available, then we stop here. Pair<IAccessMethod, Index> chosenIndex = chooseBestIndex(analyzedAMs); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java index 2b6a369..725de12 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java @@ -698,7 +698,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod { // Create select ops for removing tuples that are filterable and not filterable, respectively. IVariableTypeEnvironment probeTypeEnv = context.getOutputTypeEnvironment(probeSubTree.getRoot()); IAType inputSearchVarType; - if (chosenIndex.isEnforcingKeyFields()) { + if (chosenIndex.isEnforced()) { inputSearchVarType = optFuncExpr.getFieldType(optFuncExpr.findLogicalVar(inputSearchVar)); } else { inputSearchVarType = (IAType) probeTypeEnv.getVarType(inputSearchVar); @@ -946,7 +946,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod { } private boolean isEditDistanceFuncJoinOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) { - if (index.isEnforcingKeyFields()) { + if (index.isEnforced()) { return isEditDistanceFuncCompatible(index.getKeyFieldTypes().get(0).getTypeTag(), index.getIndexType()); } else { return isEditDistanceFuncCompatible(optFuncExpr.getFieldType(0).getTypeTag(), index.getIndexType()); @@ -1089,7 +1089,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod { } private boolean isFullTextContainsFuncJoinOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) { - if (index.isEnforcingKeyFields()) { + if (index.isEnforced()) { return isFullTextContainsFuncCompatible(index.getKeyFieldTypes().get(0).getTypeTag(), index.getIndexType()); } else { return isFullTextContainsFuncCompatible(optFuncExpr.getFieldType(0).getTypeTag(), index.getIndexType()); @@ -1190,7 +1190,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod { } private boolean isContainsFuncJoinOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) { - if (index.isEnforcingKeyFields()) { + if (index.isEnforced()) { return isContainsFuncCompatible(index.getKeyFieldTypes().get(0).getTypeTag(), index.getIndexType()); } else { return isContainsFuncCompatible(optFuncExpr.getFieldType(0).getTypeTag(), index.getIndexType()); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java index fe2827e..4d219a7 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java @@ -207,8 +207,8 @@ public class RTreeAccessMethod implements IAccessMethod { ArrayList<LogicalVariable> keyVarList = new ArrayList<>(); // List of expressions for the assign. ArrayList<Mutable<ILogicalExpression>> keyExprList = new ArrayList<>(); - Pair<ILogicalExpression, Boolean> returnedSearchKeyExpr = AccessMethodUtils.createSearchKeyExpr(optFuncExpr, - indexSubTree, probeSubTree); + Pair<ILogicalExpression, Boolean> returnedSearchKeyExpr = + AccessMethodUtils.createSearchKeyExpr(chosenIndex, optFuncExpr, indexSubTree, probeSubTree); ILogicalExpression searchKeyExpr = returnedSearchKeyExpr.first; for (int i = 0; i < numSecondaryKeys; i++) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java index d5e01a4..8258d51 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java @@ -181,7 +181,6 @@ class LangExpressionToPlanTranslator throws AlgebricksException { this.context = new TranslationContext(new Counter(currentVarCounterValue)); this.metadataProvider = metadataProvider; - FormatUtils.getDefaultFormat().registerRuntimeFunctions(FunctionCollection.getFunctionDescriptorFactories()); } // Keeps the given Counter if one is provided instead of a value. @@ -189,7 +188,6 @@ class LangExpressionToPlanTranslator throws AlgebricksException { this.context = new TranslationContext(currentVarCounter); this.metadataProvider = metadataProvider; - FormatUtils.getDefaultFormat().registerRuntimeFunctions(FunctionCollection.getFunctionDescriptorFactories()); } @Override http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java index 583302b..744f99c 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java @@ -62,12 +62,14 @@ import org.apache.asterix.lang.common.statement.Query; import org.apache.asterix.lang.common.util.FunctionUtil; import org.apache.asterix.metadata.declared.MetadataProvider; import org.apache.asterix.optimizer.base.FuzzyUtils; +import org.apache.asterix.runtime.formats.FormatUtils; import org.apache.asterix.runtime.job.listener.JobEventListenerFactory; import org.apache.asterix.transaction.management.service.transaction.JobIdFactory; import org.apache.asterix.translator.CompiledStatements.ICompiledDmlStatement; import org.apache.asterix.translator.IStatementExecutor.Stats; import org.apache.asterix.translator.SessionConfig; import org.apache.asterix.translator.SessionOutput; +import org.apache.asterix.translator.util.FunctionCollection; import org.apache.asterix.utils.ResourceUtils; import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint; import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint; @@ -133,6 +135,10 @@ public class APIFramework { this.ruleSetFactory = compilationProvider.getRuleSetFactory(); } + static { + FormatUtils.getDefaultFormat().registerRuntimeFunctions(FunctionCollection.getFunctionDescriptorFactories()); + } + private static class OptimizationContextFactory implements IOptimizationContextFactory { public static final OptimizationContextFactory INSTANCE = new OptimizationContextFactory(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java ---------------------------------------------------------------------- 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 7ce9df6..65268b1 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 @@ -84,7 +84,7 @@ import org.apache.asterix.lang.common.base.IReturningStatement; import org.apache.asterix.lang.common.base.IRewriterFactory; import org.apache.asterix.lang.common.base.IStatementRewriter; import org.apache.asterix.lang.common.base.Statement; -import org.apache.asterix.lang.common.expression.TypeExpression; +import org.apache.asterix.lang.common.expression.IndexedTypeExpression; import org.apache.asterix.lang.common.statement.CompactStatement; import org.apache.asterix.lang.common.statement.ConnectFeedStatement; import org.apache.asterix.lang.common.statement.CreateDataverseStatement; @@ -777,7 +777,8 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen List<List<String>> indexFields = new ArrayList<>(); List<IAType> indexFieldTypes = new ArrayList<>(); int keyIndex = 0; - for (Pair<List<String>, TypeExpression> fieldExpr : stmtCreateIndex.getFieldExprs()) { + boolean overridesFieldTypes = false; + for (Pair<List<String>, IndexedTypeExpression> fieldExpr : stmtCreateIndex.getFieldExprs()) { IAType fieldType = null; ARecordType subType = KeyFieldTypeUtil.chooseSource(keySourceIndicators, keyIndex, aRecordType, metaRecordType); @@ -793,9 +794,13 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen if (fieldExpr.second == null) { fieldType = subType.getSubFieldType(fieldExpr.first.subList(i, fieldExpr.first.size())); } else { - if (!stmtCreateIndex.isEnforced()) { - throw new AlgebricksException("Cannot create typed index on \"" + fieldExpr.first - + "\" field without enforcing it's type"); + if (!stmtCreateIndex.isEnforced() && stmtCreateIndex.getIndexType() != IndexType.BTREE) { + throw new AsterixException(ErrorCode.INDEX_ILLEGAL_NON_ENFORCED_TYPED, + stmtCreateIndex.getIndexType()); + } + if (stmtCreateIndex.isEnforced() && !fieldExpr.second.isUnknownable()) { + throw new AsterixException(ErrorCode.INDEX_ILLEGAL_ENFORCED_NON_OPTIONAL, + String.valueOf(fieldExpr.first)); } if (!isOpen) { throw new AlgebricksException("Typed index on \"" + fieldExpr.first @@ -805,9 +810,10 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen throw new AlgebricksException("Typed open index can only be created on the record part"); } Map<TypeSignature, IAType> typeMap = - TypeTranslator.computeTypes(mdTxnCtx, fieldExpr.second, indexName, dataverseName); + TypeTranslator.computeTypes(mdTxnCtx, fieldExpr.second.getType(), indexName, dataverseName); TypeSignature typeSignature = new TypeSignature(dataverseName, indexName); fieldType = typeMap.get(typeSignature); + overridesFieldTypes = true; } if (fieldType == null) { throw new AlgebricksException( @@ -819,8 +825,8 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen ++keyIndex; } - ValidateUtil.validateKeyFields(aRecordType, metaRecordType, indexFields, keySourceIndicators, - indexFieldTypes, stmtCreateIndex.getIndexType()); + validateIndexKeyFields(stmtCreateIndex, keySourceIndicators, aRecordType, metaRecordType, indexFields, + indexFieldTypes); if (index != null) { if (stmtCreateIndex.getIfNotExists()) { @@ -892,7 +898,7 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen // Add an entry for the files index filesIndex = new Index(dataverseName, datasetName, IndexingConstants.getFilesIndexName(datasetName), IndexType.BTREE, ExternalIndexingOperations.FILE_INDEX_FIELD_NAMES, null, - ExternalIndexingOperations.FILE_INDEX_FIELD_TYPES, false, false, + ExternalIndexingOperations.FILE_INDEX_FIELD_TYPES, overridesFieldTypes, false, false, MetadataUtil.PENDING_ADD_OP); MetadataManager.INSTANCE.addIndex(metadataProvider.getMetadataTxnContext(), filesIndex); // Add files to the external files index @@ -918,7 +924,7 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen for (Index existingIndex : indexes) { if (existingIndex.getKeyFieldNames().equals(indexFields) && !existingIndex.getKeyFieldTypes().equals(indexFieldTypes) - && existingIndex.isEnforcingKeyFields()) { + && existingIndex.isEnforced()) { throw new CompilationException("Cannot create index " + indexName + " , enforced index " + existingIndex.getIndexName() + " on field \"" + StringUtils.join(indexFields, ',') + "\" is already defined with type \"" + existingIndex.getKeyFieldTypes() + "\""); @@ -928,8 +934,8 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen // #. add a new index with PendingAddOp index = new Index(dataverseName, datasetName, indexName, stmtCreateIndex.getIndexType(), indexFields, - keySourceIndicators, indexFieldTypes, stmtCreateIndex.getGramLength(), stmtCreateIndex.isEnforced(), - false, MetadataUtil.PENDING_ADD_OP); + keySourceIndicators, indexFieldTypes, stmtCreateIndex.getGramLength(), overridesFieldTypes, + stmtCreateIndex.isEnforced(),false, MetadataUtil.PENDING_ADD_OP); MetadataManager.INSTANCE.addIndex(metadataProvider.getMetadataTxnContext(), index); // #. prepare to create the index artifact in NC. @@ -1071,6 +1077,13 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen } } + protected void validateIndexKeyFields(CreateIndexStatement stmtCreateIndex, List<Integer> keySourceIndicators, + ARecordType aRecordType, ARecordType metaRecordType, List<List<String>> indexFields, + List<IAType> indexFieldTypes) throws AlgebricksException { + ValidateUtil.validateKeyFields(aRecordType, metaRecordType, indexFields, keySourceIndicators, + indexFieldTypes, stmtCreateIndex.getIndexType()); + } + protected void handleCreateTypeStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception { TypeDecl stmtCreateType = (TypeDecl) stmt; String dataverseName = getActiveDataverse(stmtCreateType.getDataverseName()); @@ -1404,7 +1417,8 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen MetadataManager.INSTANCE.addIndex(mdTxnCtx, new Index(dataverseName, datasetName, indexName, index.getIndexType(), index.getKeyFieldNames(), index.getKeyFieldSourceIndicators(), index.getKeyFieldTypes(), - index.isEnforcingKeyFields(), index.isPrimaryIndex(), MetadataUtil.PENDING_DROP_OP)); + index.isOverridingKeyFieldTypes(), index.isEnforced(), index.isPrimaryIndex(), + MetadataUtil.PENDING_DROP_OP)); // #. commit the existing transaction before calling runJob. MetadataManager.INSTANCE.commitTransaction(mdTxnCtx); @@ -1454,8 +1468,8 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen new Index(dataverseName, datasetName, externalIndex.getIndexName(), externalIndex.getIndexType(), externalIndex.getKeyFieldNames(), externalIndex.getKeyFieldSourceIndicators(), index.getKeyFieldTypes(), - index.isEnforcingKeyFields(), externalIndex.isPrimaryIndex(), - MetadataUtil.PENDING_DROP_OP)); + index.isOverridingKeyFieldTypes(), index.isEnforced(), + externalIndex.isPrimaryIndex(), MetadataUtil.PENDING_DROP_OP)); } } } @@ -1465,7 +1479,8 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen MetadataManager.INSTANCE.addIndex(mdTxnCtx, new Index(dataverseName, datasetName, indexName, index.getIndexType(), index.getKeyFieldNames(), index.getKeyFieldSourceIndicators(), index.getKeyFieldTypes(), - index.isEnforcingKeyFields(), index.isPrimaryIndex(), MetadataUtil.PENDING_DROP_OP)); + index.isOverridingKeyFieldTypes(), index.isEnforced(), index.isPrimaryIndex(), + MetadataUtil.PENDING_DROP_OP)); // #. commit the existing transaction before calling runJob. MetadataManager.INSTANCE.commitTransaction(mdTxnCtx); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java index 8c1ce4e..99892c5 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java @@ -403,7 +403,7 @@ public class TestNodeController { keyFieldNames.add(Arrays.asList(fieldNames[primaryKeyIndexes[i]])); } index = new Index(dataset.getDataverseName(), dataset.getDatasetName(), dataset.getDatasetName(), - IndexType.BTREE, keyFieldNames, keyFieldSourceIndicators, keyFieldTypes, false, true, + IndexType.BTREE, keyFieldNames, keyFieldSourceIndicators, keyFieldTypes, false, false, true, MetadataUtil.PENDING_NO_OP); List<String> nodes = Collections.singletonList(ExecutionTestUtil.integrationUtil.ncs[0].getId()); FileSplit[] splits = SplitsAndConstraintsUtil.getIndexSplits(dataset, index.getIndexName(), nodes); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.sqlpp new file mode 100644 index 0000000..5d804b9 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-04.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_s on TestOpen(c_s:string); + +select t.c_x as res +from TestOpen t +where t.c_s = 'world' +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.sqlpp new file mode 100644 index 0000000..2818002 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-05.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_i64 on TestOpen(c_i64:int64); + +select t.c_x as res +from TestOpen t +where t.c_i64 = 2 +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.sqlpp new file mode 100644 index 0000000..7bff919 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-06.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_i64 on TestOpen(c_i64:int64); + +select t.c_x as res +from TestOpen t +where t.c_i64 > 2 +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.sqlpp new file mode 100644 index 0000000..fe78300 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-07.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_i64 on TestOpen(c_i64:int64); + +select t.c_x as res +from TestOpen t +where t.c_i64 > 2.0 +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.sqlpp new file mode 100644 index 0000000..0116c95 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.sqlpp @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-08.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_i8 on TestOpen(c_i8:int8); + +select t.c_x as res +from TestOpen t +where t.c_i8 > 2 +order by t.c_x; + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.sqlpp new file mode 100644 index 0000000..2c39be5 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-09.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_i8 on TestOpen(c_i8:int8); + +select t.c_x as res +from TestOpen t +where t.c_i8 > 2.5 +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.sqlpp new file mode 100644 index 0000000..f3519ab --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-10.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_d on TestOpen(c_d:double); + +select t.c_x as res +from TestOpen t +where t.c_d >= 3.25 +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.sqlpp new file mode 100644 index 0000000..0032524 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.sqlpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* + * Description : BTree non-enforced index verification test + * : Test that the secondary non-enforced BTree index is used + * Expected Result : Success + * Date : 12th Jun 2017 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +write output to asterix_nc1:"rttest/btree-index-non-enforced_btree-index-non-enforced-11.adm" + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen(TestOpenType) +primary key c_id; + +create index idx_i8 on TestOpen(c_i8:int8); + +select t.c_x as res +from TestOpen t +where t.c_i8 > 499 and t.c_i8 < 99999 +order by t.c_x; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.plan new file mode 100644 index 0000000..459286e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-04.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$16(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.plan new file mode 100644 index 0000000..459286e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-05.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$16(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.plan new file mode 100644 index 0000000..01c6a30 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-06.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$15(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.plan new file mode 100644 index 0000000..01c6a30 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-07.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$15(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.plan new file mode 100644 index 0000000..01c6a30 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-08.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$15(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.plan new file mode 100644 index 0000000..01c6a30 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-09.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$15(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.plan new file mode 100644 index 0000000..01c6a30 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-10.plan @@ -0,0 +1,22 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$11(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$11(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$15(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.plan ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.plan new file mode 100644 index 0000000..41da8df --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/open-index-non-enforced/btree-index-non-enforced/btree-index-non-enforced-11.plan @@ -0,0 +1,23 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- SORT_MERGE_EXCHANGE [$$14(ASC) ] |PARTITIONED| + -- STABLE_SORT [$$14(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STABLE_SORT [$$19(ASC)] |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- BTREE_SEARCH |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.aql index 9e6ed67..f699b60 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.aql @@ -25,4 +25,4 @@ create type testType as open { } create dataset testDS(testType) primary key id; -create index testIdx on testDS(value: string?); +create index testIdx on testDS(value: point?) type rtree; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp index f74baa3..9dc2368 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp @@ -30,5 +30,5 @@ create type test.testType as create dataset testDS(testType) primary key id; -create index testIdx on testDS (`value`:string?) type btree; +create index testIdx on testDS (`value`:point?) type rtree; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.1.ddl.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.1.ddl.sqlpp new file mode 100644 index 0000000..a957c0b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.1.ddl.sqlpp @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* +* Description : Index join is currently disabled for non-enforced indexes +* Expected Res : Success +* Date : 7 Jun 2017 +*/ +drop dataverse test if exists; +create dataverse test; +use test; + +create type TestOpenType as open { + c_id: int64 +} + +create dataset TestOpen1(TestOpenType) +primary key c_id; + +create dataset TestOpen2(TestOpenType) +primary key c_id; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.2.update.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.2.update.sqlpp new file mode 100644 index 0000000..903b769 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.2.update.sqlpp @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +insert into TestOpen1 ({ + "c_id": 1, + "c_x": 1, + "c_s": "hello", + "c_i64": 2, + "c_i8": 2, + "c_d": 2 +}); +insert into TestOpen1 ({ + "c_id": 2, + "c_x": 2, + "c_s": 2, + "c_i64": "2", + "c_i8": 2.5, + "c_d": 3 +}); +insert into TestOpen1 ({ + "c_id": 3, + "c_x": 3, + "c_s": "world", + "c_i64": 2, + "c_i8": 4, + "c_d": 3.125 +}); +insert into TestOpen1 ({ + "c_id": 4, + "c_x": 4, + "c_s": null, + "c_i64": null, + "c_i8": 500, + "c_d": 3.25 +}); +insert into TestOpen1 ({ + "c_id": 5, + "c_x": 5, + "c_s": "hello", + "c_i64": 2.25, + "c_i8": 10000.25, + "c_d": 3.5 +}); +insert into TestOpen1 ({ + "c_id": 6, + "c_x": 6, + "c_s": false, + "c_i64": false, + "c_i8": 2e100, + "c_d": 2e100 +}); +insert into TestOpen1 ({ + "c_id": 7, + "c_x": 7, + "c_s": "world", + "c_i64": 3 +}); +insert into TestOpen1 ({ + "c_id": 8, + "c_x": 8 +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.3.update.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.3.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.3.update.sqlpp new file mode 100644 index 0000000..6781d53 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.3.update.sqlpp @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +insert into TestOpen2 ({ + "c_id": 101, + "c_x": 101, + "c_s": "hello", + "c_i64": 2, + "c_i8": 2, + "c_d": 2 +}); +insert into TestOpen2 ({ + "c_id": 102, + "c_x": 102, + "c_s": 2, + "c_i64": "2", + "c_i8": 2.5, + "c_d": 3 +}); +insert into TestOpen2 ({ + "c_id": 103, + "c_x": 103, + "c_s": "world", + "c_i64": 2, + "c_i8": 4, + "c_d": 3.125 +}); +insert into TestOpen2 ({ + "c_id": 104, + "c_x": 104, + "c_s": null, + "c_i64": null, + "c_i8": 500, + "c_d": 3.25 +}); +insert into TestOpen2 ({ + "c_id": 105, + "c_x": 105, + "c_s": "hello", + "c_i64": 2.25, + "c_i8": 10000.25, + "c_d": 3.5 +}); +insert into TestOpen2 ({ + "c_id": 106, + "c_x": 106, + "c_s": false, + "c_i64": false, + "c_i8": 2e100, + "c_d": 2e100 +}); +insert into TestOpen2 ({ + "c_id": 107, + "c_x": 107, + "c_s": "world", + "c_i64": 3 +}); +insert into TestOpen2 ({ + "c_id": 108, + "c_x": 108 +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.4.ddl.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.4.ddl.sqlpp new file mode 100644 index 0000000..916cbb1 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.4.ddl.sqlpp @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +create index idx_t1_s on TestOpen1(c_s:string); + +create index idx_t1_i64 on TestOpen1(c_i64:int64); + +create index idx_t1_i8 on TestOpen1(c_i8:int8); + +create index idx_t1_d on TestOpen1(c_d:double); + +/********************************************/ + +create index idx_t2_s on TestOpen2(c_s:string); + +create index idx_t2_i64 on TestOpen2(c_i64:int64); + +create index idx_t2_i8 on TestOpen2(c_i8:int8); + +create index idx_t2_d on TestOpen2(c_d:double); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ba59445/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.5.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.5.query.sqlpp new file mode 100644 index 0000000..5f0ae38 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-join/btree-equi-join-01/btree-equi-join-01.5.query.sqlpp @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +use test; + +select t1.c_x as c1, t2.c_x as c2 +from TestOpen1 as t1, TestOpen2 as t2 +where (t1.c_s /*+ indexnl */ = t2.c_s) +order by t1.c_x, t2.c_x;
