From 9faeba9fb76519eebf8f831889a6b8af2e17a321 Mon Sep 17 00:00:00 2001 From: wenshao Date: Thu, 19 Dec 2024 11:15:15 +0800 Subject: [PATCH] improve sql parser bigquery support --- .../druid/sql/ast/statement/SQLMergeStatement.java | 12 ++++++++++++ .../druid/sql/ast/statement/SQLUpdateSetItem.java | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLMergeStatement.java b/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLMergeStatement.java index a9e3256096..91483cd4b1 100644 --- a/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLMergeStatement.java +++ b/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLMergeStatement.java @@ -117,6 +117,18 @@ public void addItem(SQLUpdateSetItem item) { this.items.add(item); } + public SQLUpdateSetItem findItemByColumn(SQLExpr column) { + if (column == null) { + return null; + } + for (SQLUpdateSetItem item : items) { + if (item.getColumn().equals(column)) { + return item; + } + } + return null; + } + @Override public void accept0(SQLASTVisitor v) { if (v.visit(this)) { diff --git a/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLUpdateSetItem.java b/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLUpdateSetItem.java index 0cb654f6e9..ca98eb25ee 100644 --- a/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLUpdateSetItem.java +++ b/core/src/main/java/com/alibaba/druid/sql/ast/statement/SQLUpdateSetItem.java @@ -30,6 +30,11 @@ public class SQLUpdateSetItem extends SQLObjectImpl implements SQLReplaceable { public SQLUpdateSetItem() { } + public SQLUpdateSetItem(SQLExpr column, SQLExpr value) { + this.setColumn(column); + this.setValue(value); + } + public SQLExpr getColumn() { return column; }