---
source: crates/squawk_parser/tests/tests.rs
input_file: crates/squawk_parser/tests/data/err/select.sql
---
SOURCE_FILE
  COMMENT "--- via https://duckdb.org/docs/stable/sql/dialect/friendly_sql.html#trailing-commas"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE "\n  "
      TARGET_LIST
        TARGET
          LITERAL
            INT_NUMBER "42"
          WHITESPACE " "
          AS_NAME
            AS_KW "as"
            WHITESPACE " "
            NAME
              IDENT "x"
        COMMA ","
        WHITESPACE "\n  "
        TARGET
          ARRAY_EXPR
            ARRAY_KW "array"
            L_BRACK "["
            LITERAL
              STRING "'a'"
            COMMA ","
            WHITESPACE " "
            LITERAL
              STRING "'b'"
            COMMA ","
            WHITESPACE " "
            LITERAL
              STRING "'c'"
            ERROR
              COMMA ","
            R_BRACK "]"
          WHITESPACE " "
          AS_NAME
            AS_KW "as"
            WHITESPACE " "
            NAME
              IDENT "y"
        COMMA ","
        WHITESPACE "\n  "
        TARGET
          LITERAL
            STRING "'hello world'"
          WHITESPACE " "
          AS_NAME
            AS_KW "as"
            WHITESPACE " "
            NAME
              IDENT "z"
        ERROR
          COMMA ","
  WHITESPACE "\n"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- trailing comma in column list"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
        WHITESPACE " "
        ALIAS
          AS_KW "as"
          WHITESPACE " "
          NAME
            IDENT "u"
          COLUMN_LIST
            L_PAREN "("
            COLUMN
              NAME
                IDENT "a"
            ERROR
              COMMA ","
            R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- missing comma"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          NAME_REF
            IDENT "a"
        COMMA ","
        WHITESPACE " "
        TARGET
          NAME_REF
            IDENT "b"
          WHITESPACE " "
          AS_NAME
            NAME
              IDENT "c"
        WHITESPACE "  "
        TARGET
          NAME_REF
            IDENT "d"
        COMMA ","
        WHITESPACE " "
        TARGET
          NAME_REF
            IDENT "e"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
  SEMICOLON ";"
  WHITESPACE "\n"
  COMMENT "--          ^ ^ comma missing"
  WHITESPACE "\n"
  COMMENT "--          \\-- this is a label"
  WHITESPACE "\n\n"
  COMMENT "-- distinct on missing a comma"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "SELECT"
      WHITESPACE " "
      DISTINCT_CLAUSE
        DISTINCT_KW "DISTINCT"
        WHITESPACE " "
        ON_KW "ON"
        WHITESPACE " "
        L_PAREN "("
        NAME_REF
          IDENT "a"
        WHITESPACE " "
        NAME_REF
          IDENT "b"
        R_PAREN ")"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          NAME_REF
            IDENT "a"
        COMMA ","
        WHITESPACE " "
        TARGET
          NAME_REF
            IDENT "b"
        COMMA ","
        WHITESPACE " "
        TARGET
          NAME_REF
            IDENT "c"
    WHITESPACE "\n    "
    FROM_CLAUSE
      FROM_KW "FROM"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE "\n    "
    ORDER_BY_CLAUSE
      ORDER_KW "order"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      SORT_BY_LIST
        SORT_BY
          NAME_REF
            IDENT "a"
        COMMA ","
        WHITESPACE " "
        SORT_BY
          NAME_REF
            IDENT "b"
          WHITESPACE " "
          SORT_DESC
            DESC_KW "desc"
  SEMICOLON ";"
  WHITESPACE " \n\n"
  COMMENT "-- group bys with missing commas"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE " "
    GROUP_BY_CLAUSE
      GROUP_KW "group"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      GROUP_BY_LIST
        GROUPING_ROLLUP
          ROLLUP_KW "rollup"
          WHITESPACE " "
          L_PAREN "("
          LITERAL
            INT_NUMBER "1"
          WHITESPACE " "
          LITERAL
            INT_NUMBER "2"
          WHITESPACE " "
          LITERAL
            INT_NUMBER "3"
          R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE " "
    GROUP_BY_CLAUSE
      GROUP_KW "group"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      GROUP_BY_LIST
        GROUPING_CUBE
          CUBE_KW "cube"
          WHITESPACE " "
          L_PAREN "("
          LITERAL
            INT_NUMBER "1"
          WHITESPACE " "
          LITERAL
            INT_NUMBER "2"
          WHITESPACE " "
          LITERAL
            INT_NUMBER "3"
          R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "u"
    WHITESPACE "\n  "
    GROUP_BY_CLAUSE
      GROUP_KW "group"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      GROUP_BY_LIST
        GROUPING_SETS
          GROUPING_KW "grouping"
          WHITESPACE " "
          SETS_KW "sets"
          L_PAREN "("
          GROUPING_EXPR
            TUPLE_EXPR
              L_PAREN "("
              LITERAL
                INT_NUMBER "1"
              WHITESPACE " "
              LITERAL
                INT_NUMBER "2"
              R_PAREN ")"
          WHITESPACE " "
          GROUPING_SETS
            GROUPING_KW "grouping"
            WHITESPACE " "
            SETS_KW "sets"
            L_PAREN "("
            GROUPING_EXPR
              TUPLE_EXPR
                L_PAREN "("
                R_PAREN ")"
            COMMA ","
            WHITESPACE " "
            GROUPING_SETS
              GROUPING_KW "grouping"
              WHITESPACE " "
              SETS_KW "sets"
              L_PAREN "("
              GROUPING_EXPR
                TUPLE_EXPR
                  L_PAREN "("
                  R_PAREN ")"
              R_PAREN ")"
            R_PAREN ")"
          R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- trailing comma in args"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CALL_EXPR
            NAME_REF
              IDENT "f"
            ARG_LIST
              L_PAREN "("
              LITERAL
                INT_NUMBER "1"
              ERROR
                COMMA ","
              R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- missing args"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CALL_EXPR
            NAME_REF
              IDENT "f"
            ARG_LIST
              L_PAREN "("
              NAME_REF
                IDENT "a"
              COMMA ","
              ERROR
                COMMA ","
              ERROR
                COMMA ","
              ERROR
                COMMA ","
              ERROR
                COMMA ","
              R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- in can only be used with tuples / sub queries"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          BIN_EXPR
            LITERAL
              INT_NUMBER "1"
            WHITESPACE " "
            IN_KW "in"
            WHITESPACE " "
            NAME_REF
              IDENT "c"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- type cast must use a string literal"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          NAME_REF
            NUMERIC_KW "numeric"
        WHITESPACE " "
        TARGET
          LITERAL
            INT_NUMBER "1234"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- missing comma"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          ARRAY_EXPR
            ARRAY_KW "array"
            L_BRACK "["
            LITERAL
              INT_NUMBER "1"
            WHITESPACE " "
            LITERAL
              INT_NUMBER "2"
            COMMA ","
            LITERAL
              INT_NUMBER "3"
            R_BRACK "]"
  SEMICOLON ";"
  WHITESPACE "\n"
  COMMENT "-- extra comma"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          ARRAY_EXPR
            ARRAY_KW "array"
            L_BRACK "["
            LITERAL
              INT_NUMBER "1"
            COMMA ","
            WHITESPACE " "
            ERROR
              COMMA ","
            LITERAL
              INT_NUMBER "3"
            R_BRACK "]"
  SEMICOLON ";"
  WHITESPACE "\n"
  COMMENT "-- trailing comma"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          ARRAY_EXPR
            ARRAY_KW "array"
            L_BRACK "["
            LITERAL
              INT_NUMBER "1"
            COMMA ","
            LITERAL
              INT_NUMBER "2"
            COMMA ","
            LITERAL
              INT_NUMBER "3"
            ERROR
              COMMA ","
            R_BRACK "]"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- group by all, order by all"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE " "
    GROUP_BY_CLAUSE
      GROUP_KW "group"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      ALL_KW "all"
    WHITESPACE " "
    ORDER_BY_CLAUSE
      ORDER_KW "order"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      SORT_BY_LIST
        SORT_BY
          ERROR
            ALL_KW "all"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- cast with malformed type mod args"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CAST_EXPR
            CAST_KW "cast"
            L_PAREN "("
            NAME_REF
              IDENT "x"
            WHITESPACE " "
            AS_KW "as"
            WHITESPACE " "
            CHAR_TYPE
              VARCHAR_KW "varchar"
              ARG_LIST
                L_PAREN "("
                ARG
                  LITERAL
                    INT_NUMBER "100"
                WHITESPACE " "
                ARG
                  LITERAL
                    INT_NUMBER "200"
                R_PAREN ")"
            R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CAST_EXPR
            CAST_KW "cast"
            L_PAREN "("
            NAME_REF
              IDENT "x"
            WHITESPACE " "
            AS_KW "as"
            WHITESPACE " "
            CHAR_TYPE
              VARCHAR_KW "varchar"
              ARG_LIST
                L_PAREN "("
                ARG
                  LITERAL
                    INT_NUMBER "100"
                COMMA ","
                WHITESPACE " "
                ERROR
                  COMMA ","
                WHITESPACE " "
                ARG
                  LITERAL
                    INT_NUMBER "200"
                R_PAREN ")"
            R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CAST_EXPR
            CAST_KW "cast"
            L_PAREN "("
            NAME_REF
              IDENT "x"
            WHITESPACE " "
            AS_KW "as"
            WHITESPACE " "
            PATH_TYPE
              PATH
                PATH_SEGMENT
                  NAME_REF
                    IDENT "t"
              ARG_LIST
                L_PAREN "("
                ARG
                  NAME_REF
                    IDENT "a"
                COMMA ","
                WHITESPACE " "
                ARG
                  NAME_REF
                    IDENT "b"
                ERROR
                  COMMA ","
                R_PAREN ")"
            R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- regression test: this would cause the parser to get stuck & panic, now it"
  WHITESPACE "\n"
  COMMENT "-- warns about a missing semicolon"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE " "
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- extra comma"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          NAME_REF
            IDENT "a"
        ERROR
          COMMA ","
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- case missing then expr"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CASE_EXPR
            CASE_KW "case"
            WHITESPACE " "
            WHEN_CLAUSE_LIST
              WHEN_CLAUSE
                WHEN_KW "when"
                WHITESPACE " "
                LITERAL
                  INT_NUMBER "1"
                WHITESPACE " "
                THEN_KW "then"
            WHITESPACE " "
            END_KW "end"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- case missing when expr"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CASE_EXPR
            CASE_KW "case"
            WHITESPACE " "
            WHEN_CLAUSE_LIST
              WHEN_CLAUSE
                WHEN_KW "when"
                WHITESPACE " "
                THEN_KW "then"
                WHITESPACE " "
                NAME_REF
                  IDENT "x"
            WHITESPACE " "
            END_KW "end"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- case missing else expr"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          CASE_EXPR
            CASE_KW "case"
            WHITESPACE " "
            WHEN_CLAUSE_LIST
              WHEN_CLAUSE
                WHEN_KW "when"
                WHITESPACE " "
                LITERAL
                  INT_NUMBER "1"
                WHITESPACE " "
                THEN_KW "then"
                WHITESPACE " "
                LITERAL
                  INT_NUMBER "2"
            WHITESPACE " "
            ELSE_CLAUSE
              ELSE_KW "else"
            WHITESPACE " "
            END_KW "end"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- select without semi and trailing create table"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE "\n"
  CREATE_TABLE
    CREATE_KW "create"
    WHITESPACE " "
    TABLE_KW "table"
    WHITESPACE " "
    PATH
      PATH_SEGMENT
        NAME
          IDENT "users"
    WHITESPACE " "
    TABLE_ARG_LIST
      L_PAREN "("
      R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n\n"
  COMMENT "-- select do"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE " \n"
  DO
    DO_KW "do"
    WHITESPACE " "
    LITERAL
      STRING "'begin null; end'"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- select grant"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE " \n"
  GRANT
    GRANT_KW "grant"
    WHITESPACE " "
    REVOKE_COMMAND_LIST
      REVOKE_COMMAND
        SELECT_KW "select"
    WHITESPACE " "
    ON_KW "on"
    WHITESPACE " "
    PATH
      PATH_SEGMENT
        NAME_REF
          IDENT "t"
    WHITESPACE " "
    TO_KW "to"
    WHITESPACE " "
    ROLE_REF_LIST
      ROLE_REF
        NAME_REF
          IDENT "u"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- where with missing expr"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE " "
    WHERE_CLAUSE
      WHERE_KW "where"
      WHITESPACE " "
      ERROR
        AND_KW "and"
      WHITESPACE " "
      BIN_EXPR
        NAME_REF
          IDENT "c"
        WHITESPACE " "
        R_ANGLE ">"
        WHITESPACE " "
        LITERAL
          INT_NUMBER "10"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE " "
    WHERE_CLAUSE
      WHERE_KW "where"
      WHITESPACE " "
      ERROR
        OR_KW "or"
      WHITESPACE " "
      BIN_EXPR
        NAME_REF
          IDENT "c"
        WHITESPACE " "
        NEQ "!="
        WHITESPACE " "
        LITERAL
          STRING "'b'"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
    WHITESPACE " "
    HAVING_CLAUSE
      HAVING_KW "having"
      WHITESPACE " "
      ERROR
        AND_KW "and"
      WHITESPACE " "
      BIN_EXPR
        NAME_REF
          IDENT "c"
        WHITESPACE " "
        R_ANGLE ">"
        WHITESPACE " "
        LITERAL
          INT_NUMBER "10"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
    WHITESPACE " "
    HAVING_CLAUSE
      HAVING_KW "having"
      WHITESPACE " "
      ERROR
        OR_KW "or"
      WHITESPACE " "
      BIN_EXPR
        NAME_REF
          IDENT "c"
        WHITESPACE " "
        NEQ "!="
        WHITESPACE " "
        LITERAL
          STRING "'b'"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      JOIN_EXPR
        FROM_ITEM
          NAME_REF
            IDENT "t"
        WHITESPACE " "
        JOIN
          JOIN_INNER
            JOIN_KW "join"
          WHITESPACE " "
          FROM_ITEM
            NAME_REF
              IDENT "u"
          WHITESPACE " "
          ON_CLAUSE
            ON_KW "on"
            WHITESPACE " "
            ERROR
              AND_KW "and"
            WHITESPACE " "
            LITERAL
              TRUE_KW "true"
  SEMICOLON ";"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      JOIN_EXPR
        FROM_ITEM
          NAME_REF
            IDENT "t"
        WHITESPACE " "
        JOIN
          JOIN_INNER
            JOIN_KW "join"
          WHITESPACE " "
          FROM_ITEM
            NAME_REF
              IDENT "u"
          WHITESPACE " "
          ON_CLAUSE
            ON_KW "on"
            WHITESPACE " "
            ERROR
              OR_KW "or"
            WHITESPACE " "
            LITERAL
              TRUE_KW "true"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- join after the where"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE "\n"
    WHERE_CLAUSE
      WHERE_KW "where"
      WHITESPACE " "
      BIN_EXPR
        NAME_REF
          IDENT "x"
        WHITESPACE " "
        R_ANGLE ">"
        WHITESPACE " "
        LITERAL
          INT_NUMBER "1"
    WHITESPACE "\n"
    ERROR
      JOIN
        JOIN_INNER
          JOIN_KW "join"
        WHITESPACE " "
        FROM_ITEM
          NAME_REF
            IDENT "k"
        WHITESPACE " "
        ON_CLAUSE
          ON_KW "on"
          WHITESPACE " "
          LITERAL
            TRUE_KW "true"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- having after order by instead of before"
  WHITESPACE "\n"
  SELECT
    WITH_CLAUSE
      WITH_KW "with"
      WHITESPACE " "
      WITH_TABLE
        NAME
          IDENT "t"
        WHITESPACE " "
        AS_KW "as"
        WHITESPACE " "
        L_PAREN "("
        SELECT
          SELECT_CLAUSE
            SELECT_KW "select"
            WHITESPACE " "
            TARGET_LIST
              TARGET
                LITERAL
                  INT_NUMBER "2"
                WHITESPACE " "
                AS_NAME
                  NAME
                    IDENT "b"
        R_PAREN ")"
    WHITESPACE "\n"
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          LITERAL
            INT_NUMBER "1"
          WHITESPACE " "
          AS_NAME
            NAME
              IDENT "a"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
    WHITESPACE "\n"
    GROUP_BY_CLAUSE
      GROUP_KW "group"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      GROUP_BY_LIST
        GROUPING_EXPR
          NAME_REF
            IDENT "a"
    WHITESPACE "\n"
    ORDER_BY_CLAUSE
      ORDER_KW "order"
      WHITESPACE " "
      BY_KW "by"
      WHITESPACE " "
      SORT_BY_LIST
        SORT_BY
          NAME_REF
            IDENT "a"
    WHITESPACE "\n"
    ERROR
      HAVING_CLAUSE
        HAVING_KW "having"
        WHITESPACE " "
        BIN_EXPR
          NAME_REF
            IDENT "a"
          WHITESPACE " "
          R_ANGLE ">"
          WHITESPACE " "
          LITERAL
            INT_NUMBER "10"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- select end"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE "\n"
  COMMIT
    END_KW "end"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- select analyze/analyse"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE "\n"
  ANALYZE
    ANALYZE_KW "analyze"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE "\n"
  ANALYZE
    ANALYSE_KW "analyse"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- select with"
  WHITESPACE "\n\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
  WHITESPACE "\n"
  SELECT
    WITH_CLAUSE
      WITH_KW "with"
      WHITESPACE " "
      WITH_TABLE
        NAME
          IDENT "t"
        WHITESPACE " "
        AS_KW "as"
        WHITESPACE " "
        L_PAREN "("
        SELECT
          SELECT_CLAUSE
            SELECT_KW "select"
            WHITESPACE " "
            TARGET_LIST
              TARGET
                LITERAL
                  INT_NUMBER "1"
        R_PAREN ")"
    WHITESPACE "\n"
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          STAR "*"
    WHITESPACE " "
    FROM_CLAUSE
      FROM_KW "from"
      WHITESPACE " "
      FROM_ITEM
        NAME_REF
          IDENT "t"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- trailing comma at EOF"
  WHITESPACE "\n"
  SELECT
    SELECT_CLAUSE
      SELECT_KW "select"
      WHITESPACE " "
      TARGET_LIST
        TARGET
          LITERAL
            INT_NUMBER "1"
        ERROR
          COMMA ","
  WHITESPACE "\n"
