Skip to content

Invalid parsing results produced by OwnedTableReference::from(&str) #5793

@jdye64

Description

@jdye64

Describe the bug

Invoking OwnedTableReference::from("schema.1table") produces an invalid TableReference if the "table name" starts with a number. In this example the result would be

Bare { table: "schema.1table" }

when in fact the correct result should be

Partial { schema: "schema", table: "1table" }

To Reproduce

A simple test can be added to datafusion/common/src/utils.rs to reproduce the bug.

#[test]
    fn test_split_names() -> Result<()> {
        let result = parse_identifiers_normalized("schema.1table");
        assert_eq!(result.len(), 2);
        Ok(())
    }

Expected behavior

Invoking OwnedTableReference::from("schema.1table") should produce the result

Partial { schema: "schema", table: "1table" }

Additional context

I have traced the issue to sqlparser-rs returning a Token::Word rather than expected Token::Period at https://github.com/apache/arrow-datafusion/blob/main/datafusion/common/src/utils.rs#L200

My main question is should be be handled in DataFusion or sqlparser-rs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions