starocean999 commented on code in PR #64026:
URL: https://github.com/apache/doris/pull/64026#discussion_r3418578403
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExprUtils.java:
##########
@@ -85,6 +97,39 @@ public static LiteralExpr createLiteral(String value, Type
type) throws Analysis
return literalExpr;
}
+ private static LiteralExpr createFloatingPointLiteral(String value, Type
type) throws AnalysisException {
+ try {
+ return new FloatLiteral(Double.parseDouble(value), type);
+ } catch (NumberFormatException e) {
+ throw new AnalysisException("Invalid floating-point literal: " +
value, e);
+ }
+ }
+
+ private static LiteralExpr createDecimalLiteral(String value, Type type)
throws AnalysisException {
+ Preconditions.checkArgument(type instanceof ScalarType);
+ ScalarType scalarType = (ScalarType) type;
+ BigDecimal decimalValue;
+ try {
+ decimalValue = new BigDecimal(value);
+ } catch (NumberFormatException e) {
+ throw new AnalysisException("Invalid floating-point literal: " +
value, e);
+ }
+ decimalValue = decimalValue.setScale(scalarType.getScalarScale(),
RoundingMode.HALF_UP);
Review Comment:
done
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/MultiPartitionDesc.java:
##########
@@ -381,11 +402,74 @@ private static DateTimeFormatter dateFormat(TimeUnit
timeUnitType,
}
private DateTimeFormatter dateTypeFormat(String dateTimeStr) {
- String s = DATE_FORMAT;
- if (this.timeUnitType.equals(TimeUnit.HOUR) || dateTimeStr.length() ==
19) {
- s = DATETIME_FORMAT;
+ if (isTimestampTzFormat(dateTimeStr)) {
+ return dateTimeFormatter(stripTimeZone(dateTimeStr));
+ }
+ if (this.timeUnitType.equals(TimeUnit.HOUR) ||
isDateTimeFormat(dateTimeStr)) {
+ return dateTimeFormatter(dateTimeStr);
+ }
+ return DateTimeFormatter.ofPattern(DATE_FORMAT);
+ }
+
+ private String formatPartitionDateTime(LocalDateTime dateTime, String
originalDateTimeStr) {
+ if (isTimestampTzFormat(originalDateTimeStr)) {
+ return dateTime.format(dateTypeFormat(originalDateTimeStr)) +
timeZoneSuffix(originalDateTimeStr);
+ }
+ return dateTime.format(dateTypeFormat(originalDateTimeStr));
+ }
+
+ private static boolean isDateTimeFormat(String dateTimeStr) {
+ int length = dateTimeStr.length();
+ return length == 19 || (length >= 21 && length <= 26);
+ }
+
+ private static boolean isTimestampTzFormat(String dateTimeStr) {
+ int length = dateTimeStr.length();
+ return (length == 25 || (length >= 27 && length <= 32)) &&
hasTimeZoneSuffix(dateTimeStr);
+ }
+
+ private static boolean hasTimeZoneSuffix(String dateTimeStr) {
+ return dateTimeStr.length() >= 6
+ && (dateTimeStr.charAt(dateTimeStr.length() - 6) == '+'
+ || dateTimeStr.charAt(dateTimeStr.length() - 6) == '-')
+ && dateTimeStr.charAt(dateTimeStr.length() - 3) == ':';
+ }
+
+ private static DateTimeFormatter timestampTzFormatter(String dateTimeStr) {
+ return
DateTimeFormatter.ofPattern(dateTimePattern(stripTimeZone(dateTimeStr)) +
"XXX");
+ }
+
+ private static DateTimeFormatter dateTimeFormatter(String dateTimeStr) {
+ return DateTimeFormatter.ofPattern(dateTimePattern(dateTimeStr));
+ }
+
+ private static String dateTimePattern(String dateTimeStr) {
+ switch (dateTimeStr.length()) {
+ case 19:
+ return DATETIME_FORMAT;
Review Comment:
done
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]