Skip to content

Conversation

@aryahassibi
Copy link
Contributor

@aryahassibi aryahassibi commented Jan 20, 2026

Summary

Fix BigQuery output to render decimals instead of fractions in query results.

Context

  • The runtime column comes back as BigQuery NUMERIC, and then Go represents them as *big.Rat
  • default formatting (fmt.Sprintf("%v", val) / JSON marshal) formats *big.Rat as numerator/denom, so we see fractions like 32097247/500000 instead
  • Now I changed it so that we convert all *big.Rat cells to decimal strings, and then output/log

demo

Summary by CodeRabbit

  • New Features

    • Per-cell numeric formatting for query results, producing consistent decimal strings with scaling based on column type across plain, JSON, and CSV outputs.
  • Tests

    • Added test coverage to validate numeric result normalization and decimal representation.

✏️ Tip: You can customize this high-level summary in your review settings.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Adds per-cell numeric formatting for Big Rat values in query outputs by normalizing numeric cells (e.g., *big.Rat) into decimal strings with optional scaling derived from column type (NUMERIC, BIGNUMERIC) or defaults. Introduces helper functions and applies normalization immediately after obtaining query results.

Changes

Cohort / File(s) Summary
Numeric formatting logic
cmd/fetch.go
Adds normalization and formatting helpers (normalizeQueryResultForOutput, normalizeCellForOutput, formatRatForOutput, scaleFromColumnType, parseScaleFromType, trimTrailingZeros), constants (defaultNumericScale, defaultBigNumericScale), and imports (math/big, strconv). Normalization is applied right after query results are obtained and before output (plain/JSON/CSV).
Normalization test
cmd/fetch_test.go
Adds TestNormalizeQueryResultForOutput to verify conversion of a big.Rat NUMERIC cell into the expected decimal string ("64.194494").

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble numbers, trim their toes,

From Rat to string the tidy rows,
Scales applied with gentle art,
Decimals gleam — a rabbit's part.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: converting BigQuery NUMERIC values to decimal format in query output, which directly matches the primary objective of formatting *big.Rat cells as decimals.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Docstrings were successfully generated.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #1568

coderabbitai bot added a commit that referenced this pull request Jan 21, 2026
Docstrings generation was requested by @batikankarakan.

* #1560 (comment)

The following files were modified:

* `cmd/fetch.go`
@aryahassibi aryahassibi marked this pull request as draft February 9, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant