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 - alias for each element within the unnested array #2225

Closed LaizaAngrest closed 1 day ago

LaizaAngrest commented 2 days ago

Describe the bug Athena parser error - alias for each element within the unnested array

Database Engine Athena

To Reproduce

it('should parse a query with alias for each element within the unnested array', function () {
    const parser = new SqlParserV2()
    const query = `
    SELECT id, array_agg(json_extract_scalar(elem, '$.value')) er_teams
    FROM "bronze_prod"."jira_issues"
    CROSS JOIN UNNEST(cast(json_extract(json_parse(fields), '$.customfield_10100') AS array(json))) t(elem)
    GROUP BY id`
    const parsedSql = parser.parse(query, WarehouseType.Athena)
    expect(parsedSql).toBeDefined()
  })