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

Support default precision and scale toCAST <EXPR> AS DECIMAL #2680

Merged
merged 4 commits into from
Jun 14, 2022

Conversation

gandronchik
Copy link
Contributor

@gandronchik gandronchik commented Jun 2, 2022

Hello! I am an employee of Cube.js. We use cast to0 decimal with default params. Thank you!

Which issue does this PR close?

Not exists

Rationale for this change

Postgres allow to cast to decimal in the following ways:

  • CAST(10 as Decimal(38, 10))
  • CAST(10 as Decimal(38))
  • CAST(10 as Decimal)

What changes are included in this PR?

  • Cast to decimal with default params

Are there any user-facing changes?

Ability to cast to decimal with default params

@github-actions github-actions bot added datafusion Changes in the datafusion crate sql SQL Planner labels Jun 2, 2022
@gandronchik gandronchik marked this pull request as draft June 2, 2022 17:37
@andygrove andygrove removed the datafusion Changes in the datafusion crate label Jun 3, 2022
@gandronchik gandronchik marked this pull request as ready for review June 6, 2022 10:29
@codecov-commenter
Copy link

Codecov Report

Merging #2680 (12b3faf) into master (49e072a) will increase coverage by 0.03%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master    #2680      +/-   ##
==========================================
+ Coverage   84.63%   84.66%   +0.03%     
==========================================
  Files         267      270       +3     
  Lines       46867    46921      +54     
==========================================
+ Hits        39665    39726      +61     
+ Misses       7202     7195       -7     
Impacted Files Coverage Δ
datafusion/sql/src/utils.rs 51.17% <71.42%> (+0.19%) ⬆️
datafusion/sql/src/planner.rs 81.53% <100.00%> (+0.05%) ⬆️
datafusion/core/src/logical_plan/plan.rs 84.61% <0.00%> (-9.19%) ⬇️
datafusion/core/src/test/mod.rs 83.48% <0.00%> (-4.55%) ⬇️
datafusion/core/src/physical_plan/planner.rs 77.51% <0.00%> (-1.82%) ⬇️
...afusion/core/src/datasource/file_format/parquet.rs 87.32% <0.00%> (-1.24%) ⬇️
...physical-expr/src/expressions/get_indexed_field.rs 93.95% <0.00%> (-0.94%) ⬇️
datafusion/core/src/execution/memory_manager.rs 70.25% <0.00%> (-0.63%) ⬇️
datafusion/core/src/catalog/schema.rs 85.00% <0.00%> (-0.49%) ⬇️
datafusion/common/src/scalar.rs 74.82% <0.00%> (-0.36%) ⬇️
... and 76 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49e072a...12b3faf. Read the comment docs.

@alamb
Copy link
Contributor

alamb commented Jun 6, 2022

@gandronchik can you please provide a description of this PR (namely what problem it is solving)? It is likely obvious to you but it isn't immediately obvious to me and it is much faster to review a PR (and get it merged) if we don't have to spend time researching the "why this change" and instead can focus on "is the change in behavior desired" and "does the code implemented the desired change in behavior"

🙏 thank you

@tustvold tustvold marked this pull request as draft June 8, 2022 16:32
@gandronchik
Copy link
Contributor Author

@gandronchik can you please provide a description of this PR (namely what problem it is solving)? It is likely obvious to you but it isn't immediately obvious to me and it is much faster to review a PR (and get it merged) if we don't have to spend time researching the "why this change" and instead can focus on "is the change in behavior desired" and "does the code implemented the desired change in behavior"

🙏 thank you

Sure, I will do it next time. I'm sorry for the inconvenience 🙏

@gandronchik gandronchik marked this pull request as ready for review June 10, 2022 08:30
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @gandronchik -- the description makes it much easier to understand what this PR was attempting to do.

@alamb alamb changed the title chore: default precision and scale for cast decimal Add default precision and scale toCAST <EXPR> AS DECIMAL Jun 10, 2022
@gandronchik gandronchik force-pushed the default_precision_and_scale_for_decimal branch from 7552bd9 to 2fc34f0 Compare June 14, 2022 09:52
@gandronchik gandronchik requested a review from alamb June 14, 2022 09:53
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks great -- thanks @gandronchik

@alamb alamb merged commit 613b43a into apache:master Jun 14, 2022
@alamb alamb changed the title Add default precision and scale toCAST <EXPR> AS DECIMAL Support default precision and scale toCAST <EXPR> AS DECIMAL Jun 14, 2022
waynexia pushed a commit to waynexia/arrow-datafusion that referenced this pull request Jun 20, 2022
* chore: default precision and scale for cast decimal

improve

ok

* fix decimal type max precision size (#48)

* minor

* add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants