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

Snowflake COPY INTO fails to parse with a semicolon #1519

Open
tv42 opened this issue Nov 12, 2024 · 1 comment
Open

Snowflake COPY INTO fails to parse with a semicolon #1519

tv42 opened this issue Nov 12, 2024 · 1 comment

Comments

@tv42
Copy link

tv42 commented Nov 12, 2024

This bug rhymes with #1244.

parse_sql normally doesn't care whether a single statement is terminated by a semicolon or end of string, but when parsing Snowflake syntax COPY INTO it does.

This deviation seems like a bug.

Discovered on sqlparser v0.51.0, tested on v0.52.0:

use sqlparser::{
    dialect::SnowflakeDialect,
    parser::{Parser, ParserError},
};

fn main() {
    let dialect = SnowflakeDialect {};

    // With other SQL, semicolon being there or not does not seem to matter:
    {
        let no_semicolon = Parser::parse_sql(&dialect, "select 1");
        assert!(no_semicolon.is_ok());
    }
    {
        let with_semicolon = Parser::parse_sql(&dialect, "select 1;");
        assert!(with_semicolon.is_ok());
    }

    // With the SnowFlake COPY INTO statement, it does seem to matter.
    // Parsing only works when the semicolon is omitted:
    {
        let no_semicolon = Parser::parse_sql(&dialect, "COPY INTO foo FROM @bar");
        println!("no semicolon: {no_semicolon:?}");
        assert!(no_semicolon.is_ok());
    }
    {
        // BUG
        let with_semicolon = Parser::parse_sql(&dialect, "COPY INTO foo FROM @bar;");
        println!("with semicolon: {with_semicolon:?}");
        assert_eq!(
            with_semicolon,
            Err(ParserError::ParserError(
                "Expected: stage name identifier, found: EOF".to_string()
            ))
        );
    }
}
@tv42
Copy link
Author

tv42 commented Nov 12, 2024

Interestingly, COPY INTO foo FROM 'quux'; works with the semicolon.

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

No branches or pull requests

1 participant