2023-09-21 14:51:08 -04:00
|
|
|
import click
|
2023-09-15 18:13:39 -04:00
|
|
|
from deltalake import DeltaTable
|
|
|
|
|
|
|
|
|
2023-09-21 14:51:08 -04:00
|
|
|
@click.command()
|
|
|
|
@click.option("--table-uri", type=str)
|
|
|
|
def run_check(table_uri):
|
|
|
|
print(f"Checking contents of table at {table_uri}")
|
2023-09-15 18:13:39 -04:00
|
|
|
delta_table = DeltaTable(
|
2023-09-21 14:51:08 -04:00
|
|
|
table_uri=table_uri,
|
2023-09-15 18:13:39 -04:00
|
|
|
)
|
|
|
|
|
2023-11-03 08:46:56 -04:00
|
|
|
expected_rows = 5
|
|
|
|
found_rows = len(delta_table.to_pandas())
|
|
|
|
print(
|
|
|
|
f"Checking if expected number of rows ({expected_rows}) "
|
|
|
|
f"matches how many were found: {found_rows}"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
expected_rows == found_rows
|
|
|
|
), f"expected number of rows doesn't match how many were found: {expected_rows}/{found_rows}"
|
2023-09-21 14:51:08 -04:00
|
|
|
print("table check complete")
|
2023-09-15 18:13:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
run_check()
|