Skip to content

Commit

Permalink
Add another test for creating index table.
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu committed Dec 13, 2023
1 parent c96627a commit d242594
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/hipscat_import/index/test_run_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,46 @@ def test_run_index(

schema = pq.read_metadata(os.path.join(args.catalog_path, "_common_metadata")).schema.to_arrow_schema()
assert schema.equals(basic_index_parquet_schema, check_metadata=False)


@pytest.mark.dask
def test_run_index_on_source(
small_sky_source_catalog,
tmp_path,
):
"""Test appropriate metadata is written, when primary catalog covers multiple pixels."""

args = IndexArguments(
input_catalog_path=small_sky_source_catalog,
indexing_column="source_id",
output_path=tmp_path,
output_artifact_name="small_sky_source_id_index",
overwrite=True,
progress_bar=False,
)
runner.run(args)

# Check that the catalog metadata file exists
catalog = Dataset.read_from_hipscat(args.catalog_path)
assert catalog.on_disk
assert catalog.catalog_path == args.catalog_path

basic_index_parquet_schema = pa.schema(
[
pa.field("_hipscat_index", pa.uint64()),
pa.field("Norder", pa.uint8()),
pa.field("Dir", pa.uint64()),
pa.field("Npix", pa.uint64()),
pa.field("source_id", pa.int64()),
]
)

outfile = os.path.join(args.catalog_path, "index", "part.0.parquet")
schema = pq.read_metadata(outfile).schema.to_arrow_schema()
assert schema.equals(basic_index_parquet_schema, check_metadata=False)

schema = pq.read_metadata(os.path.join(args.catalog_path, "_metadata")).schema.to_arrow_schema()
assert schema.equals(basic_index_parquet_schema, check_metadata=False)

schema = pq.read_metadata(os.path.join(args.catalog_path, "_common_metadata")).schema.to_arrow_schema()
assert schema.equals(basic_index_parquet_schema, check_metadata=False)

0 comments on commit d242594

Please sign in to comment.