>From Shahrzad Shirazi <[email protected]>: Shahrzad Shirazi has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20905?usp=email )
( 8 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: [ASTERIXDB-3706][COMP] Support IF NOT EXISTS Before and After identifier in DDL Statements ...................................................................... [ASTERIXDB-3706][COMP] Support IF NOT EXISTS Before and After identifier in DDL Statements - user model changes: yes - storage format changes: no - interface changes: no Details: This change will support IF NOT EXISTS both before and after the identifier. Ext-ref: MB-70013 Change-Id: Ib731eb88db4dfbd9c312cbcb4700029821a85717 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20905 Reviewed-by: Shahrzad Shirazi <[email protected]> Tested-by: Jenkins <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> --- M asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 2 files changed, 211 insertions(+), 36 deletions(-) Approvals: Shahrzad Shirazi: Looks good to me, but someone else must approve Ali Alsuliman: Looks good to me, approved Jenkins: Verified diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml index bc1834f..9db0281 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml @@ -4333,7 +4333,7 @@ <test-case FilePath="ddl/create-index"> <compilation-unit name="create-index-4"> <output-dir compare="Text">create-index-4</output-dir> - <expected-error>Syntax error: In line 53 >>create primary index if not exists sec_primary_idx1 if not exists on LineItem;<< Encountered <IDENTIFIER> "sec_primary_idx1" at column 37.</expected-error> + <expected-error>Syntax error: In line 53 >>create primary index if not exists sec_primary_idx1 if not exists on LineItem;<< Encountered "if" at column 55.</expected-error> </compilation-unit> </test-case> <test-case FilePath="ddl/create-index"> diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj index e04afb6..23105fd 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj +++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj @@ -1157,7 +1157,13 @@ TypeExpression typeExpr = null; } { - nameComponents = TypeName() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() + nameComponents = TypeName() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <AS> typeExpr = RecordTypeDef() { boolean dgen = false; @@ -1200,7 +1206,12 @@ List<Identifier> ncNames = new ArrayList<Identifier>(); } { - name = Identifier() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() name = Identifier() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <ON> tmp = Identifier() { ncNames.add(new Identifier(tmp)); @@ -1253,8 +1264,14 @@ { // this identifier is the soft keyword CATALOG, consume it then continue <IDENTIFIER> - catalogName = Identifier() ifNotExists = IfNotExists() + catalogName = Identifier() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } + <TYPE> catalogType = Identifier() (LOOKAHEAD({laIdentifier(SOURCE)}) <IDENTIFIER> catalogSource = Identifier())? <WITH> withRecord = RecordConstructor() @@ -1308,6 +1325,7 @@ Query query = null; } { + ifNotExists = IfNotExists() nameComponents = QualifiedName() (typeExpr = DatasetTypeSpecification(RecordTypeDefinition.RecordKind.OPEN))? ( @@ -1322,7 +1340,11 @@ } metaTypeExpr = DatasetTypeSpecification(RecordTypeDefinition.RecordKind.OPEN) )? - ifNotExists = IfNotExists() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } (LOOKAHEAD(3) primaryKeyFieldsWithTypes = PrimaryKeyWithType() | primaryKeyFields = PrimaryKey()) (<AUTOGENERATED> { autogenerated = true; } )? @@ -1381,9 +1403,14 @@ RecordConstructor withRecord = null; } { + ifNotExists = IfNotExists() nameComponents = QualifiedName() typeExpr = DatasetTypeSpecification(RecordTypeDefinition.RecordKind.OPEN) - ifNotExists = IfNotExists() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <USING> adapterName = AdapterName() properties = Configuration() ( <HINTS> hints = Properties() )? ( <WITH> withRecord = RecordConstructor() )? @@ -1504,7 +1531,13 @@ } { ( - indexName = Identifier() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() + indexName = Identifier() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <ON> nameComponents = QualifiedName() <LEFTPAREN> { startElementToken = token; } indexedElement = IndexedElement(startElementToken) { @@ -1674,7 +1707,12 @@ boolean ifNotExists = false; } { - (indexName = Identifier())? ifNotExists = IfNotExists() + ifNotExists = IfNotExists() (indexName = Identifier())? + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <ON> nameComponents = QualifiedName() (<TYPE> <BTREE>)? { if (indexName == null) { @@ -1757,7 +1795,12 @@ boolean ifNotExists = false; } { - dbName = Identifier() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() + dbName = Identifier() + { if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } { CreateDatabaseStatement stmt = new CreateDatabaseStatement(new Identifier(dbName), ifNotExists); return addSourceLocation(stmt, startStmtToken); @@ -1781,7 +1824,13 @@ boolean ifNotExists = false; } { - ns = Namespace() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() + ns = Namespace() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } { CreateDataverseStatement stmt = new CreateDataverseStatement(ns, null, ifNotExists); return addSourceLocation(stmt, startStmtToken); @@ -1807,8 +1856,13 @@ boolean ifNotExists = false; } { - adapterName = QualifiedName() ifNotExists = IfNotExists() + adapterName = QualifiedName() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <AS> externalIdentifier = FunctionExternalIdentifier() <AT> libraryName = QualifiedName() { @@ -1848,11 +1902,16 @@ Namespace currentNamespace = defaultNamespace; } { + ifNotExists = IfNotExists() nameComponents = QualifiedName() ( ( typeExpr = DatasetTypeSpecification(RecordTypeDefinition.RecordKind.CLOSED) - ifNotExists = IfNotExists() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } viewConfigDefaultNull = CastDefaultNull() { viewConfig = viewConfigDefaultNull.first; @@ -1874,9 +1933,14 @@ foreignKeyFields.first, refNameComponents.first, refNameComponents.second)); } )* - ) + ) | - ( ifNotExists = IfNotExists() ) + ( { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } + ) ) { if (orReplace && ifNotExists) { @@ -1986,6 +2050,7 @@ Namespace currentNamespace = defaultNamespace; } { + ifNotExists = IfNotExists() fctName = FunctionName() { defaultDataverse = fctName.dataverse; @@ -1998,7 +2063,11 @@ params = paramsWithArity.second; signature = new FunctionSignature(fctName.database, fctName.dataverse, fctName.function, arity); } - ifNotExists = IfNotExists() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } { if (orReplace && ifNotExists) { throw new SqlppParseException(getSourceLocation(token), "Unexpected IF NOT EXISTS"); @@ -2169,7 +2238,11 @@ RecordConstructor withRecord = null; } { - nameComponents = QualifiedName() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() nameComponents = QualifiedName() + { if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <WITH> withRecord = RecordConstructor() { try { @@ -2203,7 +2276,12 @@ CreateFeedPolicyStatement stmt = null; } { - policyName = Identifier() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() policyName = Identifier() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <FROM> (<POLICY> basePolicyName = Identifier() properties = Configuration() (<DEFINITION> definition = ConstantString())? { @@ -2245,7 +2323,12 @@ } { ( - nameComponents = QualifiedName() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() nameComponents = QualifiedName() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <AS> expr = RecordConstructor() ) @@ -2268,7 +2351,12 @@ } { ( - nameComponents = QualifiedName() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() nameComponents = QualifiedName() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <AS> expr = RecordConstructor() ) @@ -2300,7 +2388,12 @@ boolean ifNotExists = false; } { - nameComponents = QualifiedName() ifNotExists = IfNotExists() + ifNotExists = IfNotExists() nameComponents = QualifiedName() + { + if (ifNotExists == false) { + ifNotExists = IfNotExists(); + } + } <FOR> objectNameComponents = QualifiedName() { CreateSynonymStatement stmt = new CreateSynonymStatement(nameComponents.first, nameComponents.second.getValue(), @@ -2495,7 +2588,12 @@ boolean ifExists = false; } { - pairId = QualifiedName() ifExists = IfExists() + ifExists = IfExists() pairId = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { TruncateDatasetStatement stmt = new TruncateDatasetStatement(pairId.first, pairId.second.getValue(), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2547,7 +2645,12 @@ boolean ifExists = false; } { - pairId = QualifiedName() ifExists = IfExists() + ifExists = IfExists() pairId = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { DropDatasetStatement stmt = new DropDatasetStatement(pairId.first, pairId.second, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2571,7 +2674,12 @@ boolean ifExists = false; } { - pairId = QualifiedName() ifExists = IfExists() + ifExists = IfExists() pairId = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { ViewDropStatement stmt = new ViewDropStatement(pairId.first, pairId.second, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2595,7 +2703,13 @@ boolean ifExists = false; } { - tripleId = DoubleQualifiedName() ifExists = IfExists() + ifExists = IfExists() tripleId = DoubleQualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } + { IndexDropStatement stmt = new IndexDropStatement(tripleId.first, tripleId.second, tripleId.third, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2624,7 +2738,12 @@ boolean ifExists = false; } { - nameComponents = QualifiedName() ifExists = IfExists() + ifExists = IfExists() nameComponents = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { stmt = new FullTextFilterDropStatement(nameComponents.first, nameComponents.second.getValue(), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2638,7 +2757,12 @@ boolean ifExists = false; } { - nameComponents = QualifiedName() ifExists = IfExists() + ifExists = IfExists() nameComponents = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { stmt = new FullTextConfigDropStatement(nameComponents.first, nameComponents.second.getValue(), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2663,7 +2787,13 @@ boolean ifExists = false; } { - id = Identifier() ifExists = IfExists() + ifExists = IfExists() id = Identifier() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } + { NodeGroupDropStatement stmt = new NodeGroupDropStatement(new Identifier(id), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2687,7 +2817,12 @@ boolean ifExists = false; } { - pairId = TypeName() ifExists = IfExists() + ifExists = IfExists() pairId = TypeName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { TypeDropStatement stmt = new TypeDropStatement(pairId.first, pairId.second, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2711,7 +2846,12 @@ boolean ifExists = false; } { - dbName = Identifier() ifExists = IfExists() + ifExists = IfExists() dbName = Identifier() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { DatabaseDropStatement stmt = new DatabaseDropStatement(new Identifier(dbName), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2735,7 +2875,12 @@ boolean ifExists = false; } { - ns = Namespace() ifExists = IfExists() + ifExists = IfExists() ns = Namespace() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { DataverseDropStatement stmt = new DataverseDropStatement(ns, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2759,7 +2904,12 @@ boolean ifExists = false; } { - adapterName = QualifiedName() ifExists = IfExists() + ifExists = IfExists() adapterName = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { AdapterDropStatement stmt = new AdapterDropStatement(adapterName.first, adapterName.second.getValue(), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2783,7 +2933,12 @@ boolean ifExists = false; } { - funcSig = FunctionSignature() ifExists = IfExists() + ifExists = IfExists() funcSig = FunctionSignature() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { FunctionDropStatement stmt = new FunctionDropStatement(funcSig, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2807,7 +2962,12 @@ boolean ifExists = false; } { - pairId = QualifiedName() ifExists = IfExists() + ifExists = IfExists() pairId = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { FeedDropStatement stmt = new FeedDropStatement(pairId.first, pairId.second, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2831,7 +2991,12 @@ boolean ifExists = false; } { - pairId = QualifiedName() ifExists = IfExists() + ifExists = IfExists() pairId = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { FeedPolicyDropStatement stmt = new FeedPolicyDropStatement(pairId.first, pairId.second, ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2855,7 +3020,12 @@ boolean ifExists = false; } { - pairId = QualifiedName() ifExists = IfExists() + ifExists = IfExists() pairId = QualifiedName() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } { SynonymDropStatement stmt = new SynonymDropStatement(pairId.first, pairId.second.getValue(), ifExists); return addSourceLocation(stmt, startStmtToken); @@ -2882,8 +3052,13 @@ boolean isCascade = false; } { - catalogName = Identifier() ifExists = IfExists() + catalogName = Identifier() + { + if (ifExists == false) { + ifExists = IfExists(); + } + } (LOOKAHEAD({laIdentifier(CASCADE)}) <IDENTIFIER> { isCascade = true; })? { CatalogDropStatement stmt = new CatalogDropStatement(catalogName, ifExists, isCascade); -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20905?usp=email To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Change-Id: Ib731eb88db4dfbd9c312cbcb4700029821a85717 Gerrit-Change-Number: 20905 Gerrit-PatchSet: 10 Gerrit-Owner: Shahrzad Shirazi <[email protected]> Gerrit-Reviewer: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Shahrzad Shirazi <[email protected]> Gerrit-CC: Ian Maxon <[email protected]>
