Skip to content

Fails to parse BigQuery UDF with "ANY TYPE" parameters #1601

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

Closed
MartinSahlen opened this issue Dec 13, 2024 · 1 comment · Fixed by #1602
Closed

Fails to parse BigQuery UDF with "ANY TYPE" parameters #1601

MartinSahlen opened this issue Dec 13, 2024 · 1 comment · Fixed by #1602

Comments

@MartinSahlen
Copy link
Contributor

MartinSahlen commented Dec 13, 2024

EDIT: The "proper" name for this pattern is "Templated, SQL UDF Parameters", which can be further elaborated in the BQ Docs: https://cloud.google.com/bigquery/docs/user-defined-functions#templated-sql-udf-parameters

trying to parse this simple function like this:

fn main() {
    let sql = "
CREATE TEMP FUNCTION my_function(are_map ANY TYPE)
AS (
  (SELECT 1)
);
    ";

    let ast = Parser::parse_sql(&BigQueryDialect, sql).unwrap();
    for stmt in &ast {
        println!("{:?}", stmt);
    }
}

Yields this error:

thread 'main' panicked at src/main.rs:18:56:
called `Result::unwrap()` on an `Err` value: ParserError("Expected: ), found: TYPE at Line: 2, Column: 46")

I can try to have a look at this , seems relatively straightforward to fix!

@MartinSahlen
Copy link
Contributor Author

Jus adding to the context that is is working in BigQuery - see screenshot:
Screenshot 2024-12-13 at 16 16 57

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

Successfully merging a pull request may close this issue.

1 participant