Skip to content

Conversation

@KKould
Copy link
Member

@KKould KKould commented Jan 5, 2026

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

Summary

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

@KKould KKould self-assigned this Jan 5, 2026
@KKould KKould requested review from Copilot and youngsofun January 5, 2026 11:17
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Jan 5, 2026
@KKould KKould force-pushed the feat/to_decimal_support_more_type branch from 38dd3ac to c3db040 Compare January 5, 2026 11:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the to_decimal function to support non-string input types (Boolean, Number, Decimal, and Variant) in addition to the existing string support. Previously, users had to use explicit type casts or the parameterized syntax to_decimal(precision, scale)(value) to convert numeric types to decimal. Now they can use the more intuitive syntax to_decimal(value, precision, scale).

Key changes:

  • Added support for 3-argument to_decimal calls with non-string types (value, precision, scale)
  • Implementation handles Boolean, Number (integers and floats), Decimal, and Variant types
  • Added comprehensive test cases covering floats, booleans, integers, and the try_to_decimal variant

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/query/functions/src/scalars/decimal/src/cast.rs Added pattern match case (3, false, false) to handle 3-argument calls with non-string types, enabling to_decimal(value, precision, scale) syntax for numeric types
tests/sqllogictests/suites/base/11_data_type/11_0006_data_type_decimal.test Added test cases for converting float literals, booleans, integers from numbers() table, and try_to_decimal with integer input

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KKould KKould marked this pull request as ready for review January 5, 2026 16:59
@sundy-li sundy-li merged commit c7485db into databendlabs:main Jan 7, 2026
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: to_decimal support more types

3 participants