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
818 stars 181 forks source link

Athena parser error - UNNEST function with AS #2223

Closed LaizaAngrest closed 1 day ago

LaizaAngrest commented 2 days ago

Describe the bug Athena parser error - UNNEST function with AS

Database Engine Athena

To Reproduce

 it('should parse a query with UNNEST and AS', function () {
    const parser = new SqlParserV2()
    const query = `
    WITH CTE AS (
      SELECT * FROM test_cte
    )
    SELECT
        organization,
        date,
        author_email,
        t.key AS tag,
        t.value AS count
    FROM CTE
    CROSS JOIN UNNEST(tags_counts) AS t (key, value)
    ORDER BY 1, 2`
    const parsedSql = parser.parse(query, WarehouseType.Athena)
    expect(parsedSql).toBeDefined()
  })