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

chore!: remove pyarrow-based file reader #3587

Merged
merged 9 commits into from
Dec 18, 2024
Merged

Conversation

kevinzwang
Copy link
Member

@kevinzwang kevinzwang commented Dec 17, 2024

BREAKING CHANGE: removed the following: reading using PyArrow, PythonStorageConfig type and StorageConfig.python function, daft.table.schema_inference, refactored StorageConfig and NativeStorageConfig into one type

Also includes two small fixes:

  • Schema struct equality now also depends on the ordering of the fields
  • Monotonically increasing ID schema now always inserts ID as the first column

todo:

  • refactor StorageConfig and NativeStorageConfig into one struct
  • clean up table_io.py

BREAKING CHANGE: reading using PyArrow, along with the PythonStorageConfig, are removed
Copy link

codspeed-hq bot commented Dec 17, 2024

CodSpeed Performance Report

Merging #3587 will degrade performances by 36.08%

Comparing kevin/bye-py-storage-config (5f54cdc) with main (07752b8)

Summary

❌ 1 regressions
✅ 26 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main kevin/bye-py-storage-config Change
test_iter_rows_first_row[100 Small Files] 159.5 ms 249.6 ms -36.08%

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 86.09023% with 37 lines in your changes missing coverage. Please review.

Project coverage is 77.65%. Comparing base (07752b8) to head (5f54cdc).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/daft-micropartition/src/micropartition.rs 86.98% 22 Missing ⚠️
src/daft-micropartition/src/python.rs 0.00% 4 Missing ⚠️
src/daft-scan/src/python.rs 57.14% 3 Missing ⚠️
daft/expressions/expressions.py 80.00% 2 Missing ⚠️
src/daft-scan/src/builder.rs 71.42% 2 Missing ⚠️
daft/io/_deltalake.py 66.66% 1 Missing ⚠️
daft/io/_sql.py 50.00% 1 Missing ⚠️
daft/table/table_io.py 95.45% 1 Missing ⚠️
src/daft-scan/src/lib.rs 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3587      +/-   ##
==========================================
- Coverage   77.86%   77.65%   -0.22%     
==========================================
  Files         719      717       -2     
  Lines       88459    88204     -255     
==========================================
- Hits        68877    68492     -385     
- Misses      19582    19712     +130     
Files with missing lines Coverage Δ
daft/delta_lake/delta_lake_scan.py 77.77% <100.00%> (ø)
daft/hudi/hudi_scan.py 87.95% <100.00%> (ø)
daft/io/_csv.py 95.23% <100.00%> (-0.42%) ⬇️
daft/io/_hudi.py 100.00% <100.00%> (ø)
daft/io/_iceberg.py 85.71% <100.00%> (ø)
daft/io/_json.py 90.47% <100.00%> (-0.83%) ⬇️
daft/io/_parquet.py 84.61% <100.00%> (-1.10%) ⬇️
daft/sql/sql_scan.py 25.89% <ø> (ø)
src/daft-local-execution/src/sources/scan_task.rs 76.45% <100.00%> (+0.89%) ⬆️
...ogical-plan/src/ops/monotonically_increasing_id.rs 96.96% <100.00%> (+0.09%) ⬆️
... and 13 more

... and 12 files with indirect coverage changes

@kevinzwang kevinzwang marked this pull request as ready for review December 18, 2024 00:46
@kevinzwang kevinzwang requested a review from jaychia December 18, 2024 00:46
Copy link
Contributor

@jaychia jaychia left a comment

Choose a reason for hiding this comment

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

Nice, saw a few changes that looked not relevant though?

daft/sql/sql_scan.py Show resolved Hide resolved
@@ -17,7 +17,8 @@ impl MonotonicallyIncreasingId {
let column_name = column_name.unwrap_or("id");

let mut schema_with_id_index_map = input.schema().fields.clone();
schema_with_id_index_map.insert(
schema_with_id_index_map.shift_insert(
0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? Seems like an orthogonal change to the rest of the PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok this is a long explanation but it's necessary.

One discrepancy between the native and python readers I found is that if you pass in a schema that reorders the columns, the native reader does not actually respect that. The reason turned out to be because an unloaded micropartition only creates a new scan task if the schemas differ (see here). However, the impl of Eq for Schema relies on Eq for indexmap::IndexMap, which does not actually check for ordering. Thus the schemas are erronenously presumed to be equal.

So, I made the equality check for Schema stricter, however that caused an issue with monotonically increasing ID, since the schema built in the logical plan (which has the ID at the end) was different from the schema of the actual computed tables (which have the ID as the first column). That's why I need to shift_insert instead of insert here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whaaaat 😮

Ok can we lift this to the PR description? Very surprised that this was surfaced only now though, seems like a bug that should have come up sooner.

src/daft-micropartition/src/micropartition.rs Show resolved Hide resolved
src/daft-scan/src/python.rs Outdated Show resolved Hide resolved
src/daft-schema/src/schema.rs Show resolved Hide resolved
tests/dataframe/test_intersect.py Outdated Show resolved Hide resolved
tests/table/table_io/test_read_time_cast.py Show resolved Hide resolved
read_options=json_read_options,
io_config=config.io_config,
)
return _cast_table_to_schema(tbl, read_options=read_options, schema=schema)


def read_parquet(
Copy link
Contributor

Choose a reason for hiding this comment

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

What do we need table_io.read_parquet/csv/json for? Is it possible to get rid of them even?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, I believe we eliminate the Python code path entirely. I think I'll leave that for a future PR and add a TODO here.

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact we could probably remove table_io.py entirely if we port our non-swordfish code to use daft.io.writer to do writing.

@jaychia
Copy link
Contributor

jaychia commented Dec 18, 2024

BTW we can maybe just deprecate the APIs first and deal with this later

In the interest of letting us cut a release first, I might push up an API-only change first since it seems this PR might not yet be ready to go.

@kevinzwang kevinzwang requested a review from jaychia December 18, 2024 21:21
@kevinzwang kevinzwang enabled auto-merge (squash) December 18, 2024 22:31
@kevinzwang kevinzwang merged commit 3a3707a into main Dec 18, 2024
43 of 44 checks passed
@kevinzwang kevinzwang deleted the kevin/bye-py-storage-config branch December 18, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants