This is an automated email from the ASF dual-hosted git repository. jakevin pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 57a045c4052 [performance](Nereids): avoid use getStringValue() in getTimeFormatter (#28582) 57a045c4052 is described below commit 57a045c4052c2347698438b29500ea00f10c7d5b Author: jakevin <jakevin...@gmail.com> AuthorDate: Tue Dec 19 17:17:19 2023 +0800 [performance](Nereids): avoid use getStringValue() in getTimeFormatter (#28582) Original `getTimeFormatter()` will convert `long` to `string`, and then parse `string` to `int`. (cherry picked from commit 646f1ea087acf5153596e86ef49e84246a68af6c) --- .../org/apache/doris/analysis/DateLiteral.java | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java index 811b8d257b7..29db8d13e90 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java @@ -1066,25 +1066,17 @@ public class DateLiteral extends LiteralExpr { } public LocalDateTime getTimeFormatter() { - TemporalAccessor accessor; if (type.equals(Type.DATE) || type.equals(Type.DATEV2)) { - accessor = DATE_FORMATTER.parse(getStringValue()); + return LocalDateTime.of((int) this.year, (int) this.month, (int) this.day, 0, 0, 0); } else if (type.isDatetimeV2()) { - accessor = DATE_TIME_FORMATTER_TO_MICRO_SECOND.parse(getStringValue()); + return LocalDateTime.of((int) this.year, (int) this.month, (int) this.day, (int) this.hour, + (int) this.minute, + (int) this.second, (int) this.microsecond * 1000); } else { - accessor = DATE_TIME_FORMATTER.parse(getStringValue()); + return LocalDateTime.of((int) this.year, (int) this.month, (int) this.day, (int) this.hour, + (int) this.minute, + (int) this.second); } - final int year = accessor.get(ChronoField.YEAR); - final int month = accessor.get(ChronoField.MONTH_OF_YEAR); - final int dayOfMonth = accessor.get(ChronoField.DAY_OF_MONTH); - final int hour = getOrDefault(accessor, ChronoField.HOUR_OF_DAY, 0); - final int minute = getOrDefault(accessor, ChronoField.MINUTE_OF_HOUR, 0); - final int second = getOrDefault(accessor, ChronoField.SECOND_OF_MINUTE, 0); - final int microSeconds = getOrDefault(accessor, ChronoField.MICRO_OF_SECOND, 0); - - // LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, - // int second, int nanoOfSecond) - return LocalDateTime.of(year, month, dayOfMonth, hour, minute, second, microSeconds * 1000); } public DateLiteral plusYears(int year) throws AnalysisException { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org