taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
780 stars 174 forks source link

Invalid query with generator(rowcount => in Snowflake #2009

Closed LaizaAngrest closed 1 month ago

LaizaAngrest commented 1 month ago

Describe the bug Invalid query with generator(rowcount => in Snowflake

Database Engine Snowflake

To Reproduce

it('should parse a query with generator(rowcount =>', function () {
    const parser = new SqlParserV2()
    const query = `
    select *, date(concat(left(date,7),'-01')) as date_start_month, left(date,7) as month from 
((select
  dateadd(day, '-' || seq4(), current_date()) as date
from
  table(generator(rowcount => 1095))
where date>='2022-10-01') as dates
left join
(select id, name, category, start_date, end_date, days, cost, cost/days as cost_per_day
from
(select id, name, category, start_date, end_date, cost, datediff('day',start_date, end_date)+1 as days 
from ui_other_costs
group by 1,2,3,4,5,6)
group by 1,2,3,4,5,6,7) as cost)
where dates.date between cost.start_date and cost.end_date`
    const parsedSql = parser.parse(query, WarehouseType.Snowflake)
    expect(parsedSql).toBeDefined()
  })

Expected behavior Valid query