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: Initial globbing ranges support #2654

Merged
merged 7 commits into from
Mar 6, 2024
Merged

feat: Initial globbing ranges support #2654

merged 7 commits into from
Mar 6, 2024

Conversation

vrongmeal
Copy link
Contributor

@vrongmeal vrongmeal commented Feb 15, 2024

We support two kinds of glob ranges:

  • {N..M}: Here both N and M are valid integers and (N <= M).
  • {str1,str2,str3}: Three different strings: "str1", "str2", "str3"

Example:

> select * from 'file_{2..3}.csv';
┌─────────┐
│ column1 │
│      ── │
│   Int64 │
╞═════════╡
│       2 │
│       3 │
└─────────┘
> select * from 'file{_1,_3}.csv';
┌─────────┐
│ column1 │
│      ── │
│   Int64 │
╞═════════╡
│       1 │
│       3 │
└─────────┘

@vrongmeal vrongmeal changed the title feat: Globbing ranges feat: Initial globbing ranges support Feb 20, 2024
@vrongmeal vrongmeal marked this pull request as ready for review February 20, 2024 16:06
assert_eq!(&actual, expected);
}

// TODO: Add test cases for failed patterns...
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking about

  • {0..a} and {a..0}
  • what do we do for non-ascii alphabets?
  • {3..} {r..}
  • {..72}

We can imagine bounded ranges that only have an upper or lower bound working as long as the type/value being ranged over had a well defined collation. I initially thought that we'd only want to have unbounded ranges over bounded values, but because this is matching within a list of objects that we can iterate through, we could make it work. We don't have to support all of these now, but having tests that we can change later seems good.

There are also a bunch of potential syntax errors that we should produce clear error messages to users (and maybe this were the things that I thought might go in the enum:

  • mismatched bracket types.
  • wrong number of .. in glob
  • mismatched start/end types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added more cases to handle the cases you mentioned.

I am not very keen on throwing an error since the "pattern" formation can be coincidental and we shouldn't throw an error until user opts-in or opts-out.

We definitely should have an "opt-out" from glob pattern so we can throw errors with confidence.

We support two kinds of glob ranges:

* `{N..M}`: Here both `N` and `M` are valid integers and (`N <= M`).
* `{str1,str2,str3}`: Three different strings: `"str1", "str2", "str3"`

**Example:**

```
> select * from 'file_{2..3}.csv';
┌─────────┐
│ column1 │
│      ── │
│   Int64 │
╞═════════╡
│       2 │
│       3 │
└─────────┘
> select * from 'file{_1,_3}.csv';
┌─────────┐
│ column1 │
│      ── │
│   Int64 │
╞═════════╡
│       1 │
│       3 │
└─────────┘
```

Signed-off-by: Vaibhav <vrongmeal@gmail.com>
Copy link
Collaborator

@tychoish tychoish left a comment

Choose a reason for hiding this comment

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

some nits.

I'd also sort of like to see the tests also do BSON because the object store integration is a bit different, but I'm fine if we don't, I think.

crates/datasources/src/excel/mod.rs Outdated Show resolved Hide resolved
crates/datasources/src/object_store/mod.rs Outdated Show resolved Hide resolved
@vrongmeal vrongmeal enabled auto-merge (squash) March 6, 2024 18:48
@vrongmeal vrongmeal merged commit 73ee918 into main Mar 6, 2024
25 checks passed
@vrongmeal vrongmeal deleted the vrongmeal/glob-gen branch March 6, 2024 18:57
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.

None yet

3 participants