Skip to content

Commit

Permalink
Merge branch 'main' into deprecation-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyler authored Oct 18, 2023
2 parents da8a4c4 + 1860158 commit 58f83de
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltalake-python"
version = "0.11.0"
version = "0.12.0"
authors = ["Qingping Hou <dave2008713@gmail.com>", "Will Jones <willjones127@gmail.com>"]
homepage = "https://github.com/delta-io/delta-rs"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions python/deltalake/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def encode_partition_value(val: Any) -> str:
return val
elif isinstance(val, (int, float)):
return str(val)
elif isinstance(val, date):
return val.isoformat()
elif isinstance(val, datetime):
return val.isoformat(sep=" ")
elif isinstance(val, date):
return val.isoformat()
elif isinstance(val, bytes):
return val.decode("unicode_escape", "backslashreplace")
else:
Expand Down
34 changes: 33 additions & 1 deletion python/tests/test_table_read.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import os
from datetime import datetime
from datetime import date, datetime
from pathlib import Path
from threading import Barrier, Thread
from types import SimpleNamespace
from typing import Any
from unittest.mock import Mock

from packaging import version

from deltalake._util import encode_partition_value
from deltalake.exceptions import DeltaProtocolError
from deltalake.table import ProtocolVersions
from deltalake.writer import write_deltalake
Expand Down Expand Up @@ -695,3 +697,33 @@ def test_issue_1653_filter_bool_partition(tmp_path: Path):
)
== 1
)


@pytest.mark.parametrize(
"input_value, expected",
[
(True, "true"),
(False, "false"),
(1, "1"),
(1.5, "1.5"),
("string", "string"),
(date(2023, 10, 17), "2023-10-17"),
(datetime(2023, 10, 17, 12, 34, 56), "2023-10-17 12:34:56"),
(b"bytes", "bytes"),
([True, False], ["true", "false"]),
([1, 2], ["1", "2"]),
([1.5, 2.5], ["1.5", "2.5"]),
(["a", "b"], ["a", "b"]),
([date(2023, 10, 17), date(2023, 10, 18)], ["2023-10-17", "2023-10-18"]),
(
[datetime(2023, 10, 17, 12, 34, 56), datetime(2023, 10, 18, 12, 34, 56)],
["2023-10-17 12:34:56", "2023-10-18 12:34:56"],
),
([b"bytes", b"testbytes"], ["bytes", "testbytes"]),
],
)
def test_encode_partition_value(input_value: Any, expected: str) -> None:
if isinstance(input_value, list):
assert [encode_partition_value(val) for val in input_value] == expected
else:
assert encode_partition_value(input_value) == expected

0 comments on commit 58f83de

Please sign in to comment.