---
error[syntax-error]: unexpected trailing comma
  ╭▸ 
4 │   array['a', 'b', 'c',] as y,
  ╰╴                     ━
error[syntax-error]: unexpected trailing comma
  ╭▸ 
5 │   'hello world' as z,
  ╰╴                    ━
error[syntax-error]: unexpected trailing comma
  ╭▸ 
9 │ select * from t as u(a,);
  ╰╴                      ━
error[syntax-error]: missing comma
   ╭▸ 
12 │ select a, b c  d, e from t;
   ╰╴             ━
error[syntax-error]: expected COMMA
   ╭▸ 
17 │ SELECT DISTINCT ON (a b) a, b, c
   ╰╴                     ━
error[syntax-error]: expected COMMA
   ╭▸ 
22 │ select * from t group by rollup (1 2 3);
   ╰╴                                  ━
error[syntax-error]: expected COMMA
   ╭▸ 
22 │ select * from t group by rollup (1 2 3);
   ╰╴                                    ━
error[syntax-error]: expected COMMA
   ╭▸ 
23 │ select * from t group by cube (1 2 3);
   ╰╴                                ━
error[syntax-error]: expected COMMA
   ╭▸ 
23 │ select * from t group by cube (1 2 3);
   ╰╴                                  ━
error[syntax-error]: expected COMMA
   ╭▸ 
