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

can not parse "SET TIME ZONE 'UTC'" #303

Closed
435201823 opened this issue Mar 28, 2021 · 5 comments · Fixed by #617 or #727
Closed

can not parse "SET TIME ZONE 'UTC'" #303

435201823 opened this issue Mar 28, 2021 · 5 comments · Fixed by #617 or #727

Comments

@435201823
Copy link

It was normal to parse "SET TIME ZONE 'UTC'" a few days ago. Today I tried to parse "SET TIME ZONE 'UTC'" and there was an error.

pub fn sql_parse_test() {
    use sqlparser::dialect::GenericDialect;
    use sqlparser::parser::Parser;

    let sql = r#"set time zone 'UTC'"#;

    let dialect = GenericDialect {};

    let ast = Parser::parse_sql(&dialect, sql).unwrap();

    println!("AST: {:?}", ast);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_sql_parse() {
        sql_parse_test();
    }
}

called `Result::unwrap()` on an `Err` value: ParserError("Expected equals sign or TO, found: zone")
thread 'func::sql_parse_test::tests::test_sql_parse' panicked at 'called `Result::unwrap()` on an `Err` value: ParserError("Expected equals sign or TO, found: zone")', src\func\sql_parse_test.rs:9:48
@waitingkuo
Copy link
Contributor

@435201823 which sqlparser version did you use that worked? i switched back to 0.5.0 but it still not works

@step-baby
Copy link
Contributor

The latest version of sqlparse still fails to parse SET TIME ZONE 'UTC'

@waitingkuo
Copy link
Contributor

@alamb i think we could reopen this and discuss.
We only support SET TIME ZONE TO 'UTC' and SET TIME ZONE = 'UTC'
but not SET TIME ZONE 'UTC'

i'm not familiar with how other db works, in postgrseql, TIMEZONE is the only variable that support SET SOMETHING 'VALUE'
https://www.postgresql.org/docs/current/sql-set.html

@alamb
Copy link
Contributor

alamb commented Nov 27, 2022

Reopened -- I think the typical strategy in these cases is to reflect the difference between SET TIME ZONE = 'UTC'
and SET TIME ZONE 'UTC' in the ast and then downstream systems can figure out if they want to treat them equivalently or not

@waitingkuo
Copy link
Contributor

@alamb i updated the pr

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