Skip to content

Commit da77180

Browse files
authored
feat: #290 support dtstack SparkSQL/HiveSQL lifecycle (#292)
1 parent 8bb27ee commit da77180

23 files changed

Lines changed: 17920 additions & 17596 deletions

src/grammar/hive/HiveSqlLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ KW_LEADING : 'LEADING';
214214
KW_LEFT : 'LEFT';
215215
KW_LESS : 'LESS';
216216
KW_LEVEL : 'LEVEL';
217+
KW_LIFECYCLE : 'LIFECYCLE';
217218
KW_LIKE : 'LIKE';
218219
KW_LIMIT : 'LIMIT';
219220
KW_LINES : 'LINES';

src/grammar/hive/HiveSqlParser.g4

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@ tableComment
657657
: KW_COMMENT comment=StringLiteral
658658
;
659659

660+
// dtstack SparkSQL/HiveSQL lifecycle
661+
tableLifecycle
662+
: KW_LIFECYCLE Number
663+
;
664+
660665
createTablePartitionSpec
661666
: KW_PARTITIONED KW_BY (
662667
LPAREN (opt1=createTablePartitionColumnTypeSpec | opt2=createTablePartitionColumnSpec)
@@ -1630,13 +1635,17 @@ Rules for parsing createtable
16301635
createTableStatement
16311636
: KW_CREATE temp=KW_TEMPORARY? trans=KW_TRANSACTIONAL? ext=KW_EXTERNAL? KW_TABLE ifNotExists? name=tableNameCreate (
16321637
likeTableOrFile createTablePartitionSpec? tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed?
1633-
| (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? createTablePartitionSpec? tableBuckets? tableSkewed? tableRowFormat?
1634-
tableFileFormat? tableLocation? tablePropertiesPrefixed? (KW_AS selectStatementWithCTE)?
1638+
| (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? tableLifecycle? createTablePartitionSpec? tableBuckets? tableSkewed?
1639+
tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? (
1640+
KW_AS selectStatementWithCTE
1641+
)?
16351642
)
16361643
| KW_CREATE mgd=KW_MANAGED KW_TABLE ifNotExists? name=tableNameCreate (
16371644
likeTableOrFile tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed?
1638-
| (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? createTablePartitionSpec? tableBuckets? tableSkewed? tableRowFormat?
1639-
tableFileFormat? tableLocation? tablePropertiesPrefixed? (KW_AS selectStatementWithCTE)?
1645+
| (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? tableLifecycle? createTablePartitionSpec? tableBuckets? tableSkewed?
1646+
tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? (
1647+
KW_AS selectStatementWithCTE
1648+
)?
16401649
)
16411650
;
16421651

@@ -2685,6 +2694,7 @@ nonReserved
26852694
| KW_KILL
26862695
| KW_LAST
26872696
| KW_LEVEL
2697+
| KW_LIFECYCLE
26882698
| KW_LIMIT
26892699
| KW_LINES
26902700
| KW_LOAD

src/grammar/spark/SparkSqlLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ KW_LATERAL : 'LATERAL';
217217
KW_LAZY : 'LAZY';
218218
KW_LEADING : 'LEADING';
219219
KW_LEFT : 'LEFT';
220+
KW_LIFECYCLE : 'LIFECYCLE';
220221
KW_LIKE : 'LIKE';
221222
KW_ILIKE : 'ILIKE';
222223
KW_LIMIT : 'LIMIT';

src/grammar/spark/SparkSqlParser.g4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ statement
6565
| createFileFormat
6666
| locationSpec
6767
| (KW_TBLPROPERTIES tableProps=propertyList)
68+
| tableLifecycle
6869
)* # createTableLike
6970
| replaceTableHeader (LEFT_PAREN createOrReplaceTableColTypeList RIGHT_PAREN)? tableProvider? createTableClauses (
7071
KW_AS? query
@@ -351,9 +352,15 @@ createTableClauses
351352
| locationSpec
352353
| commentSpec
353354
| (KW_TBLPROPERTIES tableProps=propertyList)
355+
| tableLifecycle
354356
)*
355357
;
356358

359+
// dtstack SparkSQL/HiveSQL lifecycle
360+
tableLifecycle
361+
: KW_LIFECYCLE INTEGER_VALUE
362+
;
363+
357364
propertyList
358365
: LEFT_PAREN property (COMMA property)* RIGHT_PAREN
359366
;
@@ -1849,6 +1856,7 @@ nonReserved
18491856
| KW_LAST
18501857
| KW_LAZY
18511858
| KW_LEADING
1859+
| KW_LIFECYCLE
18521860
| KW_LIKE
18531861
| KW_LONG
18541862
| KW_ILIKE

src/lib/hive/HiveSqlLexer.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)