Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gaussdb support partitioned by in ddl #6196

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,34 @@ protected void parseCreateTableRest(SQLCreateTableStatement stmt) {
if (partitionClause != null) {
gdStmt.setPartitionBy(partitionClause);
}
if (lexer.nextIf(Token.PARTITIONED)) {
accept(Token.BY);
accept(Token.LPAREN);

for (; ; ) {
if (lexer.token() != Token.IDENTIFIER) {
throw new ParserException("expect identifier. " + lexer.info());
}

SQLColumnDefinition column = this.exprParser.parseColumn();
stmt.addPartitionColumn(column);

if (lexer.isKeepComments() && lexer.hasComment()) {
column.addAfterComment(lexer.readAndResetComments());
}

if (lexer.token() != Token.COMMA) {
break;
} else {
lexer.nextToken();
if (lexer.isKeepComments() && lexer.hasComment()) {
column.addAfterComment(lexer.readAndResetComments());
}
}
}

accept(Token.RPAREN);
}
}

public SQLPartitionBy parsePartitionBy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected Keywords loadKeywords() {
map.put("PARTIAL", Token.PARTIAL);
map.put("KEY", Token.KEY);
map.put("OVERWRITE", Token.OVERWRITE);
map.put("PARTITIONED", Token.PARTITIONED);
map.putAll(super.loadKeywords().getKeywords());
return new Keywords(map);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ protected void printCollate(SQLExpr collate) {

@Override
protected void printPartitionedBy(SQLCreateTableStatement x) {
super.printPartitionedBy(x);
if (x instanceof GaussDbCreateTableStatement) {
SQLPartitionBy partitionBy = ((GaussDbCreateTableStatement) x).getPartitionBy();
if (partitionBy == null) {
Expand Down
21 changes: 20 additions & 1 deletion core/src/test/resources/bvt/parser/gaussdb/1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,23 @@ INSERT OVERWRITE TABLE edw_dwi.dwi_pub_eps_itsm_work_order_history_da PARTITION
SELECT historyid AS history_id, workorderid AS work_order_id, operationownerid AS operation_owner_id, operationtime AS operation_time, description AS description
, operation AS operation
FROM smart_sdi.sdi_itsm_public_workorderhistory_da
WHERE dt = '${deal_date}'
WHERE dt = '${deal_date}'
------------------------------------------------------------------------------------------------------------------------
create table if not exists edw_dwr.dwr_sale_tran_order_finance_scheme_da
(
order_id string comment '订单号'
,smart_id string comment 'smartId'
,vehicle_type string comment '车型'
) comment '订单金融方案'
partitioned by (dt string comment 'YYYY-MM-DD')
;
--------------------
CREATE TABLE IF NOT EXISTS edw_dwr.dwr_sale_tran_order_finance_scheme_da (
order_id string COMMENT '订单号',
smart_id string COMMENT 'smartId',
vehicle_type string COMMENT '车型'
)
COMMENT = '订单金融方案'
PARTITIONED BY (
dt string COMMENT 'YYYY-MM-DD'
);
Loading