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(type): add support for Decimal type in database #66

Merged
merged 3 commits into from
Sep 25, 2023

Conversation

loloxwg
Copy link
Member

@loloxwg loloxwg commented Sep 24, 2023

The database schema has been updated to support the Decimal data type. This includes casting from and to Decimal type in the DataValue structure, creating a new Decimal field in both LogicalType and DataValue structures, and adding appropriate match arms in the from_sqlparser_data_type and can_implicit_cast functions. A new error type for when an attempted conversion from Decimal fails have also been implemented. The round_dp_with_strategy method is used to provide flexibility with scale modification and rounding strategy when casting to Decimal type. Tests for the new functionality have been added as well.

What problem does this PR solve?

Add corresponding issue link with summary if exists -->

Issue link:

What is changed and how it works?

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

The database schema has been updated to support the Decimal data type. This includes casting from and to Decimal type in the DataValue structure, creating a new Decimal field in both LogicalType and DataValue structures, and adding appropriate match arms in the from_sqlparser_data_type and can_implicit_cast functions. A new error type for when an attempted conversion from Decimal fails have also been implemented. The round_dp_with_strategy method is used to provide flexibility with scale modification and rounding strategy when casting to Decimal type. Tests for the new functionality have been added as well.
@KKould KKould added the enhancement New feature or request label Sep 24, 2023
@loloxwg loloxwg changed the title fret(type): add support for Decimal type in database feat(type): add support for Decimal type in database Sep 24, 2023
Copy link
Member

@KKould KKould left a comment

Choose a reason for hiding this comment

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

I made three changes:

  • optimized the length check logic of Decimal and removed other types of check logic.
  • optimized the conversion between various types and Decimal, eliminating a lot of dangerous unwrap
  • the length of Decimal is obviously 16 when serialized, so fix its definition as a fixed-length type.

Copy link
Member Author

@loloxwg loloxwg left a comment

Choose a reason for hiding this comment

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

lgtm

@loloxwg loloxwg merged commit a696e2a into KipData:main Sep 25, 2023
@loloxwg loloxwg deleted the decimal branch September 25, 2023 02:31
@KKould KKould linked an issue Sep 27, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Decimal type
2 participants