Skip to content

Commit

Permalink
Add partitions() test for date partitioned table
Browse files Browse the repository at this point in the history
  • Loading branch information
omkar-foss committed Aug 23, 2024
1 parent 0e6cbcc commit 226c671
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions python/tests/test_table_read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import tempfile
from datetime import date, datetime, timezone
from pathlib import Path
from random import random
Expand Down Expand Up @@ -871,6 +872,35 @@ def test_partitions_filtering_partitioned_table():
partition in actual


def test_partitions_date_partitioned_table():
table_path = tempfile.gettempdir() + "/date_partition_table"
date_partitions = [
date(2024, 8, 1),
date(2024, 8, 2),
date(2024, 8, 3),
date(2024, 8, 4),
]
sample_data = pa.table(
{
"date_field": pa.array(date_partitions, pa.date32()),
"numeric_data": pa.array([1, 2, 3, 4], pa.int64()),
}
)
write_deltalake(
table_path, sample_data, mode="overwrite", partition_by=["date_field"]
)

delta_table = DeltaTable(table_path)
expected = [
{"date_field": "2024-08-01"},
{"date_field": "2024-08-02"},
{"date_field": "2024-08-03"},
{"date_field": "2024-08-04"},
]
actual = sorted(delta_table.partitions(), key=lambda x: x["date_field"])
assert expected == actual


def test_partitions_special_partitioned_table():
table_path = "../crates/test/tests/data/delta-0.8.0-special-partition"
dt = DeltaTable(table_path)
Expand Down

0 comments on commit 226c671

Please sign in to comment.