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

Feature: load parquet/ndjson support case sensitive #16897

Open
youngsofun opened this issue Nov 21, 2024 · 2 comments
Open

Feature: load parquet/ndjson support case sensitive #16897

youngsofun opened this issue Nov 21, 2024 · 2 comments
Labels
C-feature Category: feature

Comments

@youngsofun
Copy link
Member

youngsofun commented Nov 21, 2024

Summary

currently, when reading parquet file, the fields of file schema is modified that all field names are turned to lowercase.

Solution 1

parquet/ndjson add format option case_sensitive

cons:

  1. can not copy file ('a', 'b') into ('a', 'B')
  2. select, infer_infer_schema not show the orignal field names
    3. need to create a file_format for this purpose

Solution 2:

  1. select, infer_infer_schema: add table function option case_sensitive, true by default
  2. add copy option case_sensitive, false by default (for compatible)
    1. table fields check: allow ('a', 'B'), not allow ('a', 'A')
    2. parquet
      1. arrow_to_table_schema, to_lowercase and check for dup name
      2. impl 1 (trans to select): required fields to_lowercase
      3. impl 2 (match): table fields to_lower_case
    3. ndjson:
      1. both to_lower_case when matching names

cons:

  1. the default behavior of select and copy are not consist

pros

  1. select, infer_infer_schema show what the original name by default (maybe we can sacrifice this and let all case_sensitive=false by default for consist)
@youngsofun
Copy link
Member Author

cc @sundy-li @everpcpc @wubx @Xuanwo

@youngsofun
Copy link
Member Author

youngsofun commented Nov 21, 2024

choose Solution 2 after discuss with @sundy-li.

to make it more clear, I propose:

  1. add copy option COLUMN_MATCH_MODE
COLUMN_MATCH_MODE:
  CASE_SENSITIVE: Match columns by name, case-sensitive.
  CASE_INSENSITIVE: Match columns by name, case-insensitive.
  POSITION: Match columns by position instead of name.
  FORMAT_DEFAULT: Use the default matching behavior based on file format.

FILE_FORMAT:
  CSV: Default POSITION.
  Parquet/ORC/NDJson: Default CASE_INSENSITIVE.

note nota all mode for all format are supported, we will do them one by one

  1. select, infer_infer_schema add param column_name_to_lowercase=TRUE|FALSE, default false

will remind user to use this option if there are related errors.

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

No branches or pull requests

1 participant