Skip to content

Conversation

wcy-fdu
Copy link
Contributor

@wcy-fdu wcy-fdu commented Sep 22, 2025

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Allow up cast unsigned data type to signed data type (u16 -> i32, u32 -> i64, i64 -> decimal).

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • I have checked the Release Timeline and Currently Supported Versions to determine which release branches I need to cherry-pick this PR into.

Documentation

  • My PR needs documentation updates.
Release note

@github-actions github-actions bot added the type/fix Type: Bug fix. Only for pull requests. label Sep 22, 2025
case "bigint":
return val == Data.DataType.TypeName.INT64_VALUE;
return val == Data.DataType.TypeName.INT64_VALUE
|| val == Data.DataType.TypeName.DECIMAL_VALUE;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try to distinguish signed bigint from unsigned bigint in a later PR to achieve more accurate schema check.

@wcy-fdu wcy-fdu requested review from xiangjinwu, zwang28 and hzxa21 and removed request for xiangjinwu September 23, 2025 01:42
Comment on lines +432 to +434
Err(_) => {
// Only attempt base64 decoding in Precise mode
match self.bigint_unsigned_handling {
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract this special logic into a dedicated function, then we can do

-ScalarImpl::Decimal(Decimal::from_str(str).map_err(|_err| create_error())?)
+ScalarImpl::Decimal(Decimal::from_str(str).or_else(|_err| second_chance_base64(..))?)

This avoids deep indentation, and keeps the flow of normal handling uninterrupted when reading thru the code.

}
DataType::Int16 => {
handle_data_type!(mysql_row, mysql_datum_index, column_name, i16)
handle_data_type_with_signed!(mysql_row, mysql_datum_index, column_name, i16, u16)
Copy link
Contributor

Choose a reason for hiding this comment

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

How does upcast work here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the relationship between DataType::Int16, i16, and u16?

DataType::Date => Value::from(value.into_date().0),
DataType::Time => Value::from(value.into_time().0),
DataType::Timestamp => Value::from(value.into_timestamp().0),
DataType::Decimal => Value::from(value.into_decimal().to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

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

So we can also query mysql decimal or bigint unsigned with a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so.


match Decimal::from_str(str_val) {
Ok(decimal) => decimal.into(),
Err(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

When will Err occur?

}
DataType::Int16 => {
handle_data_type!(mysql_row, mysql_datum_index, column_name, i16)
handle_data_type_with_signed!(mysql_row, mysql_datum_index, column_name, i16, u16)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the relationship between DataType::Int16, i16, and u16?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Type: Bug fix. Only for pull requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants