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

【1.1.15】Fix Datatype Decimal Error #265

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object DataType extends Logging {
val LOWCASE_NULL_VALUE = "null"

val DECIMAL_REGEX = "^decimal\\(\\d*\\,\\d*\\)".r.unanchored
val DECIMAL_REGEX_BLANK = "^decimal\\(\\s*\\d*\\s*,\\s*\\d*\\s*\\)".r.unanchored

val SHORT_REGEX = "^short.*".r.unanchored
val INT_REGEX = "^int.*".r.unanchored
Expand Down Expand Up @@ -62,7 +63,7 @@ object DataType extends Logging {
case "date" => DateType
case "timestamp" => TimestampType
case "binary" => BinaryType
case "decimal" | DECIMAL_REGEX() => DecimalType
case "decimal" | DECIMAL_REGEX() | DECIMAL_REGEX_BLANK() => DecimalType
case ARRAY_REGEX() => ArrayType

Choose a reason for hiding this comment

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

补充 单元测试

Choose a reason for hiding this comment

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

^decimal\\(\\d*\\,\\d*\\)
^decimal\\(\\s*\\d*\\s*,\\s*\\d*\\s*\\)

Copy link
Author

Choose a reason for hiding this comment

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

done

case MAP_REGEX() => MapType
case LIST_REGEX() => ListType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ class DataTypeTest {
Assertions.assertNotNull(str)
}

@Test
@DisplayName("decimalTest")
def decimalTest(): Unit = {
val dateType = DataType.toDataType("decimal")
val str = DataType.toValue(dateType, "decimal(10,8)")
Assertions.assertNotNull(str)
}

}
Loading