Skip to content

Commit

Permalink
support big query support delete
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Oct 28, 2024
1 parent 6b7ea76 commit e5fb686
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.alibaba.druid.sql.dialect.bigquery.parser;

import com.alibaba.druid.sql.ast.SQLDeclareItem;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
import com.alibaba.druid.sql.ast.statement.*;
Expand Down Expand Up @@ -130,4 +131,21 @@ protected SQLStatement parseAssert() {
}
return stmt;
}

public SQLDeleteStatement parseDeleteStatement() {
SQLDeleteStatement deleteStatement = new SQLDeleteStatement(getDbType());

accept(Token.DELETE);
lexer.nextIf(Token.FROM);

SQLTableSource tableSource = createSQLSelectParser().parseTableSource();
deleteStatement.setTableSource(tableSource);

if (lexer.nextIf(Token.WHERE)) {
SQLExpr where = this.exprParser.expr();
deleteStatement.setWhere(where);
}

return deleteStatement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4746,11 +4746,8 @@ protected SQLUpdateStatement createUpdateStatement() {
public SQLDeleteStatement parseDeleteStatement() {
SQLDeleteStatement deleteStatement = new SQLDeleteStatement(getDbType());

if (lexer.token == Token.DELETE) {
lexer.nextToken();
if (lexer.token == (Token.FROM)) {
lexer.nextToken();
}
if (lexer.nextIf(Token.DELETE)) {
lexer.nextIf(Token.FROM);

if (lexer.token == Token.COMMENT) {
lexer.nextToken();
Expand Down
4 changes: 4 additions & 0 deletions core/src/test/resources/bvt/parser/bigquery/0.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
DELETE FROM `data-gojek-id-mart.risk_analytics.detail_suspicious_key` AS a
--------------------
DELETE FROM `data-gojek-id-mart.risk_analytics.detail_suspicious_key` a
------------------------------------------------------------------------------------------------------------------------
SELECT case when contains(u.roles[company_id_cross], 'report_reader') then 1 else 0 end is_report_reader from t1
--------------------
SELECT CASE
Expand Down

0 comments on commit e5fb686

Please sign in to comment.