Skip to content

[Python] Keep Nexmark Query 1 bid prices as integers - #40548

Open
raams95 wants to merge 1 commit into
apache:masterfrom
raams95:fix-nexmark-query1-integer-price
Open

raams95 wants to merge 1 commit into
apache:masterfrom
raams95:fix-nexmark-query1-integer-price

Conversation

@raams95

@raams95 raams95 commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #24678

Python Nexmark Query 1 converts bid prices with bid.price * 0.89, which turns the price into a float. BidCoder writes the price with VarIntCoderImpl, so encoding the converted bid fails with:

TypeError: unsupported operand type(s) for &: 'float' and 'int'

The Java version of the query does integer math, (bid.price * 89) / 100. This change does the same in Python with (bid.price * 89) // 100, so the result is still an int and matches the Java output.

I also added query1_test.py. It runs the query on a couple of bids and sends the results through Bid.CODER. It fails with the error above before the change and passes after it.

Testing:

  • pytest apache_beam/testing/benchmarks/nexmark/queries/query1_test.py
  • yapf --diff and ruff check on the changed files

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123 or fixes #456).
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Query 1 multiplied the bid price by a float, so the converted Bid could
not be encoded by BidCoder, which writes the price as a varint. Use the
same integer arithmetic as the Java Query 1.

Fixes apache#24678
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @tvalentyn for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Python Nexmark Query 1 is broken unsupported operand & float and int

1 participant