Skip to content

Commit

Permalink
for #2084, merge BaseRule and SQLServerBase
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Mar 30, 2019
1 parent b241337 commit a5a95b4
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ primaryKey
;

columnNames
: LP_ columnName (COMMA_ columnName)* RP_
: LP_ columnNameWithSort (COMMA_ columnNameWithSort)* RP_
;

exprs
Expand Down Expand Up @@ -165,7 +165,7 @@ caseExpress
;

privateExprOfDb
: matchNone
: windowedFunction | atTimeZoneExpr | castExpr | convertExpr
;

variable
Expand Down Expand Up @@ -207,9 +207,9 @@ collateClause
;

orderByClause
: ORDER BY orderByItem (COMMA_ orderByItem)*
: ORDER BY orderByExpr (COMMA_ orderByExpr)*
;

orderByItem
: (columnName | number | expr) (ASC | DESC)?
;
Expand All @@ -218,6 +218,133 @@ asterisk
: ASTERISK_
;

dataType
: dataTypeName_ (dataTypeLength | LP_ MAX RP_ | LP_ (CONTENT | DOCUMENT)? ignoredIdentifier_ RP_)?
;

dataTypeName_
: IDENTIFIER_
;

atTimeZoneExpr
: IDENTIFIER_ (WITH TIME ZONE)? STRING_
;

castExpr
: CAST LP_ expr AS dataType (LP_ NUMBER_ RP_)? RP_
;

convertExpr
: CONVERT (dataType (LP_ NUMBER_ RP_)? COMMA_ expr (COMMA_ NUMBER_)?)
;

windowedFunction
: functionCall overClause
;

overClause
: OVER LP_ partitionByClause? orderByClause? rowRangeClause? RP_
;

partitionByClause
: PARTITION BY expr (COMMA_ expr)*
;

orderByExpr
: expr (COLLATE collationName)? (ASC | DESC)?
;

rowRangeClause
: (ROWS | RANGE) windowFrameExtent
;

windowFrameExtent
: windowFramePreceding | windowFrameBetween
;

windowFrameBetween
: BETWEEN windowFrameBound AND windowFrameBound
;

windowFrameBound
: windowFramePreceding | windowFrameFollowing
;

windowFramePreceding
: UNBOUNDED PRECEDING | NUMBER_ PRECEDING | CURRENT ROW
;

windowFrameFollowing
: UNBOUNDED FOLLOWING | NUMBER_ FOLLOWING | CURRENT ROW
;

columnNameWithSort
: columnName (ASC | DESC)?
;

indexOption
: FILLFACTOR EQ_ NUMBER_
| eqOnOffOption
| (COMPRESSION_DELAY | MAX_DURATION) eqTime
| MAXDOP EQ_ NUMBER_
| compressionOption onPartitionClause?
;

compressionOption
: DATA_COMPRESSION EQ_ (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE)
;

eqTime
: EQ_ NUMBER_ (MINUTES)?
;

eqOnOffOption
: eqKey eqOnOff
;

eqKey
: PAD_INDEX
| SORT_IN_TEMPDB
| IGNORE_DUP_KEY
| STATISTICS_NORECOMPUTE
| STATISTICS_INCREMENTAL
| DROP_EXISTING
| ONLINE
| RESUMABLE
| ALLOW_ROW_LOCKS
| ALLOW_PAGE_LOCKS
| COMPRESSION_DELAY
| SORT_IN_TEMPDB
;

eqOnOff
: EQ_ (ON | OFF)
;

onPartitionClause
: ON PARTITIONS LP_ partitionExpressions RP_
;

partitionExpressions
: partitionExpression (COMMA_ partitionExpression)*
;

partitionExpression
: NUMBER_ | numberRange
;

numberRange
: NUMBER_ TO NUMBER_
;

lowPriorityLockWait
: WAIT_AT_LOW_PRIORITY LP_ MAX_DURATION EQ_ NUMBER_ (MINUTES)? COMMA_ ABORT_AFTER_WAIT EQ_ (NONE | SELF | BLOCKERS) RP_
;

onLowPriorLockWait
: ON (LP_ lowPriorityLockWait RP_)?
;

ignoredIdentifier_
: IDENTIFIER_
;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

grammar SQLServerDCLStatement;

import Symbol, Keyword, Literals, SQLServerBase, BaseRule;
import Symbol, Keyword, Literals, BaseRule;

grant
: GRANT (classPrivilegesClause_ | classTypePrivilegesClause_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

grammar SQLServerDDLStatement;

import Symbol, Keyword, Literals, SQLServerBase, BaseRule;
import Symbol, Keyword, Literals, BaseRule;

createIndex
: CREATE UNIQUE? (CLUSTERED | NONCLUSTERED)? INDEX indexName ON tableName columnNames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

grammar SQLServerTCLStatement;

import Symbol, Keyword, Literals, SQLServerBase;
import Symbol, Keyword, Literals;

setTransaction
: SET TRANSACTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

grammar SQLServerStatement;

import Keyword, Symbol, SQLServerBase, SQLServerDDLStatement, SQLServerTCLStatement, SQLServerDCLStatement;
import Keyword, Symbol, SQLServerDDLStatement, SQLServerTCLStatement, SQLServerDCLStatement;

execute
: (createIndex
Expand Down

0 comments on commit a5a95b4

Please sign in to comment.