Skip to content

Commit 102b96d

Browse files
committed
feat: support table function in bigquery
1 parent bf4796f commit 102b96d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

pegjs/bigquery.pegjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,9 @@ tablesample
18911891

18921892
//NOTE that, the table assigned to `var` shouldn't write in `table_join`
18931893
table_base
1894-
= from_unnest_item
1894+
= from_unnest_item / e:func_call __ alias:alias_clause? {
1895+
return { type: 'expr', expr: e, as: alias };
1896+
}
18951897
/ t:table_name
18961898
ht:hint? __
18971899
ts:tablesample? __

test/bigquery.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,4 +965,12 @@ describe('BigQuery', () => {
965965
ast = parser.parse(sql, opt)
966966
expect(ast.columnList).to.be.eql(['select::null::my_date'])
967967
})
968+
it('should support table function in from clause', () => {
969+
let sql = 'SELECT * FROM table_function();'
970+
expect(getParsedSql(sql, opt)).to.equal('SELECT * FROM table_function()')
971+
sql = 'SELECT * FROM table_function(1,2,3);'
972+
expect(getParsedSql(sql, opt)).to.equal('SELECT * FROM table_function(1, 2, 3)')
973+
sql = 'SELECT * FROM table_function(@param1, @param2, @param3);'
974+
expect(getParsedSql(sql, opt)).to.equal('SELECT * FROM table_function(@param1, @param2, @param3)')
975+
})
968976
})

0 commit comments

Comments
 (0)