Ali Alsuliman has submitted this change and it was merged. Change subject: [NO ISSUE][COMP] Disable creating index on meta ......................................................................
[NO ISSUE][COMP] Disable creating index on meta - user model changes: no - storage format changes: no - interface changes: no Details: Disable creating an index on meta fields. Change-Id: Ib7d3b3706f200da0ef023e642b2d807511cb0801 Reviewed-on: https://asterix-gerrit.ics.uci.edu/3103 Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <ti...@apache.org> --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 2 files changed, 16 insertions(+), 3 deletions(-) Approvals: Anon. E. Moose #1000171: Till Westmann: Looks good to me, approved Jenkins: Verified; Verified Objections: Jenkins: Violations found 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 f619ab6..ed4c361 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 @@ -787,6 +787,7 @@ MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction(); metadataProvider.setMetadataTxnContext(mdTxnCtx); String datasetFullyQualifiedName = dataverseName + "." + datasetName; + boolean isSecondaryPrimary = stmtCreateIndex.getFieldExprs().isEmpty(); Dataset ds = null; Index index = null; MetadataLockUtil.createIndexBegin(lockManager, metadataProvider.getLocks(), dataverseName, @@ -808,10 +809,19 @@ throw new CompilationException(ErrorCode.INDEX_EXISTS, sourceLoc, indexName); } } - // can't create secondary primary index on an external dataset - if (ds.getDatasetType() == DatasetType.EXTERNAL && stmtCreateIndex.getFieldExprs().isEmpty()) { + // find keySourceIndicators for secondary primary index since the parser isn't aware of them + if (isSecondaryPrimary && ds.getDatasetType() == DatasetType.INTERNAL) { + keySourceIndicators = ((InternalDatasetDetails) ds.getDatasetDetails()).getKeySourceIndicator(); + } + // disable creating secondary primary index on an external dataset + if (isSecondaryPrimary && ds.getDatasetType() == DatasetType.EXTERNAL) { throw new AsterixException(ErrorCode.CANNOT_CREATE_SEC_PRIMARY_IDX_ON_EXT_DATASET); } + // disable creating an index on meta fields (fields with source indicator == 1 are meta fields) + if (keySourceIndicators.stream().anyMatch(fieldSource -> fieldSource == 1) && !isSecondaryPrimary) { + throw new AsterixException(ErrorCode.COMPILATION_ERROR, sourceLoc, + "Cannot create index on meta fields"); + } Datatype dt = MetadataManager.INSTANCE.getDatatype(metadataProvider.getMetadataTxnContext(), ds.getItemTypeDataverseName(), ds.getItemTypeName()); ARecordType aRecordType = (ARecordType) dt.getDatatype(); 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 37eaf79..3ab1ff9 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -8870,6 +8870,7 @@ <test-case FilePath="feeds"> <compilation-unit name="change-feed-with-meta-with-mixed-index"> <output-dir compare="Text">change-feed-with-meta-with-mixed-index</output-dir> + <expected-error>Compilation error: Cannot create index on meta fields (in line 61, at column 1)</expected-error> </compilation-unit> </test-case> <test-case FilePath="feeds"> @@ -8885,7 +8886,7 @@ <test-case FilePath="feeds"> <compilation-unit name="change-feed-with-meta-open-index-in-meta"> <output-dir compare="Text">change-feed-with-meta-open-index-in-meta</output-dir> - <expected-error>Typed open index can only be created on the record part</expected-error> + <expected-error>Compilation error: Cannot create index on meta fields (in line 60, at column 1)</expected-error> </compilation-unit> </test-case> <test-case FilePath="feeds"> @@ -8896,11 +8897,13 @@ <test-case FilePath="feeds"> <compilation-unit name="change-feed-with-meta-pk-in-meta-index-after-ingest"> <output-dir compare="Text">change-feed-with-meta-pk-in-meta-index-after-ingest</output-dir> + <expected-error>Compilation error: Cannot create index on meta fields (in line 27, at column 1)</expected-error> </compilation-unit> </test-case> <test-case FilePath="feeds"> <compilation-unit name="change-feed-with-meta-pk-in-meta-index-in-meta"> <output-dir compare="Text">change-feed-with-meta-pk-in-meta-index-in-meta</output-dir> + <expected-error>Compilation error: Cannot create index on meta fields (in line 60, at column 1)</expected-error> </compilation-unit> </test-case> <test-case FilePath="feeds"> -- To view, visit https://asterix-gerrit.ics.uci.edu/3103 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib7d3b3706f200da0ef023e642b2d807511cb0801 Gerrit-PatchSet: 3 Gerrit-Project: asterixdb Gerrit-Branch: stabilization-f69489 Gerrit-Owner: Ali Alsuliman <ali.al.solai...@gmail.com> Gerrit-Reviewer: Ali Alsuliman <ali.al.solai...@gmail.com> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Gerrit-Reviewer: Till Westmann <ti...@apache.org>