Skip to content

test(pyamber): add unit tests for attribute_type_utils#6833

Open
Amer-Mukhtar wants to merge 3 commits into
apache:mainfrom
Amer-Mukhtar:test/attribute-type-utils
Open

test(pyamber): add unit tests for attribute_type_utils#6833
Amer-Mukhtar wants to merge 3 commits into
apache:mainfrom
Amer-Mukhtar:test/attribute-type-utils

Conversation

@Amer-Mukhtar

@Amer-Mukhtar Amer-Mukhtar commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

What changes were proposed in this PR?

  • Add amber/src/test/python/core/models/schema/test_attribute_type_utils.py, a new pytest spec for the Python worker's attribute_type_utils, which previously had no dedicated unit tests.
  • Cover detect_attribute_type_from_arrow_field: every supported Arrow type, timestamps across all four units, the texera_type: LARGE_BINARY metadata marker taking precedence over the Arrow type, metadata that doesn't mark large binary falling back to the type mapping, and unmapped Arrow types raising KeyError.
  • Cover create_arrow_field_with_metadata: every AttributeType, metadata attached only for LARGE_BINARY, attribute names preserved verbatim (empty, unicode, emoji, long), and non-AttributeType input raising KeyError.
  • Cover round trips, including that stripping the metadata off a LARGE_BINARY field degrades it to STRING.

Any related issues, documentation, discussions?

Closes: #6635

How was this PR tested?

  • Ran: cd amber && pytest src/test/python/core/models/schema/test_attribute_type_utils.py -v, expect all 67 tests passing.
  • Test-only change; no production code is modified.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 8 worse · ⚪ 7 noise (<±5%) · 0 without baseline

Compared against main a351f44 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 408 0.249 24,666/33,269/33,269 us 🔴 -9.1% / 🔴 +100.5%
🔴 bs=100 sw=10 sl=64 887 0.541 107,414/160,949/160,949 us 🔴 +41.6% / 🔴 +47.5%
bs=1000 sw=10 sl=64 1,063 0.649 951,383/984,037/984,037 us ⚪ within ±5% / 🟢 -8.3%
Baseline details

Latest main a351f44 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 408 tuples/sec 449 tuples/sec 754.55 tuples/sec -9.1% -45.9%
bs=10 sw=10 sl=64 MB/s 0.249 MB/s 0.274 MB/s 0.461 MB/s -9.1% -45.9%
bs=10 sw=10 sl=64 p50 24,666 us 22,867 us 12,816 us +7.9% +92.5%
bs=10 sw=10 sl=64 p95 33,269 us 32,435 us 16,594 us +2.6% +100.5%
bs=10 sw=10 sl=64 p99 33,269 us 32,435 us 19,806 us +2.6% +68.0%
bs=100 sw=10 sl=64 throughput 887 tuples/sec 992 tuples/sec 969.38 tuples/sec -10.6% -8.5%
bs=100 sw=10 sl=64 MB/s 0.541 MB/s 0.605 MB/s 0.592 MB/s -10.6% -8.6%
bs=100 sw=10 sl=64 p50 107,414 us 98,055 us 103,584 us +9.5% +3.7%
bs=100 sw=10 sl=64 p95 160,949 us 113,638 us 109,097 us +41.6% +47.5%
bs=100 sw=10 sl=64 p99 160,949 us 113,638 us 117,304 us +41.6% +37.2%
bs=1000 sw=10 sl=64 throughput 1,063 tuples/sec 1,084 tuples/sec 1,004 tuples/sec -1.9% +5.9%
bs=1000 sw=10 sl=64 MB/s 0.649 MB/s 0.662 MB/s 0.613 MB/s -2.0% +5.9%
bs=1000 sw=10 sl=64 p50 951,383 us 925,606 us 1,002,357 us +2.8% -5.1%
bs=1000 sw=10 sl=64 p95 984,037 us 961,930 us 1,046,463 us +2.3% -6.0%
bs=1000 sw=10 sl=64 p99 984,037 us 961,930 us 1,073,661 us +2.3% -8.3%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,490.19,200,128000,408,0.249,24666.04,33269.02,33269.02
1,100,10,64,20,2255.69,2000,1280000,887,0.541,107413.96,160949.39,160949.39
2,1000,10,64,20,18820.35,20000,12800000,1063,0.649,951382.53,984037.15,984037.15

@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
47 1 46 0
View the top 1 failed test(s) by shortest run time
::src.test.python.core.models.schema.test_attribute_type_utils
Stack Traces | 0s run time
................../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11.../site-packages/_pytest/python.py:507: in importtestmodule
    mod = import_path(
................../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11....../site-packages/_pytest/pathlib.py:561: in import_path
    mod = _import_module_using_spec(
................../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11....../site-packages/_pytest/pathlib.py:725: in _import_module_using_spec
    spec.loader.exec_module(mod)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
................../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11.../_pytest/assertion/rewrite.py:188: in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
................../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11.../_pytest/assertion/rewrite.py:357: in _rewrite_test
    tree = ast.parse(source, filename=strfn)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
................../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ast.py:50: in parse
    return compile(source, filename, mode, flags,
E     File ".../models/schema/test_attribute_type_utils.py", line 189
E       def test_non_attribute_type_raises_type_or_key_error(self, invalid_type):
E   IndentationError: unexpected unindent

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@Amer-Mukhtar
Amer-Mukhtar marked this pull request as ready for review July 23, 2026 13:00
@aglinxinyuan
aglinxinyuan requested a review from Copilot July 24, 2026 03:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing unit-test coverage for the Python worker’s core.models.schema.attribute_type_utils conversion helpers, ensuring Arrow ↔ AttributeType mapping (including LARGE_BINARY’s metadata-based encoding) is validated and protected against regressions.

Changes:

  • Introduces a new pytest module covering detect_attribute_type_from_arrow_field across supported Arrow types, timestamp units, metadata precedence, and error behavior for unsupported types.
  • Adds coverage for create_arrow_field_with_metadata, including LARGE_BINARY marker metadata behavior and round-trip preservation through Arrow schemas.
Comments suppressed due to low confidence (1)

amber/src/test/python/core/models/schema/test_attribute_type_utils.py:179

  • Similar to the earlier metadata check: comparing field.metadata to a plain dict can be fragile. Prefer asserting the presence/value of the texera_type marker to avoid version-specific equality behavior.
    def test_unicode_name_survives_on_a_large_binary_field(self):
        field = create_arrow_field_with_metadata("列名", AttributeType.LARGE_BINARY)
        assert field.name == "列名"
        assert field.metadata == LARGE_BINARY_METADATA


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread amber/src/test/python/core/models/schema/test_attribute_type_utils.py Outdated
Amer-Mukhtar and others added 2 commits July 24, 2026 20:18
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Amer Mukhtar <136252708+Amer-Mukhtar@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit test coverage for attribute_type_utils

3 participants