From Shahrzad Shirazi <[email protected]>:

Shahrzad Shirazi has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20905?usp=email )


Change subject: WIP: Aligning collection syntax with naming standards for IF 
NOT EXISTS
......................................................................

WIP: Aligning collection syntax with naming standards for IF NOT EXISTS

Change-Id: Ib731eb88db4dfbd9c312cbcb4700029821a85717
---
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
1 file changed, 35 insertions(+), 19 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/05/20905/1

diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index e04afb6..11a0c07 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -1157,7 +1157,8 @@
   TypeExpression typeExpr = null;
 }
 {
-  nameComponents = TypeName() ifNotExists = IfNotExists()
+  ((nameComponents = TypeName() ifNotExists = IfNotExists())
+  |(ifNotExists = IfNotExists() nameComponents = TypeName()))
   <AS> typeExpr = RecordTypeDef()
   {
     boolean dgen = false;
@@ -1253,8 +1254,10 @@
 {
   // this identifier is the soft keyword CATALOG, consume it then continue
   <IDENTIFIER>
-  catalogName = Identifier()
-  ifNotExists = IfNotExists()
+  ((catalogName = Identifier()
+  ifNotExists = IfNotExists())
+  |(ifNotExists = IfNotExists()
+  catalogName = Identifier()))
   <TYPE> catalogType = Identifier()
   (LOOKAHEAD({laIdentifier(SOURCE)}) <IDENTIFIER> catalogSource = 
Identifier())?
   <WITH> withRecord = RecordConstructor()
@@ -1322,7 +1325,6 @@
     }
     metaTypeExpr = 
DatasetTypeSpecification(RecordTypeDefinition.RecordKind.OPEN)
   )?
-  ifNotExists = IfNotExists()
   (LOOKAHEAD(3) primaryKeyFieldsWithTypes = PrimaryKeyWithType()
     | primaryKeyFields = PrimaryKey())
   (<AUTOGENERATED> { autogenerated = true; } )?
@@ -1381,9 +1383,12 @@
   RecordConstructor withRecord = null;
 }
 {
-  nameComponents = QualifiedName()
+  ((nameComponents = QualifiedName()
   typeExpr = DatasetTypeSpecification(RecordTypeDefinition.RecordKind.OPEN)
-  ifNotExists = IfNotExists()
+  ifNotExists = IfNotExists())
+  |(ifNotExists = IfNotExists()
+  nameComponents = QualifiedName()
+  typeExpr = DatasetTypeSpecification(RecordTypeDefinition.RecordKind.OPEN)))
   <USING> adapterName = AdapterName() properties = Configuration()
   ( <HINTS> hints = Properties() )?
   ( <WITH> withRecord = RecordConstructor() )?
@@ -1504,7 +1509,8 @@
 }
 {
   (
-    indexName = Identifier() ifNotExists = IfNotExists()
+    ((indexName = Identifier() ifNotExists = IfNotExists())
+    |(ifNotExists = IfNotExists() indexName = Identifier()))
     <ON> nameComponents = QualifiedName()
     <LEFTPAREN> { startElementToken  = token; }
       indexedElement = IndexedElement(startElementToken) {
@@ -1757,7 +1763,8 @@
   boolean ifNotExists = false;
 }
 {
-  dbName = Identifier() ifNotExists = IfNotExists()
+  ((dbName = Identifier() ifNotExists = IfNotExists())
+  |(ifNotExists = IfNotExists() dbName = Identifier()))
   {
     CreateDatabaseStatement stmt = new CreateDatabaseStatement(new 
Identifier(dbName), ifNotExists);
     return addSourceLocation(stmt, startStmtToken);
@@ -1781,7 +1788,8 @@
   boolean ifNotExists = false;
 }
 {
-  ns = Namespace() ifNotExists = IfNotExists()
+  ((ns = Namespace() ifNotExists = IfNotExists())
+   |(ifNotExists = IfNotExists() ns = Namespace()))
   {
     CreateDataverseStatement stmt = new CreateDataverseStatement(ns, null, 
ifNotExists);
     return addSourceLocation(stmt, startStmtToken);
@@ -1847,10 +1855,13 @@
   String currentDatabase = defaultDatabase;
   Namespace currentNamespace = defaultNamespace;
 }
-{
-  nameComponents = QualifiedName()
-  (
-      (
+{ (
+    LOOKAHEAD(2)
+    ifNotExists = IfNotExists()
+    nameComponents = QualifiedName()
+  |
+    nameComponents = QualifiedName()
+    (
         typeExpr = 
DatasetTypeSpecification(RecordTypeDefinition.RecordKind.CLOSED)
         ifNotExists = IfNotExists()
         viewConfigDefaultNull = CastDefaultNull()
@@ -1874,9 +1885,9 @@
               foreignKeyFields.first, refNameComponents.first, 
refNameComponents.second));
           }
         )*
-      )
       |
       ( ifNotExists = IfNotExists() )
+    )
   )
   {
     if (orReplace && ifNotExists) {
@@ -2169,7 +2180,8 @@
   RecordConstructor withRecord = null;
 }
 {
-  nameComponents = QualifiedName() ifNotExists = IfNotExists()
+  ((nameComponents = QualifiedName() ifNotExists = IfNotExists())
+  |(ifNotExists = IfNotExists() nameComponents = QualifiedName()))
   <WITH> withRecord = RecordConstructor()
   {
     try {
@@ -2203,7 +2215,8 @@
   CreateFeedPolicyStatement stmt = null;
 }
 {
-  policyName = Identifier() ifNotExists = IfNotExists()
+  ((policyName = Identifier() ifNotExists = IfNotExists())
+  | (ifNotExists = IfNotExists() policyName = Identifier()))
   <FROM>
   (<POLICY> basePolicyName = Identifier() properties = Configuration() 
(<DEFINITION> definition = ConstantString())?
     {
@@ -2245,7 +2258,8 @@
 }
 {
   (
-    nameComponents = QualifiedName() ifNotExists = IfNotExists()
+    ((nameComponents = QualifiedName() ifNotExists = IfNotExists())
+    |(ifNotExists = IfNotExists() nameComponents = QualifiedName()))
     <AS>
     expr = RecordConstructor()
   )
@@ -2268,7 +2282,8 @@
 }
 {
   (
-    nameComponents = QualifiedName() ifNotExists = IfNotExists()
+    ((nameComponents = QualifiedName() ifNotExists = IfNotExists())
+    |(ifNotExists = IfNotExists() nameComponents = QualifiedName()))
     <AS>
     expr = RecordConstructor()
   )
@@ -2300,7 +2315,8 @@
   boolean ifNotExists = false;
 }
 {
-  nameComponents = QualifiedName() ifNotExists = IfNotExists()
+  ((nameComponents = QualifiedName() ifNotExists = IfNotExists())
+  |(ifNotExists = IfNotExists() nameComponents = QualifiedName()))
   <FOR> objectNameComponents = QualifiedName()
   {
     CreateSynonymStatement stmt = new 
CreateSynonymStatement(nameComponents.first, nameComponents.second.getValue(),

--
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: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Ib731eb88db4dfbd9c312cbcb4700029821a85717
Gerrit-Change-Number: 20905
Gerrit-PatchSet: 1
Gerrit-Owner: Shahrzad Shirazi <[email protected]>

Reply via email to