Skip to content

fix(query): fix variant cast to number#19623

Open
b41sh wants to merge 3 commits intodatabendlabs:mainfrom
b41sh:fix-variant_to_number
Open

fix(query): fix variant cast to number#19623
b41sh wants to merge 3 commits intodatabendlabs:mainfrom
b41sh:fix-variant_to_number

Conversation

@b41sh
Copy link
Copy Markdown
Member

@b41sh b41sh commented Mar 26, 2026

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

This PR allows the variant value of floating-point numbers to be cast as integers, and floating-point numbers will be converted to integers by rounding

for example

select to_int64(parse_json('123.0')), to_int64(parse_json('999.9'));
╭───────────────────────────────────────────────────────────────╮
│ to_int64(parse_json('123.0')) │ to_int64(parse_json('999.9')) │
│             UInt8             │             UInt16            │
├───────────────────────────────┼───────────────────────────────┤
│                           1231000 │
╰───────────────────────────────────────────────────────────────╯
1 row read in 0.047 sec. Processed 1 row, 1 B (21.28 rows/s, 21 B/s)
  • fixes: #[Link the issue here]

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Mar 26, 2026
@b41sh b41sh marked this pull request as ready for review March 27, 2026 08:46
@b41sh b41sh requested a review from sundy-li March 27, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants