@@ -119,13 +119,13 @@ replDumpStatement
119
119
;
120
120
121
121
replDbPolicy
122
- : dbName=id_ (DOT tablePolicy=replTableLevelPolicy)?
122
+ : dbName=dbSchemaName (DOT tablePolicy=replTableLevelPolicy)?
123
123
;
124
124
125
125
replLoadStatement
126
126
: KW_REPL KW_LOAD
127
127
sourceDbPolicy=replDbPolicy
128
- (KW_INTO dbName=id_ )?
128
+ (KW_INTO dbName=dbSchemaName )?
129
129
(KW_WITH replConf=replConfigs)?
130
130
;
131
131
@@ -143,7 +143,7 @@ replTableLevelPolicy
143
143
144
144
replStatusStatement
145
145
: KW_REPL KW_STATUS
146
- dbName=id_
146
+ dbName=dbSchemaName
147
147
(KW_WITH replConf=replConfigs)?
148
148
;
149
149
@@ -233,14 +233,14 @@ orReplace
233
233
createDatabaseStatement
234
234
: KW_CREATE KW_REMOTE ? db_schema
235
235
ifNotExists?
236
- name=id_
236
+ name=dbSchemaNameCreate
237
237
databaseComment?
238
238
dbLocation?
239
239
dbManagedLocation?
240
240
(KW_WITH KW_DBPROPERTIES dbprops=dbProperties)?
241
241
| KW_CREATE KW_REMOTE db_schema
242
242
ifNotExists?
243
- name=id_
243
+ name=dbSchemaNameCreate
244
244
databaseComment?
245
245
dbConnectorName
246
246
(KW_WITH KW_DBPROPERTIES dbprops=dbProperties)?
@@ -263,15 +263,15 @@ dbPropertiesList
263
263
;
264
264
265
265
dbConnectorName
266
- : KW_USING dcName=id_
266
+ : KW_USING dcName=dbSchemaName
267
267
;
268
268
269
269
switchDatabaseStatement
270
- : KW_USE id_
270
+ : KW_USE dbSchemaName
271
271
;
272
272
273
273
dropDatabaseStatement
274
- : KW_DROP db_schema ifExists? id_ restrictOrCascade?
274
+ : KW_DROP db_schema ifExists? dbSchemaName restrictOrCascade?
275
275
;
276
276
277
277
databaseComment
@@ -300,15 +300,15 @@ partTypeExpr
300
300
;
301
301
302
302
tabPartColTypeExpr
303
- : tableName partitionSpec? extColumnName?
303
+ : tableOrView partitionSpec? extColumnName?
304
304
;
305
305
306
306
descStatement
307
307
: (KW_DESCRIBE | KW_DESC )
308
308
(
309
- db_schema KW_EXTENDED ? dbName=id_
310
- | KW_DATACONNECTOR KW_EXTENDED ? dcName=id_
311
- | KW_FUNCTION KW_EXTENDED ? name=descFuncNames
309
+ db_schema KW_EXTENDED ? dbName=dbSchemaName
310
+ | KW_DATACONNECTOR KW_EXTENDED ? dcName=dbSchemaName
311
+ | KW_FUNCTION KW_EXTENDED ? name=functionNameForDDL
312
312
| (descOptions=KW_FORMATTED | descOptions=KW_EXTENDED ) parttype=tabPartColTypeExpr
313
313
| parttype=tabPartColTypeExpr
314
314
)
@@ -333,26 +333,26 @@ db_schema
333
333
334
334
showStatement
335
335
: KW_SHOW (KW_DATABASES | KW_SCHEMAS ) (KW_LIKE showStmtIdentifier)?
336
- | KW_SHOW isExtended=KW_EXTENDED ? KW_TABLES (from_in db_name=id_ )? filter=showTablesFilterExpr?
337
- | KW_SHOW KW_VIEWS (from_in db_name=id_ )? (KW_LIKE showStmtIdentifier | showStmtIdentifier)?
338
- | KW_SHOW KW_MATERIALIZED KW_VIEWS (from_in db_name=id_ )? (KW_LIKE showStmtIdentifier|showStmtIdentifier)?
339
- | KW_SHOW KW_SORTED ? KW_COLUMNS from_in tableName (from_in db_name=id_ )? (KW_LIKE showStmtIdentifier|showStmtIdentifier)?
340
- | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier )?
341
- | KW_SHOW KW_PARTITIONS tabName=tableName partitionSpec? whereClause? orderByClause? limitClause?
342
- | KW_SHOW KW_CREATE (db_schema db_name=id_ | KW_TABLE tabName=tableName)
343
- | KW_SHOW KW_TABLE KW_EXTENDED (from_in db_name=id_ )? KW_LIKE showStmtIdentifier partitionSpec?
336
+ | KW_SHOW isExtended=KW_EXTENDED ? KW_TABLES (from_in db_name=dbSchemaName )? filter=showTablesFilterExpr?
337
+ | KW_SHOW KW_VIEWS (from_in db_name=dbSchemaName )? (KW_LIKE showStmtIdentifier | showStmtIdentifier)?
338
+ | KW_SHOW KW_MATERIALIZED KW_VIEWS (from_in db_name=dbSchemaName )? (KW_LIKE showStmtIdentifier|showStmtIdentifier)?
339
+ | KW_SHOW KW_SORTED ? KW_COLUMNS from_in tableOrView (from_in db_name=dbSchemaName )? (KW_LIKE showStmtIdentifier|showStmtIdentifier)?
340
+ | KW_SHOW KW_FUNCTIONS (KW_LIKE functionNameForDDL )?
341
+ | KW_SHOW KW_PARTITIONS tabOrViewName=tableOrView partitionSpec? whereClause? orderByClause? limitClause?
342
+ | KW_SHOW KW_CREATE (db_schema db_name=dbSchemaName | KW_TABLE tabName=tableName)
343
+ | KW_SHOW KW_TABLE KW_EXTENDED (from_in db_name=dbSchemaName )? KW_LIKE showStmtIdentifier partitionSpec?
344
344
| KW_SHOW KW_TBLPROPERTIES tableName (LPAREN prptyName=StringLiteral RPAREN )?
345
- | KW_SHOW KW_LOCKS (db_schema dbName=id_ isExtended=KW_EXTENDED ? | parttype=partTypeExpr? isExtended=KW_EXTENDED ?)
345
+ | KW_SHOW KW_LOCKS (db_schema dbName=dbSchemaName isExtended=KW_EXTENDED ? | parttype=partTypeExpr? isExtended=KW_EXTENDED ?)
346
346
| KW_SHOW KW_COMPACTIONS
347
347
( compactionId
348
- | db_schema dbName=id_ compactionPool? compactionType? compactionStatus? orderByClause? limitClause?
348
+ | db_schema dbName=dbSchemaName compactionPool? compactionType? compactionStatus? orderByClause? limitClause?
349
349
| parttype=partTypeExpr? compactionPool? compactionType? compactionStatus? orderByClause? limitClause?
350
350
)
351
351
| KW_SHOW KW_TRANSACTIONS
352
352
| KW_SHOW KW_CONF StringLiteral
353
353
| KW_SHOW KW_RESOURCE (KW_PLAN rp_name=id_ | KW_PLANS )
354
354
| KW_SHOW KW_DATACONNECTORS
355
- | KW_SHOW KW_FORMATTED ? ( KW_INDEX | KW_INDEXES ) KW_ON tableName (from_in id_ )?
355
+ | KW_SHOW KW_FORMATTED ? ( KW_INDEX | KW_INDEXES ) KW_ON tableName (from_in dbSchemaName )?
356
356
;
357
357
358
358
showTablesFilterExpr
@@ -366,7 +366,7 @@ lockStatement
366
366
;
367
367
368
368
lockDatabase
369
- : KW_LOCK db_schema dbName=id_ lockMode
369
+ : KW_LOCK db_schema dbName=dbSchemaName lockMode
370
370
;
371
371
372
372
lockMode
@@ -379,7 +379,7 @@ unlockStatement
379
379
;
380
380
381
381
unlockDatabase
382
- : KW_UNLOCK db_schema dbName=id_
382
+ : KW_UNLOCK db_schema dbName=dbSchemaName
383
383
;
384
384
385
385
createRoleStatement
@@ -450,14 +450,14 @@ privilegeObject
450
450
database or table type. Type is optional, default type is table
451
451
*/
452
452
privObject
453
- : db_schema id_
453
+ : db_schema dbSchemaName
454
454
| KW_TABLE ? tableName partitionSpec?
455
455
| KW_URI path=StringLiteral
456
456
| KW_SERVER id_
457
457
;
458
458
459
459
privObjectCols
460
- : db_schema id_
460
+ : db_schema dbSchemaName
461
461
| KW_TABLE ? tableName (LPAREN cols=columnNameList RPAREN )? partitionSpec?
462
462
| KW_URI path=StringLiteral
463
463
| KW_SERVER id_
@@ -539,12 +539,12 @@ resourceType
539
539
;
540
540
541
541
createFunctionStatement
542
- : KW_CREATE temp=KW_TEMPORARY ? KW_FUNCTION functionIdentifier KW_AS StringLiteral
542
+ : KW_CREATE temp=KW_TEMPORARY ? KW_FUNCTION functionNameCreate KW_AS StringLiteral
543
543
(KW_USING rList=resourceList)?
544
544
;
545
545
546
546
dropFunctionStatement
547
- : KW_DROP temp=KW_TEMPORARY ? KW_FUNCTION ifExists? functionIdentifier
547
+ : KW_DROP temp=KW_TEMPORARY ? KW_FUNCTION ifExists? functionNameForDDL
548
548
;
549
549
550
550
reloadFunctionsStatement
@@ -575,7 +575,7 @@ dropIndexStatement
575
575
: KW_DROP KW_INDEX ifExists? id_ KW_ON tableName;
576
576
577
577
createViewStatement
578
- : KW_CREATE orReplace? KW_VIEW ifNotExists? name=tableName
578
+ : KW_CREATE orReplace? KW_VIEW ifNotExists? name=viewNameCreate
579
579
(LPAREN columnNameCommentList RPAREN )? tableComment? viewPartition?
580
580
tablePropertiesPrefixed?
581
581
KW_AS
@@ -612,7 +612,7 @@ dropViewStatement
612
612
;
613
613
614
614
createMaterializedViewStatement
615
- : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? name=tableName
615
+ : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? name=viewNameCreate
616
616
rewriteDisabled? tableComment? viewPartition? viewOrganization?
617
617
tableRowFormat? tableFileFormat? tableLocation?
618
618
tablePropertiesPrefixed? KW_AS selectStatementWithCTE
@@ -660,11 +660,6 @@ definedAsSpec
660
660
: KW_DEFINED ? KW_AS statement
661
661
;
662
662
663
- showFunctionIdentifier
664
- : functionIdentifier
665
- | StringLiteral
666
- ;
667
-
668
663
showStmtIdentifier
669
664
: id_
670
665
| StringLiteral
@@ -1345,8 +1340,8 @@ END SHOW COMPACTIONS statement
1345
1340
1346
1341
alterStatement
1347
1342
: KW_ALTER ( KW_TABLE tableName alterTableStatementSuffix
1348
- | KW_VIEW tableName KW_AS ? alterViewStatementSuffix
1349
- | KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix
1343
+ | KW_VIEW viewName KW_AS ? alterViewStatementSuffix
1344
+ | KW_MATERIALIZED KW_VIEW tableNameTree=viewName alterMaterializedViewStatementSuffix
1350
1345
| db_schema alterDatabaseStatementSuffix
1351
1346
| KW_DATACONNECTOR alterDataConnectorStatementSuffix
1352
1347
| KW_INDEX alterIndexStatementSuffix
@@ -1425,23 +1420,23 @@ alterDatabaseStatementSuffix
1425
1420
;
1426
1421
1427
1422
alterDatabaseSuffixProperties
1428
- : name=id_ KW_SET KW_DBPROPERTIES dbProperties
1423
+ : name=dbSchemaName KW_SET KW_DBPROPERTIES dbProperties
1429
1424
;
1430
1425
1431
1426
alterDatabaseSuffixSetOwner
1432
- : dbName=id_ KW_SET KW_OWNER principalAlterName
1427
+ : dbName=dbSchemaName KW_SET KW_OWNER principalAlterName
1433
1428
;
1434
1429
1435
1430
alterDatabaseSuffixSetLocation
1436
- : dbName=id_ KW_SET (KW_LOCATION | KW_MANAGEDLOCATION ) newLocation=StringLiteral
1431
+ : dbName=dbSchemaName KW_SET (KW_LOCATION | KW_MANAGEDLOCATION ) newLocation=StringLiteral
1437
1432
;
1438
1433
1439
1434
alterDatabaseSuffixSetManagedLocation
1440
- : dbName=id_ KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral
1435
+ : dbName=dbSchemaName KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral
1441
1436
;
1442
1437
1443
1438
alterStatementSuffixRename
1444
- : KW_RENAME KW_TO tableName
1439
+ : KW_RENAME KW_TO tableNameCreate
1445
1440
;
1446
1441
1447
1442
alterStatementSuffixAddCol
@@ -1635,15 +1630,15 @@ alterDataConnectorStatementSuffix
1635
1630
;
1636
1631
1637
1632
alterDataConnectorSuffixProperties
1638
- : name=id_ KW_SET KW_DCPROPERTIES dcProperties
1633
+ : name=dbSchemaName KW_SET KW_DCPROPERTIES dcProperties
1639
1634
;
1640
1635
1641
1636
alterDataConnectorSuffixSetOwner
1642
- : dcName=id_ KW_SET KW_OWNER principalAlterName
1637
+ : dcName=dbSchemaName KW_SET KW_OWNER principalAlterName
1643
1638
;
1644
1639
1645
1640
alterDataConnectorSuffixSetUrl
1646
- : dcName=id_ KW_SET KW_URL newUri=StringLiteral
1641
+ : dcName=dbSchemaName KW_SET KW_URL newUri=StringLiteral
1647
1642
;
1648
1643
1649
1644
likeTableOrFile
@@ -1656,7 +1651,7 @@ likeTableOrFile
1656
1651
Rules for parsing createtable
1657
1652
*/
1658
1653
createTableStatement
1659
- : KW_CREATE temp=KW_TEMPORARY ? trans=KW_TRANSACTIONAL ? ext=KW_EXTERNAL ? KW_TABLE ifNotExists? name=tableName
1654
+ : KW_CREATE temp=KW_TEMPORARY ? trans=KW_TRANSACTIONAL ? ext=KW_EXTERNAL ? KW_TABLE ifNotExists? name=tableNameCreate
1660
1655
( likeTableOrFile
1661
1656
createTablePartitionSpec?
1662
1657
tableRowFormat?
@@ -1674,7 +1669,7 @@ createTableStatement
1674
1669
tablePropertiesPrefixed?
1675
1670
(KW_AS selectStatementWithCTE)?
1676
1671
)
1677
- | KW_CREATE mgd=KW_MANAGED KW_TABLE ifNotExists? name=tableName
1672
+ | KW_CREATE mgd=KW_MANAGED KW_TABLE ifNotExists? name=tableNameCreate
1678
1673
( likeTableOrFile
1679
1674
tableRowFormat?
1680
1675
tableFileFormat?
@@ -1720,7 +1715,7 @@ dropDataConnectorStatement
1720
1715
1721
1716
tableAllColumns
1722
1717
: STAR
1723
- | tableName DOT STAR
1718
+ | tableOrView DOT STAR
1724
1719
;
1725
1720
1726
1721
// (table|column)
@@ -1816,7 +1811,7 @@ tableSample
1816
1811
;
1817
1812
1818
1813
tableSource
1819
- : tabname=tableName props=tableProperties? ts=tableSample? asOf=asOfClause? (KW_AS ? alias=id_)?
1814
+ : tabname=tableOrView props=tableProperties? ts=tableSample? asOf=asOfClause? (KW_AS ? alias=id_)?
1820
1815
;
1821
1816
1822
1817
asOfClause
@@ -1826,18 +1821,40 @@ asOfClause
1826
1821
;
1827
1822
1828
1823
uniqueJoinTableSource
1829
- : tabname=tableName ts=tableSample? (KW_AS ? alias=id_)?
1824
+ : tabname=tableOrView ts=tableSample? (KW_AS ? alias=id_)?
1825
+ ;
1826
+
1827
+ dbSchemaName
1828
+ : id_
1829
+ ;
1830
+
1831
+ dbSchemaNameCreate
1832
+ : id_
1833
+ ;
1834
+
1835
+ tableOrView
1836
+ : tableName
1837
+ | viewName
1830
1838
;
1831
1839
1832
1840
tableName
1833
1841
: db=id_ DOT tab=id_ (DOT meta=id_)?
1834
1842
| tab=id_
1835
1843
;
1836
1844
1845
+ tableNameCreate
1846
+ : db=id_ DOT tab=id_ (DOT meta=id_)?
1847
+ | tab=id_
1848
+ ;
1849
+
1837
1850
viewName
1838
1851
: (db=id_ DOT )? view=id_
1839
1852
;
1840
1853
1854
+ viewNameCreate
1855
+ : (db=id_ DOT )? view=id_
1856
+ ;
1857
+
1841
1858
subQuerySource
1842
1859
: LPAREN queryStatementExpression RPAREN KW_AS ? id_
1843
1860
;
@@ -2140,7 +2157,7 @@ trimFunction
2140
2157
// fun(par1, par2, par3)
2141
2158
function_
2142
2159
: trimFunction
2143
- | functionName
2160
+ | functionNameForInvoke
2144
2161
LPAREN
2145
2162
(star=STAR | dist=all_distinct? (selectExpression (COMMA selectExpression)*)?)
2146
2163
(
@@ -2160,9 +2177,23 @@ null_treatment
2160
2177
| KW_IGNORE KW_NULLS
2161
2178
;
2162
2179
2163
- functionName
2164
- : functionIdentifier // Keyword IF is also a function name
2180
+ functionNameForDDL
2181
+ : functionNameForInvoke
2182
+ | StringLiteral
2183
+ ;
2184
+
2185
+ functionNameForInvoke
2186
+ : userDefinedFuncName
2165
2187
| sql11ReservedKeywordsUsedAsFunctionName
2188
+ | sysFuncNames
2189
+ ;
2190
+
2191
+ userDefinedFuncName
2192
+ : functionIdentifier
2193
+ ;
2194
+
2195
+ functionNameCreate
2196
+ : functionIdentifier
2166
2197
;
2167
2198
2168
2199
castExpression
@@ -2584,12 +2615,6 @@ sysFuncNames
2584
2615
| KW_BETWEEN
2585
2616
;
2586
2617
2587
- descFuncNames
2588
- : sysFuncNames
2589
- | StringLiteral
2590
- | functionIdentifier
2591
- ;
2592
-
2593
2618
id_
2594
2619
: Identifier
2595
2620
| nonReserved
0 commit comments