Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Use logical types when possible #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions stac_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,12 @@ def get_columns(ds: pyarrow.parquet.ParquetDataset) -> list:
for field, col in zip(ds.schema, fragment.metadata.schema):
if field.name == "__null_dask_index__":
continue

column = {"name": field.name, "type": col.physical_type.lower()}

if col.logical_type.type == "NONE":
col_type = col.physical_type
else:
col_type = col.logical_type.type
column = {"name": field.name, "type": col_type.lower()}
if field.metadata is not None:
column["metadata"] = field.metadata
columns.append(column)
Expand Down
10 changes: 5 additions & 5 deletions test_stac_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def test_generate_item(self, partition):
)

expected_columns = [
{"name": "pop_est", "type": "int64"},
{"name": "continent", "type": "byte_array"},
{"name": "name", "type": "byte_array"},
{"name": "iso_a3", "type": "byte_array"},
{"name": "gdp_md_est", "type": "double"},
{"name": "pop_est", "type": "double"},
{"name": "continent", "type": "string"},
{"name": "name", "type": "string"},
{"name": "iso_a3", "type": "string"},
{"name": "gdp_md_est", "type": "int64"},
{"name": "geometry", "type": "byte_array"},
]
assert result.properties["table:columns"] == expected_columns
Expand Down