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

Fix up some mypy errors #76

Merged
merged 6 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
# Type stubs
- boto3-stubs
- dask
- deltalake
- deltalake>=0.16
- pandas-stubs
- pytest
- types-setuptools
Expand Down
9 changes: 5 additions & 4 deletions dask_deltatable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import os
from collections.abc import Sequence
from functools import partial
from typing import Any, Callable, cast

import dask
import dask.dataframe as dd
import pyarrow as pa
import pyarrow.parquet as pq
from dask.base import tokenize
from dask.dataframe.io.parquet.arrow import ArrowDatasetEngine
from dask.dataframe.utils import make_meta
from deltalake import DataCatalog, DeltaTable
Expand Down Expand Up @@ -117,11 +115,14 @@ def _read_from_filesystem(
meta = meta[columns]

return dd.from_map(
partial(_read_delta_partition, fs=fs, columns=columns, schema=schema, **kwargs),
_read_delta_partition,
pq_files,
meta=meta,
label="read-delta-table",
token=tokenize(path, fs_token, **kwargs),
fs=fs,
columns=columns,
schema=schema,
**kwargs,
Copy link
Member

Choose a reason for hiding this comment

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

from_map in dask-expr doesn't support token=, but in this case I think we can have from_map handle tokenization internally (someone should feel free to correct me if that's not the case)

)


Expand Down
6 changes: 3 additions & 3 deletions dask_deltatable/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dask.highlevelgraph import HighLevelGraph
from deltalake import DeltaTable
from deltalake.writer import (
MAX_SUPPORTED_WRITER_VERSION,
MAX_SUPPORTED_PYARROW_WRITER_VERSION,
PYARROW_MAJOR_VERSION,
AddAction,
DeltaJSONEncoder,
Expand Down Expand Up @@ -167,11 +167,11 @@ def to_deltalake(
else:
partition_by = table.metadata().partition_columns

if table.protocol().min_writer_version > MAX_SUPPORTED_WRITER_VERSION:
if table.protocol().min_writer_version > MAX_SUPPORTED_PYARROW_WRITER_VERSION:
raise DeltaProtocolError(
"This table's min_writer_version is "
f"{table.protocol().min_writer_version}, "
f"but this method only supports version {MAX_SUPPORTED_WRITER_VERSION}."
f"but this method only supports version {MAX_SUPPORTED_PYARROW_WRITER_VERSION}."
)
else: # creating a new table
current_version = -1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dask[dataframe]
deltalake>=0.15
deltalake>=0.16
fsspec
pyarrow
1 change: 1 addition & 0 deletions tests/test_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_reader_all_primitive_types():
# timestamp differently. This is likely a bug in arrow but the delta result
# is "more correct".
expected_ddf["timestamp"] = expected_ddf["timestamp"].astype("datetime64[us]")
expected_ddf["timestamp"] = expected_ddf["timestamp"].dt.tz_localize("UTC")
jacobtomlinson marked this conversation as resolved.
Show resolved Hide resolved
assert_eq(actual_ddf, expected_ddf)


Expand Down
Loading