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 all 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
13 changes: 8 additions & 5 deletions dask_deltatable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

import dask
Expand Down Expand Up @@ -121,14 +120,18 @@ def _read_from_filesystem(
if columns:
meta = meta[columns]

kws = dict(meta=meta, label="read-delta-table")
if not dd._dask_expr_enabled():
# Setting token not supported in dask-expr
kws["token"] = tokenize(path, fs_token, **kwargs) # type: ignore
kwargs["token"] = tokenize(path, fs_token, **kwargs) # type: ignore
return dd.from_map(
partial(_read_delta_partition, fs=fs, columns=columns, schema=schema, **kwargs),
_read_delta_partition,
pq_files,
**kws,
fs=fs,
columns=columns,
schema=schema,
meta=meta,
label="read-delta-table",
**kwargs,
)


Expand Down
10 changes: 5 additions & 5 deletions dask_deltatable/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
from deltalake import DeltaTable

try:
from deltalake.writer import MAX_SUPPORTED_WRITER_VERSION # type: ignore
from deltalake.writer import MAX_SUPPORTED_PYARROW_WRITER_VERSION
except ImportError:
from deltalake.writer import (
MAX_SUPPORTED_PYARROW_WRITER_VERSION as MAX_SUPPORTED_WRITER_VERSION,
from deltalake.writer import ( # type: ignore
MAX_SUPPORTED_WRITER_VERSION as MAX_SUPPORTED_PYARROW_WRITER_VERSION,
)

from deltalake.writer import (
Expand Down Expand Up @@ -177,11 +177,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
5 changes: 2 additions & 3 deletions tests/test_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ def test_reader_all_primitive_types():
# Dask and delta go through different parquet parsers which read the
# 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]").dt.tz_localize("UTC")
)
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