25 │   group by grouping sets((1 2) grouping sets((), grouping sets(())));
   ╰╴                           ━
error[syntax-error]: expected COMMA
   ╭▸ 
25 │   group by grouping sets((1 2) grouping sets((), grouping sets(())));
   ╰╴                              ━
error[syntax-error]: unexpected trailing comma
   ╭▸ 
28 │ select f(1,);
   ╰╴          ━
error[syntax-error]: expected expression
   ╭▸ 
31 │ select f(a,,,,,);
   ╰╴           ━
error[syntax-error]: expected expression
   ╭▸ 
31 │ select f(a,,,,,);
   ╰╴            ━
error[syntax-error]: expected expression
   ╭▸ 
31 │ select f(a,,,,,);
   ╰╴             ━
error[syntax-error]: expected expression
   ╭▸ 
31 │ select f(a,,,,,);
   ╰╴              ━
error[syntax-error]: missing comma
   ╭▸ 
37 │ select numeric 1234;
   ╰╴              ━
error[syntax-error]: expected COMMA
   ╭▸ 
40 │ select array[1 2,3];
   ╰╴              ━
error[syntax-error]: unexpected comma
   ╭▸ 
42 │ select array[1, ,3];
   ╰╴                ━
error[syntax-error]: unexpected trailing comma
   ╭▸ 
44 │ select array[1,2,3,];
   ╰╴                  ━
error[syntax-error]: expected expression in atom_expr
   ╭▸ 
47 │ select * from t group by all order by all;
   ╰╴                                      ━
error[syntax-error]: expected COMMA
   ╭▸ 
50 │ select cast(x as varchar(100 200));
   ╰╴                            ━
error[syntax-error]: unexpected comma
   ╭▸ 
51 │ select cast(x as varchar(100, , 200));
   ╰╴                              ━
error[syntax-error]: unexpected trailing comma
   ╭▸ 
52 │ select cast(x as t(a, b,));
   ╰╴                       ━
error[syntax-error]: expected SEMICOLON
   ╭▸ 
56 │ select select;
   ╰╴      ━
error[syntax-error]: unexpected trailing comma
   ╭▸ 
59 │ select a, from t;
   ╰╴        ━
error[syntax-error]: expected an expression, found END_KW
   ╭▸ 
62 │ select case when 1 then end;
   ╰╴                       ━
error[syntax-error]: expected an expression, found THEN_KW
   ╭▸ 
65 │ select case when then x end;
   ╰╴                ━
error[syntax-error]: expected an expression, found END_KW
   ╭▸ 
68 │ select case when 1 then 2 else end;
   ╰╴                              ━
