Skip to content

Commit

Permalink
Support to parse and generate unnest with offset sql.
Browse files Browse the repository at this point in the history
  • Loading branch information
lingo-xp authored and wenshao committed Dec 25, 2024
1 parent 19adb32 commit b166cbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4913,15 +4913,15 @@ public boolean visit(SQLSubqueryTableSource x) {
final List<SQLName> columns = x.getColumns();
final String alias = x.getAlias();
if (alias != null) {
if (columns.size() > 0) {
if (!columns.isEmpty()) {
print0(" AS ");
} else {
print(' ');
}
print0(alias);
}

if (columns.size() > 0) {
if (!columns.isEmpty()) {
print0(" (");
for (int i = 0; i < columns.size(); i++) {
if (i != 0) {
Expand Down Expand Up @@ -4983,6 +4983,11 @@ public boolean visit(SQLUnnestTableSource x) {
print(')');
}

if (x.getOffset() != null) {
print0(ucase ? " WITH OFFSET AS " : " with offset as ");
x.getOffset().accept(this);
}

return false;
}

Expand Down
7 changes: 6 additions & 1 deletion core/src/test/resources/bvt/parser/bigquery/9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,9 @@ x.y.z
--------------------
UPDATE a.b.c tbl
SET tbl.x1 = oba.x2, tbl.x3 = oba.x4, tbl.x5 = oba.x6, tbl.x7 = oba.x8, tbl.x9 = oba.x10, tbl.x11 = oba.x12, tbl.x13 = oba.x14
FROM x.y.z
FROM x.y.z
------------------------------------------------------------------------------------------------------------------------
select b from t, unnest(a) c1 with offset as c2
--------------------
SELECT b
FROM t, UNNEST(a) AS c1 WITH OFFSET AS c2

0 comments on commit b166cbb

Please sign in to comment.