JingsongLi commented on a change in pull request #11925:
URL: https://github.com/apache/flink/pull/11925#discussion_r416545572
##########
File path:
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/data/binary/BinaryStringDataUtil.java
##########
@@ -134,49 +136,49 @@
}
}
- return substrings.toArray(new BinaryString[0]);
+ return substrings.toArray(new BinaryStringData[0]);
}
/**
* Decide boolean representation of a string.
*/
- public static Boolean toBooleanSQL(BinaryString str) {
- BinaryString lowerCase = str.toLowerCase();
+ public static Boolean toBooleanSQL(BinaryStringData str) {
+ BinaryStringData lowerCase = str.toLowerCase();
return TRUE_STRINGS.contains(lowerCase) ? Boolean.TRUE :
(FALSE_STRINGS.contains(lowerCase) ?
Boolean.FALSE : null);
}
/**
* Calculate the hash value of a given string use {@link MessageDigest}.
*/
- public static BinaryString hash(BinaryString str, MessageDigest md) {
- return fromString(EncodingUtils.hex(md.digest(str.getBytes())));
+ public static BinaryStringData hash(BinaryStringData str, MessageDigest
md) {
+ return fromString(EncodingUtils.hex(md.digest(str.toBytes())));
}
- public static BinaryString hash(BinaryString str, String algorithm)
throws NoSuchAlgorithmException {
+ public static BinaryStringData hash(BinaryStringData str, String
algorithm) throws NoSuchAlgorithmException {
return hash(str, MessageDigest.getInstance(algorithm));
}
/**
- * Parses this BinaryString to Decimal.
+ * Parses this BinaryStringData to DecimalData.
*
- * @return Decimal value if the parsing was successful, or null if
overflow
+ * @return DecimalData value if the parsing was successful, or null if
overflow
* @throws NumberFormatException if the parsing failed.
*/
- public static Decimal toDecimal(BinaryString str, int precision, int
scale) {
+ public static DecimalData toDecimal(BinaryStringData str, int
precision, int scale) {
str.ensureMaterialized();
- if (precision > Decimal.MAX_LONG_DIGITS || str.getSizeInBytes()
> Decimal.MAX_LONG_DIGITS) {
+ if (DecimalDataUtils.isByteArrayDecimal(precision) ||
DecimalDataUtils.isByteArrayDecimal(str.getSizeInBytes())) {
Review comment:
It is right.
The case is, precision is 10 (less than `MAX_LONG_DIGITS`), but the string
data is more than 10 precision maybe, we can use big decimal to convert, and
then remove the extra decimals according to the precision.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]