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

Add support for parsing comma-separated column name lists #458

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

scovich
Copy link
Collaborator

@scovich scovich commented Nov 6, 2024

What changes are proposed in this pull request?

Some Delta table properties are comma-separated lists of column names, so we need a way to reliably parse them. Integrate list parsing into the existing column name parsing, so that commas are handled correctly in the presence of special characters, escaping, etc.

This PR affects the following public APIs

New public API.

How was this change tested?

New unit tests.

if chars.peek().is_none() {
return Ok((ColumnName::empty(), FieldEnding::InputExhausted));
}
if chars.next_if_eq(&',').is_some() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we make the delimiter a parameter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I really hope we don't ever need to support configurable delimiters...

Copy link
Collaborator

Choose a reason for hiding this comment

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

hahaha yea fair enough

Comment on lines +654 to +657
(
" a , ",
Some(vec![column_name!("a"), ColumnName::empty()]),
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm... thinking about this. do we want trailing delimiters to mean an empty column follows? I feel like SQL has annoying behavior like this but I've gotten used to trailing delimiters being optional (e.g. in rust syntax)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about that, but we already allow a whole bunch of similar corner cases already, such as "." parsing as a column name with two empty field names. If an engine cares doesn't like those, it's welcome to check for and reject them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(if we decide to reject any of the corner cases, we probably need to start rejecting them all, which is a lot of extra code and testing to worry about -- but we can do it as a separate PR if we decide it's really needed)

Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds good :)

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 94.84536% with 5 lines in your changes missing coverage. Please review.

Project coverage is 78.50%. Comparing base (4466509) to head (c951241).

Files with missing lines Patch % Lines
kernel/src/expressions/column_names.rs 94.84% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #458      +/-   ##
==========================================
+ Coverage   78.41%   78.50%   +0.08%     
==========================================
  Files          55       55              
  Lines       11806    11875      +69     
  Branches    11806    11875      +69     
==========================================
+ Hits         9258     9322      +64     
- Misses       2041     2044       +3     
- Partials      507      509       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

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

lgtm! thanks

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

Successfully merging this pull request may close these issues.

3 participants