Skip to content

Conversation

@Peiyingy
Copy link
Member

@Peiyingy Peiyingy commented Oct 30, 2025

Description

The Trino Gateway UI currently has a bug in the Query Distribution chart: query counts display correctly for even minutes, but always show zero for odd minutes due to the incorrect query count calculation.

Screenshot 2025-10-23 at 22 35 23 Screenshot 2025-10-23 at 22 35 46

The issue is caused by using Float.parseFloat when converting the minute value. Since float has limited precision, the last bit of the value was lost, results wrong minute buckets. This PR replaces Float.parseFloat with BigDecimal longvalue to ensure full precision and correct query counts for all minutes.

Testing Done

  • mvn clean install
  • Tested the new query distribution chart
Screenshot 2025-10-23 at 22 39 49 Screenshot 2025-10-23 at 22 40 00

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required, with the following suggested text:

* Fix some things.

Summary by Sourcery

Bug Fixes:

  • Replace Float.parseFloat with BigDecimal.longValue to avoid precision loss when computing minute buckets in the chart

@cla-bot
Copy link

cla-bot bot commented Oct 30, 2025

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Peiying Ye.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 30, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces float-based parsing of minute buckets with BigDecimal to fix incorrect zero query counts in the Query Distribution chart by preserving full precision during conversion.

Class diagram for updated minute parsing in HaQueryHistoryManager

classDiagram
    class HaQueryHistoryManager {
        +List<DistributionResponse.LineChart> findDistribution(Long ts)
    }
    class DistributionResponse {
    }
    class LineChart {
    }
    HaQueryHistoryManager --> DistributionResponse : uses
    DistributionResponse --> LineChart : contains
    HaQueryHistoryManager : - minute parsing changed from Float.parseFloat to BigDecimal.longValue
Loading

File-Level Changes

Change Details Files
Use BigDecimal for minute value parsing instead of Float.parseFloat to avoid precision loss
  • Replaced Float.parseFloat conversion with new BigDecimal(string).longValue()
  • Adjusted minute assignment to use BigDecimal.longValue()
gateway-ha/src/main/java/io/trino/gateway/ha/router/HaQueryHistoryManager.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Peiyingy Peiyingy force-pushed the Peiyingy/ui-distribution-minute-calculation branch from 64445d3 to b12e7ef Compare October 30, 2025 20:52
@cla-bot cla-bot bot added the cla-signed label Oct 30, 2025
@Peiyingy Peiyingy added the bug Something isn't working label Nov 1, 2025
@maswin
Copy link
Member

maswin commented Nov 3, 2025

Verified that the fix works. Can we add a test case?

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

Labels

bug Something isn't working cla-signed

Development

Successfully merging this pull request may close these issues.

2 participants