Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hive should not successfully parse the factorial operator #1473

Open
wugeer opened this issue Oct 12, 2024 · 0 comments · May be fixed by #1472
Open

Hive should not successfully parse the factorial operator #1473

wugeer opened this issue Oct 12, 2024 · 0 comments · May be fixed by #1472

Comments

@wugeer
Copy link

wugeer commented Oct 12, 2024

Hive does not support the syntax a!, although it is supported in Postgres. However, the current project's Hive dialect supports the select a! clause.

cargo run --features json_example --example cli test.sql  --hive
   Compiling sqlparser v0.51.0 (/home/xiehw/code/person/rust/sqlparser-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.61s
     Running `target/debug/examples/cli test.sql --hive`
Parsing from file 'test.sql' using HiveDialect
2024-10-12T07:43:55.615Z DEBUG [sqlparser::parser] Parsing sql 'select a!
'...
2024-10-12T07:43:55.615Z DEBUG [sqlparser::parser] parsing expr
2024-10-12T07:43:55.615Z DEBUG [sqlparser::parser] prefix: Identifier(Ident { value: "a", quote_style: None })
2024-10-12T07:43:55.615Z DEBUG [sqlparser::dialect] get_next_precedence_full() TokenWithLocation { token: ExclamationMark, location: Location { line: 1, column: 9 } }
2024-10-12T07:43:55.615Z DEBUG [sqlparser::parser] next precedence: 50
2024-10-12T07:43:55.615Z DEBUG [sqlparser::dialect] get_next_precedence_full() TokenWithLocation { token: EOF, location: Location { line: 0, column: 0 } }
2024-10-12T07:43:55.615Z DEBUG [sqlparser::parser] next precedence: 0
Round-trip:
'SELECT a!'
Serialized as JSON:
[
  {
    "Query": {
      "with": null,
      "body": {
        "Select": {
          "distinct": null,
          "top": null,
          "projection": [
            {
              "UnnamedExpr": {
                "UnaryOp": {
                  "op": "PGPostfixFactorial",
                  "expr": {
                    "Identifier": {
                      "value": "a",
                      "quote_style": null
                    }
                  }
                }
              }
            }
          ],
          "into": null,
          "from": [],
          "lateral_views": [],
          "prewhere": null,
          "selection": null,
          "group_by": {
            "Expressions": [
              [],
              []
            ]
          },
          "cluster_by": [],
          "distribute_by": [],
          "sort_by": [],
          "having": null,
          "named_window": [],
          "qualify": null,
          "window_before_qualify": false,
          "value_table_mode": null,
          "connect_by": null
        }
      },
      "order_by": null,
      "limit": null,
      "limit_by": [],
      "offset": null,
      "fetch": null,
      "locks": [],
      "for_clause": null,
      "settings": null,
      "format_clause": null
    }
  }
]

The expected result is to throw an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant