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

feat(ingest/s3): type aware directory sorting #8089

Merged

Conversation

treff7es
Copy link
Contributor

Adding comparator to dir sorting which can sort dirs as numbers if it is number

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label May 19, 2023
Copy link
Collaborator

@asikowitz asikowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main question is around how to best handle folders with multiple equals signs

Comment on lines +197 to +200
if num_folder1 == num_folder2:
return 0
else:
return 1 if num_folder1 > num_folder2 else -1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can be more concisely num_folder1 - num_folder2

Comment on lines +190 to +193
if "=" in folder1 and "=" in folder2:
if folder1.split("=", 1)[0] == folder2.split("=", 1)[0]:
folder1 = folder1.split("=", 1)[1]
folder2 = folder2.split("=", 1)[1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the structure of these folder names? Is this preferred over using .rsplit("=", 1), which seems maybe more flexible in case the folders have multiple equal signs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hive partitioning is usually like :
mydir/2022/12/11
or like this:
mydir/year=2022/month=12/day=11

@treff7es
Copy link
Contributor Author

Main question is around how to best handle folders with multiple equals signs

Hive partitioning is usually like :
mydir/2022/12/11
or like this:
mydir/year=2022/month=12/day=11

I think these are the most common ones and for the others it should be fine to compare as string

@treff7es treff7es merged commit f8be9f6 into datahub-project:master May 23, 2023
41 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ingestion PR or Issue related to the ingestion of metadata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants