Skip to content

Can not handle ' characters in PARTITIONED BY clause #9714

Open

Description

@alamb

Describe the bug

#9604 from @metesynnada rationalied COPY option handling 🙏

However one of the tests needed to be commented out: https://github.com/apache/arrow-datafusion/blob/1d0171ab9d33fc7896861dee85804d7daf0a6390/datafusion/sqllogictest/test_files/copy.slt#L114-L142

To Reproduce

@metesynnada explained on synnada-ai#10 (comment)

Before this pull request, there was a problem with how escape characters in the PARTITIONED BY clause were processed in both the CREATE EXTERNAL TABLE and COPY TO statements. The issue stemmed from converting the Value to a string too early in the parsing process, leading to errors.

Although it appears that the test passes, in reality, during the execution of CREATE EXTERNAL TABLE, the specified field names do not match as expected, indicating a silent error. This issue should be addressed separately, as it falls outside the scope of the current PR.

I propose that we standardize the approach to handling column names in both the schema definitions and the PARTITIONED BY clauses. Once we establish a consistent method, the relevance of this test can be reassessed.

I will proceed to open an issue to address it.

Expected behavior

The test should pass

Additional context

No response

Activity

  1. yyy1000 commented on Mar 26, 2024

    @yyy1000
    Contributor

    I'd like to try this, from the description,

    Until the partition by parsing uses ColumnDef

    So maybe trying to make partition by use ColumnDef, currently, my plan is:

    1. Make table_partition_cols field in https://github.com/apache/arrow-datafusion/blob/39f4aaf5cd1abfc9204c3eb96effdb4ebcf5b882/datafusion/sql/src/parser.rs#L206 CreateExternalTable statement to Vec<ColumnRef>
    2. make parse_partitions return ColumnRef like parse_columns. https://github.com/apache/arrow-datafusion/blob/39f4aaf5cd1abfc9204c3eb96effdb4ebcf5b882/datafusion/sql/src/parser.rs#L542
    3. In external_table_to_plan, do the same thing to table_partition_cols like column_defaults https://github.com/apache/arrow-datafusion/blob/39f4aaf5cd1abfc9204c3eb96effdb4ebcf5b882/datafusion/sql/src/statement.rs#L984-L987

    So this will not convert the Ident value to string too early, but I also doubt whether it would fix this. I encountered similar issue related to ' characters in my past experience and it's a bit tricky.

  2. alamb commented on Mar 27, 2024

    @alamb
    ContributorAuthor

    @metesynnada I wonder if you have any thoughts on the suggestion above from @yyy1000 ?

  3. metesynnada commented on Mar 27, 2024

    @metesynnada
    Contributor

    I believe this is a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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