error[syntax-error]: expected SEMICOLON
   ╭▸ 
71 │   select
   │ ┏━━━━━━━┛
72 │ ┃ create table users ();
   ╰╴┗━┛
error[syntax-error]: expected SEMICOLON
   ╭▸ 
76 │ select 
   ╰╴      ━
error[syntax-error]: expected SEMICOLON
   ╭▸ 
80 │ select 
   ╰╴      ━
error[syntax-error]: expected expression but got AND_KW
   ╭▸ 
84 │ select from t where and c > 10;
   ╰╴                    ━
error[syntax-error]: expected expression but got OR_KW
   ╭▸ 
85 │ select from t where or c != 'b';
   ╰╴                    ━
error[syntax-error]: expected expression but got AND_KW
   ╭▸ 
87 │ select having and c > 10;
   ╰╴              ━
error[syntax-error]: expected expression but got OR_KW
   ╭▸ 
88 │ select having or c != 'b';
   ╰╴              ━
error[syntax-error]: expected expression but got AND_KW
   ╭▸ 
90 │ select from t join u on and true;
   ╰╴                        ━
error[syntax-error]: expected expression but got OR_KW
   ╭▸ 
91 │ select from t join u on or true;
   ╰╴                        ━
error[syntax-error]: JOINs must appear before WHERE
   ╭▸ 
96 │ join k on true;
   ╰╴━
error[syntax-error]: HAVING must appear before ORDER BY
    ╭▸ 
103 │ having a > 10;
    ╰╴━
error[syntax-error]: expected SEMICOLON
    ╭▸ 
106 │   select
    │ ┏━━━━━━━┛
107 │ ┃ end;
    ╰╴┗━┛
error[syntax-error]: expected SEMICOLON
    ╭▸ 
110 │   select
    │ ┏━━━━━━━┛
111 │ ┃ analyze;
    ╰╴┗━┛
error[syntax-error]: expected SEMICOLON
    ╭▸ 
113 │   select
    │ ┏━━━━━━━┛
114 │ ┃ analyse;
    ╰╴┗━┛
error[syntax-error]: expected SEMICOLON
    ╭▸ 
118 │   select
    │ ┏━━━━━━━┛
119 │ ┃ with t as (select 1)
    ╰╴┗━┛
error[syntax-error]: unexpected trailing comma
    ╭▸ 
123 │ select 1,
    ╰╴        ━
