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 Rust bindings for Schema #650

Merged
merged 6 commits into from Mar 3, 2023
Merged

Add Rust bindings for Schema #650

merged 6 commits into from Mar 3, 2023

Conversation

jaychia
Copy link
Contributor

@jaychia jaychia commented Mar 3, 2023

Adds a schema2.py which includes Rust bindings for schema

@jaychia jaychia requested a review from samster25 March 3, 2023 06:56
@jaychia jaychia marked this pull request as ready for review March 3, 2023 06:56
@codecov
Copy link

codecov bot commented Mar 3, 2023

Codecov Report

Merging #650 (7584ad1) into main (b62e068) will increase coverage by 0.17%.
The diff coverage is 92.98%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #650      +/-   ##
==========================================
+ Coverage   84.18%   84.36%   +0.17%     
==========================================
  Files         113      115       +2     
  Lines       10403    10526     +123     
==========================================
+ Hits         8758     8880     +122     
- Misses       1645     1646       +1     
Impacted Files Coverage Δ
src/table/mod.rs 71.42% <ø> (ø)
src/schema.rs 67.34% <76.92%> (+3.45%) ⬆️
daft/logical/schema2.py 91.66% <91.66%> (ø)
daft/table.py 86.66% <100.00%> (+3.33%) ⬆️
src/python/mod.rs 100.00% <100.00%> (ø)
src/python/schema.rs 100.00% <100.00%> (ø)
src/python/table.rs 75.82% <100.00%> (+1.40%) ⬆️
daft/dataframe/dataframe.py 92.37% <0.00%> (-0.06%) ⬇️
daft/runners/ray_runner.py 91.77% <0.00%> (-0.04%) ⬇️
daft/execution/execution_step.py 93.79% <0.00%> (+0.02%) ⬆️
... and 6 more


def __iter__(self) -> Iterator[Field]:
col_names = self.column_names()
return (self[name] for name in col_names)
Copy link
Member

Choose a reason for hiding this comment

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

return iter of the tuple

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually returns a generator rather than a tuple:

>>> x = (i for i in range(10))
>>> type(x)
<class 'generator'>

I can do yield from instead if its clearer?

Copy link
Member

Choose a reason for hiding this comment

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

nah its fine then

s._schema = schema
return s

def __getitem__(self, key: str) -> Field:
Copy link
Member

Choose a reason for hiding this comment

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

runtime check that key is a str to avoid panic in pyo3

Ok(self.schema.names()?)
}

pub fn union(&self, other: &PySchema) -> PyResult<PySchema> {
Copy link
Member

Choose a reason for hiding this comment

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

this union method should be implemented in Schema rather than having the logic in the pybindings

@jaychia jaychia merged commit 1a3ed70 into main Mar 3, 2023
8 checks passed
@jaychia jaychia deleted the jay/schema-rust-bindings branch March 3, 2023 22:05
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

2 participants