Skip to content

Scalar row subqueries with an alias column name broken #127

Open
@jaypipes

Description

@jaypipes
[jaypipes@uberbox _build]$ ./sqltoaster/sqltoaster --yaml "SELECT (SELECT d FROM t2 WHERE d.id = t2.id) AS d_id FROM t2"
Syntax error.
Expected to find one of ('*'|<< identifier >>) but found keyword[AS]
SELECT (SELECT d FROM t2 WHERE d.id = t2.id) AS d_id FROM t2
                                            ^^^^^^^^^^^^^^^^
(took 109416 nanoseconds)
[jaypipes@uberbox _build]$ ./sqltoaster/sqltoaster --yaml "SELECT (SELECT d FROM t2 WHERE d.id = t2.id) FROM t2"
statements:
  - type: SELECT
    select_statement:
      query:
        selected_columns:
          - type: NUMERIC_EXPRESSION
            numeric_expression:
              left:
                left:
                  primary:
                    type: VALUE
                    value:
                      primary:
                        type: SCALAR_SUBQUERY
                        scalar_subquery:
                          query:
                            selected_columns:
                              - type: NUMERIC_EXPRESSION
                                numeric_expression:
                                  left:
                                    left:
                                      primary:
                                        type: VALUE
                                        value:
                                          primary:
                                            type: COLUMN_REFERENCE
                                            column_reference: d
                            referenced_tables:
                              - type: TABLE
                                table:
                                  name: t2
                            where:
                              terms:
                                - factor:
                                    predicate:
                                      type: COMPARISON
                                      comparison_predicate:
                                        op: EQUAL
                                        left:
                                          type: ELEMENT
                                          element:
                                            type: VALUE_EXPRESSION
                                            value_expression:
                                              type: NUMERIC_EXPRESSION
                                              numeric_expression:
                                                left:
                                                  left:
                                                    primary:
                                                      type: VALUE
                                                      value:
                                                        primary:
                                                          type: COLUMN_REFERENCE
                                                          column_reference: d.id
                                        right:
                                          type: ELEMENT
                                          element:
                                            type: VALUE_EXPRESSION
                                            value_expression:
                                              type: NUMERIC_EXPRESSION
                                              numeric_expression:
                                                left:
                                                  left:
                                                    primary:
                                                      type: VALUE
                                                      value:
                                                        primary:
                                                          type: COLUMN_REFERENCE
                                                          column_reference: t2.id
        referenced_tables:
          - type: TABLE
            table:
              name: t2
(took 50661 nanoseconds)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions