Skip to content

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

Open
Amer-Mukhtar wants to merge 1 commit 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 1 commit 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

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 3 worse · ⚪ 10 noise (<±5%) · 0 without baseline

Compared against main 0ba5d1a 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 434 0.265 22,816/28,699/28,699 us 🟢 -17.9% / 🔴 +78.5%
🔴 bs=100 sw=10 sl=64 924 0.564 105,233/156,049/156,049 us 🔴 +19.2% / 🔴 +45.3%
bs=1000 sw=10 sl=64 1,101 0.672 914,839/958,871/958,871 us ⚪ within ±5% / 🟢 -9.2%
Baseline details

Latest main 0ba5d1a from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 434 tuples/sec 418 tuples/sec 760.2 tuples/sec +3.8% -42.9%
bs=10 sw=10 sl=64 MB/s 0.265 MB/s 0.255 MB/s 0.464 MB/s +3.9% -42.9%
bs=10 sw=10 sl=64 p50 22,816 us 20,344 us 12,781 us +12.2% +78.5%
bs=10 sw=10 sl=64 p95 28,699 us 34,938 us 16,118 us -17.9% +78.1%
bs=10 sw=10 sl=64 p99 28,699 us 34,938 us 19,074 us -17.9% +50.5%
bs=100 sw=10 sl=64 throughput 924 tuples/sec 963 tuples/sec 988.68 tuples/sec -4.0% -6.5%
bs=100 sw=10 sl=64 MB/s 0.564 MB/s 0.588 MB/s 0.603 MB/s -4.1% -6.5%
bs=100 sw=10 sl=64 p50 105,233 us 102,314 us 101,448 us +2.9% +3.7%
bs=100 sw=10 sl=64 p95 156,049 us 130,861 us 107,410 us +19.2% +45.3%
bs=100 sw=10 sl=64 p99 156,049 us 130,861 us 120,258 us +19.2% +29.8%
bs=1000 sw=10 sl=64 throughput 1,101 tuples/sec 1,082 tuples/sec 1,023 tuples/sec +1.8% +7.6%
bs=1000 sw=10 sl=64 MB/s 0.672 MB/s 0.66 MB/s 0.624 MB/s +1.8% +7.6%
bs=1000 sw=10 sl=64 p50 914,839 us 926,537 us 983,888 us -1.3% -7.0%
bs=1000 sw=10 sl=64 p95 958,871 us 978,638 us 1,030,100 us -2.0% -6.9%
bs=1000 sw=10 sl=64 p99 958,871 us 978,638 us 1,056,513 us -2.0% -9.2%
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,460.91,200,128000,434,0.265,22816.13,28698.68,28698.68
1,100,10,64,20,2163.64,2000,1280000,924,0.564,105232.52,156049.35,156049.35
2,1000,10,64,20,18168.18,20000,12800000,1101,0.672,914839.37,958870.50,958870.50

@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.28%. Comparing base (0ba5d1a) to head (72392be).
⚠️ Report is 9 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6833   +/-   ##
=========================================
  Coverage     76.28%   76.28%           
  Complexity     3452     3452           
=========================================
  Files          1161     1161           
  Lines         45916    45916           
  Branches       5099     5099           
=========================================
  Hits          35025    35025           
  Misses         9327     9327           
  Partials       1564     1564           
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 0ba5d1a
agent-service 76.76% <ø> (ø) Carriedforward from 0ba5d1a
amber 67.33% <ø> (ø) Carriedforward from 0ba5d1a
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from 0ba5d1a
config-service 66.66% <ø> (ø) Carriedforward from 0ba5d1a
file-service 67.21% <ø> (ø) Carriedforward from 0ba5d1a
frontend 81.72% <ø> (ø) Carriedforward from 0ba5d1a
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 0ba5d1a
pyamber 92.15% <ø> (ø) Carriedforward from 0ba5d1a
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 0ba5d1a

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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 on lines +148 to +151
def test_large_binary_field_carries_marker_metadata(self):
field = create_arrow_field_with_metadata("payload", AttributeType.LARGE_BINARY)
assert field.metadata == LARGE_BINARY_METADATA

Comment on lines +189 to +193
def test_non_attribute_type_raises_key_error(self, invalid_type):
"""Anything that isn't an AttributeType member fails the mapping lookup."""
with pytest.raises(KeyError):
create_arrow_field_with_metadata("f", invalid_type)

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