Skip to content

Commit

Permalink
update python integ test for mor
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiyan committed Jan 18, 2025
1 parent fac8f79 commit cd4cb14
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
60 changes: 31 additions & 29 deletions demo/app/python/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,37 @@
from hudi import HudiTableBuilder
import pyarrow as pa

hudi_table = HudiTableBuilder.from_base_uri(
"s3://hudi-demo/cow/v6_complexkeygen_hivestyle"
).build()
records = hudi_table.read_snapshot()
for url in [
"s3://hudi-demo/cow/v6_complexkeygen_hivestyle",
"s3://hudi-demo/mor/v6_complexkeygen_hivestyle",
]:
hudi_table = HudiTableBuilder.from_base_uri(url).build()
records = hudi_table.read_snapshot()

arrow_table = pa.Table.from_batches(records)
assert arrow_table.schema.names == [
"_hoodie_commit_time",
"_hoodie_commit_seqno",
"_hoodie_record_key",
"_hoodie_partition_path",
"_hoodie_file_name",
"id",
"name",
"isActive",
"intField",
"longField",
"floatField",
"doubleField",
"decimalField",
"dateField",
"timestampField",
"binaryField",
"arrayField",
"mapField",
"structField",
"byteField",
"shortField",
]
assert arrow_table.num_rows == 4
arrow_table = pa.Table.from_batches(records)
assert arrow_table.schema.names == [
"_hoodie_commit_time",
"_hoodie_commit_seqno",
"_hoodie_record_key",
"_hoodie_partition_path",
"_hoodie_file_name",
"id",
"name",
"isActive",
"intField",
"longField",
"floatField",
"doubleField",
"decimalField",
"dateField",
"timestampField",
"binaryField",
"arrayField",
"mapField",
"structField",
"byteField",
"shortField",
]
assert arrow_table.num_rows == 4

print("Python API: read snapshot successfully!")
3 changes: 3 additions & 0 deletions demo/infra/mc/prepare_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ mc mb local/hudi-demo
# unzip the data
mkdir -p /tmp/tables/cow/
for zip in /opt/data/tables/cow/*.zip; do unzip -o "$zip" -d "/tmp/tables/cow/"; done
mkdir -p /tmp/tables/mor/
for zip in /opt/data/tables/mor/*.zip; do unzip -o "$zip" -d "/tmp/tables/mor/"; done

# copy the data to the bucket
mc cp -r /tmp/tables/cow/* local/hudi-demo/cow/
mc cp -r /tmp/tables/mor/* local/hudi-demo/mor/

0 comments on commit cd4cb14

Please sign in to comment.