Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse decimal in expr. #10275

Merged
merged 18 commits into from
Mar 5, 2023
Merged

feat: parse decimal in expr. #10275

merged 18 commits into from
Mar 5, 2023

Conversation

youngsofun
Copy link
Member

@youngsofun youngsofun commented Mar 1, 2023

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

trying to split this pr, a drawback is that effect of some changes need this pr to test.

Summary

  • choose the minimal type for numeric literal, large number try to fit into decimal (may truncate trailing digits after the point), if overflow, use float64
  • 1 + -1 result in plus(1, -1) instead of plus(1, minus(1))
  • add auto cast rule Decimal->Float32/64
  • to_variant(decimal) result in number.

notice:

  • agg func like std(1.0), manually cast in test for now.

not in this pr

  • decimal to int (not auto)
  • string to decimal

Closes #10220
#10262

@vercel
Copy link

vercel bot commented Mar 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
databend ⬜️ Ignored (Inspect) Visit Preview Mar 5, 2023 at 2:23AM (UTC)

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Mar 1, 2023
@youngsofun youngsofun marked this pull request as draft March 1, 2023 02:31
@youngsofun youngsofun force-pushed the expr branch 2 times, most recently from dec2f84 to 9511c21 Compare March 1, 2023 05:04
@youngsofun youngsofun force-pushed the expr branch 2 times, most recently from 985677a to 7e08b1d Compare March 2, 2023 01:20
@youngsofun
Copy link
Member Author

float64 to float32 is here https://github.com/datafuselabs/databend/blob/main/src/query/functions/src/scalars/arithmetic.rs#L301

it comes last in the number_to_number functions (not include decimal)

@youngsofun youngsofun force-pushed the expr branch 2 times, most recently from b846637 to 9851d60 Compare March 3, 2023 15:45
@youngsofun youngsofun marked this pull request as ready for review March 3, 2023 15:47
@youngsofun youngsofun requested a review from b41sh March 3, 2023 15:54
@youngsofun
Copy link
Member Author

youngsofun commented Mar 4, 2023

@b41sh @sundy-li it was my mistake(not formaily with jsonb and variant): to_variant is fixed here

1941669

@youngsofun youngsofun mentioned this pull request Mar 5, 2023
@mergify mergify bot merged commit 2354482 into databendlabs:main Mar 5, 2023
@youngsofun youngsofun mentioned this pull request Mar 5, 2023
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
3 participants