Repository navigation
Add a temporal benchmark shape derived from the snapshot timestamp (GH-1287) #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1bf7f02
0a96670
64a8887
7e6349b
998a3b6
1086ef7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,23 @@ | |
| ) | ||
| # The flat projection with one column of Athena's json type, NULL where details is NULL. | ||
| JSON_COLUMNS = f"{FLAT_COLUMNS}, CAST(details AS JSON) AS details_json" | ||
| # The flat projection with temporal columns derived from the epoch microseconds of | ||
| # "timestamp"; from_unixtime() returns timestamp(3). UNLOAD and CTAS write Parquet | ||
| # through Hive, which has no time or with time zone types, so their reads project | ||
| # the timestamp and date columns only. The zone has no daylight saving time, whose | ||
| # ambiguous local times PyAthena rejects. | ||
| _SECONDS = '"timestamp" / 1e6' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Round two, evidence for the claims: Rerun on Athena after the zone change (two-row
Existing callers: the signature change of Operator view: the temporal columns are computed from Evidence: the transport validation was mutation-checked (with it removed, Limits:
|
||
| PARQUET_TEMPORAL_COLUMNS = ( | ||
| f"{FLAT_COLUMNS}, from_unixtime({_SECONDS}) AS event_time, " | ||
| f"CAST(from_unixtime({_SECONDS}) AS date) AS event_date" | ||
| ) | ||
| TEMPORAL_COLUMNS = ( | ||
| f"{PARQUET_TEMPORAL_COLUMNS}, " | ||
| f"from_unixtime({_SECONDS}, 'UTC') AS event_time_utc, " | ||
| f"from_unixtime({_SECONDS}, 'Asia/Tokyo') AS event_time_zone, " | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round one (behavior and implementation), base 7b2a084, initial head 1bf7f02, repaired head 7e6349b. Covered: Result: FINDINGS, repaired.
|
||
| f"from_unixtime({_SECONDS}, '+09:00') AS event_time_offset, " | ||
| f"CAST(from_unixtime({_SECONDS}) AS time(3)) AS event_clock" | ||
| ) | ||
|
|
||
|
|
||
| def identifier(value: str) -> str: | ||
|
|
@@ -139,23 +156,35 @@ def load(cls, path: Path) -> Settings: | |
| ) | ||
|
|
||
|
|
||
| def select_sql(database: str, table: str, shape: str) -> str: | ||
| def select_sql(database: str, table: str, shape: str, transport: str) -> str: | ||
| """Return the measured query of a shape over a snapshot table. | ||
|
|
||
| Args: | ||
| database: Database of the snapshot. | ||
| table: Snapshot table. | ||
| shape: ``flat``, ``nested``, or ``json``. | ||
| shape: ``flat``, ``nested``, ``json``, or ``temporal``. | ||
| transport: ``csv``, ``unload``, or ``ctas``. The ``temporal`` shape | ||
| projects only the columns that Parquet can hold for ``unload`` and | ||
| ``ctas``. | ||
|
|
||
| Returns: | ||
| The SELECT statement without a ``LIMIT``. | ||
|
|
||
| Raises: | ||
| ValueError: If the shape is unknown. | ||
| ValueError: If the shape or transport is unknown. | ||
| """ | ||
| columns = {"flat": FLAT_COLUMNS, "nested": NESTED_COLUMNS, "json": JSON_COLUMNS}.get(shape) | ||
| columns = { | ||
| "flat": FLAT_COLUMNS, | ||
| "nested": NESTED_COLUMNS, | ||
| "json": JSON_COLUMNS, | ||
| "temporal": TEMPORAL_COLUMNS, | ||
| }.get(shape) | ||
| if columns is None: | ||
| raise ValueError(f"Unknown shape: {shape}") | ||
| if transport not in {"csv", "unload", "ctas"}: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Round one, findings 2-3 (repaired):
Deferred, with reasons:
|
||
| raise ValueError(f"Unknown transport: {transport}") | ||
| if shape == "temporal" and transport != "csv": | ||
| columns = PARQUET_TEMPORAL_COLUMNS | ||
| return f'SELECT {columns} FROM "{identifier(database)}"."{identifier(table)}"' | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,6 +246,25 @@ def summarize(s3, location): | |
| ) | ||
|
|
||
|
|
||
| def test_temporal_trials_query_the_projection_of_their_transport(monkeypatch, tmp_path, run_stubs): | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Round one, test coverage: test names, mutation checks, and validation results. Test names: renamed in 64a8887 from Mutation checks on 1bf7f02:
Validation at 7e6349b: |
||
| payloads = [] | ||
| monkeypatch.setattr( | ||
| "pyathena_bench.runner.supervise", | ||
| lambda payload, events, settings: payloads.append(payload) or {"status": "ok"}, | ||
| ) | ||
| monkeypatch.setattr("pyathena_bench.runner.output_files", lambda *args: {}) | ||
| cases = [ | ||
| Case("arrow", transport=transport, output="native", shape="temporal") | ||
| for transport in ("csv", "unload") | ||
| ] | ||
| settings = replace(Settings(), warmups=0, repetitions=1) | ||
| assert run(settings, RUN_MANIFEST, cases, ["small"], tmp_path / "run") | ||
| csv, unload = (p["sql"] for p in payloads) | ||
| assert "AS event_time_utc" in csv | ||
| assert "AS event_date" in unload | ||
| assert "AS event_time_utc" not in unload | ||
|
|
||
|
|
||
| def test_filesystem_trials_transfer_the_prepared_object_within_the_scratch_bucket( | ||
| monkeypatch, tmp_path, run_stubs | ||
| ): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review round two (claims, callers, operations), base 7b2a084, initial head 7e6349b, repaired head 998a3b6.
Claims checked: the PR body, README, DATASET.md, the comments and docstrings in
config.pyandcases.py, and the commit messages.Result: FINDINGS, repaired.
timeorwith time zonetypes to Parquet. The evidence covers only UNLOAD and CTAS (NOT_SUPPORTED: Unsupported Hive type); Iceberg Parquet is a separate path that I did not check. Repaired in 998a3b6: the wording now names UNLOAD and CTAS.America/New_York, tested commit 1bf7f02, and the old test name, and it left out theValueErrorfor an unknown transport. Repaired in the PR description.