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

hb.data.ParquetDataset support Case-sensitive-fields #51

Closed
karterotte opened this issue May 9, 2022 · 0 comments · Fixed by #54
Closed

hb.data.ParquetDataset support Case-sensitive-fields #51

karterotte opened this issue May 9, 2022 · 0 comments · Fixed by #54
Assignees
Labels
enhancement New feature or request

Comments

@karterotte
Copy link

User Story

I want to read data using hb.data.ParquetDataset and feed field param using my column names from other place.
When I use hb.data.ParquetDataset(filenames=[My parquet files],fields = [My custom column names]), It throws f'Field {f} is not found in the parquet file {filename}'

Detailed requirements

Hive stores the schema of a table in all lowercase. It makes input-param (fields) maybe not in parquet files.
Like "AGE" in fields but "age" in parquet schema. In this case , should do auto fields transform like below:

schema_ds = ParquetFile(filenames[0])
schema_names = schema_ds.schema_arrow.names
def _fix_name(name):
      if name not in schema_names and name.lower() in schema_names:
            return (name.lower(),1)
      else:
            return (name,0)
results_fields = [_fix_name(n) for n in fields]
fixed_fields = [n[0] for n in results_fields]
changed_fields = [n[0] for n in results_fields if n[1]==1]
print("changed-fileds:%s" % changed_fields)

API Compatibility

hb.data.ParquetDataset

@2sin18 2sin18 self-assigned this May 10, 2022
@2sin18 2sin18 added the enhancement New feature or request label May 10, 2022
@2sin18 2sin18 linked a pull request May 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants