diff --git a/pegjs/bigquery.pegjs b/pegjs/bigquery.pegjs index 424eccf9..f772afed 100644 --- a/pegjs/bigquery.pegjs +++ b/pegjs/bigquery.pegjs @@ -1891,7 +1891,9 @@ tablesample //NOTE that, the table assigned to `var` shouldn't write in `table_join` table_base - = from_unnest_item + = from_unnest_item / e:func_call __ alias:alias_clause? { + return { type: 'expr', expr: e, as: alias }; + } / t:table_name ht:hint? __ ts:tablesample? __ diff --git a/test/bigquery.spec.js b/test/bigquery.spec.js index 6995f2f7..8b9ac022 100644 --- a/test/bigquery.spec.js +++ b/test/bigquery.spec.js @@ -965,4 +965,12 @@ describe('BigQuery', () => { ast = parser.parse(sql, opt) expect(ast.columnList).to.be.eql(['select::null::my_date']) }) + it('should support table function in from clause', () => { + let sql = 'SELECT * FROM table_function();' + expect(getParsedSql(sql, opt)).to.equal('SELECT * FROM table_function()') + sql = 'SELECT * FROM table_function(1,2,3);' + expect(getParsedSql(sql, opt)).to.equal('SELECT * FROM table_function(1, 2, 3)') + sql = 'SELECT * FROM table_function(@param1, @param2, @param3);' + expect(getParsedSql(sql, opt)).to.equal('SELECT * FROM table_function(@param1, @param2, @param3)') + }) })