diff --git a/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java b/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java index 7ee4da4e4cec..7fe88f525dee 100644 --- a/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java +++ b/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java @@ -20,12 +20,10 @@ import io.trino.sql.tree.IntervalLiteral.IntervalField; import org.assertj.core.util.VisibleForTesting; import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.joda.time.DurationFieldType; import org.joda.time.MutablePeriod; import org.joda.time.Period; import org.joda.time.ReadWritablePeriod; -import org.joda.time.chrono.ISOChronology; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatterBuilder; @@ -48,12 +46,9 @@ import static com.google.common.base.Preconditions.checkArgument; import static io.trino.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT; -import static io.trino.spi.type.DateTimeEncoding.unpackMillisUtc; import static io.trino.util.DateTimeZoneIndex.getChronology; import static io.trino.util.DateTimeZoneIndex.getDateTimeZone; import static io.trino.util.DateTimeZoneIndex.packDateTimeWithZone; -import static io.trino.util.DateTimeZoneIndex.unpackChronology; -import static io.trino.util.DateTimeZoneIndex.unpackDateTimeZone; import static java.lang.Math.toIntExact; import static java.lang.String.format; @@ -136,7 +131,6 @@ public static String printDate(int days) return DATE_FORMATTER.print(TimeUnit.DAYS.toMillis(days)); } - private static final DateTimeFormatter TIMESTAMP_WITH_TIME_ZONE_FORMATTER; private static final DateTimeFormatter TIMESTAMP_WITH_OR_WITHOUT_TIME_ZONE_FORMATTER; static { @@ -165,10 +159,6 @@ public static String printDate(int days) DateTimeFormat.forPattern("yyyyyy-M-d H:m:s.SSS ZZZ").getParser()}; DateTimePrinter timestampWithTimeZonePrinter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS ZZZ").getPrinter(); - TIMESTAMP_WITH_TIME_ZONE_FORMATTER = new DateTimeFormatterBuilder() - .append(timestampWithTimeZonePrinter, timestampWithTimeZoneParser) - .toFormatter() - .withOffsetParsed(); DateTimeParser[] timestampWithOrWithoutTimeZoneParser = Stream.concat(Stream.of(timestampWithoutTimeZoneParser), Stream.of(timestampWithTimeZoneParser)) .toArray(DateTimeParser[]::new); @@ -194,15 +184,7 @@ public static long convertToTimestampWithTimeZone(TimeZoneKey timeZoneKey, Strin return packDateTimeWithZone(dateTime); } - public static String printTimestampWithTimeZone(long timestampWithTimeZone) - { - ISOChronology chronology = unpackChronology(timestampWithTimeZone); - long millis = unpackMillisUtc(timestampWithTimeZone); - return TIMESTAMP_WITH_TIME_ZONE_FORMATTER.withChronology(chronology).print(millis); - } - private static final DateTimeFormatter TIME_FORMATTER; - private static final DateTimeFormatter TIME_WITH_TIME_ZONE_FORMATTER; static { DateTimeParser[] timeWithoutTimeZoneParser = { @@ -211,22 +193,6 @@ public static String printTimestampWithTimeZone(long timestampWithTimeZone) DateTimeFormat.forPattern("H:m:s.SSS").getParser()}; DateTimePrinter timeWithoutTimeZonePrinter = DateTimeFormat.forPattern("HH:mm:ss.SSS").getPrinter(); TIME_FORMATTER = new DateTimeFormatterBuilder().append(timeWithoutTimeZonePrinter, timeWithoutTimeZoneParser).toFormatter().withZoneUTC(); - - DateTimeParser[] timeWithTimeZoneParser = { - DateTimeFormat.forPattern("H:mZ").getParser(), - DateTimeFormat.forPattern("H:m Z").getParser(), - DateTimeFormat.forPattern("H:m:sZ").getParser(), - DateTimeFormat.forPattern("H:m:s Z").getParser(), - DateTimeFormat.forPattern("H:m:s.SSSZ").getParser(), - DateTimeFormat.forPattern("H:m:s.SSS Z").getParser(), - DateTimeFormat.forPattern("H:mZZZ").getParser(), - DateTimeFormat.forPattern("H:m ZZZ").getParser(), - DateTimeFormat.forPattern("H:m:sZZZ").getParser(), - DateTimeFormat.forPattern("H:m:s ZZZ").getParser(), - DateTimeFormat.forPattern("H:m:s.SSSZZZ").getParser(), - DateTimeFormat.forPattern("H:m:s.SSS ZZZ").getParser()}; - DateTimePrinter timeWithTimeZonePrinter = DateTimeFormat.forPattern("HH:mm:ss.SSS ZZZ").getPrinter(); - TIME_WITH_TIME_ZONE_FORMATTER = new DateTimeFormatterBuilder().append(timeWithTimeZonePrinter, timeWithTimeZoneParser).toFormatter().withOffsetParsed(); } /** @@ -241,27 +207,6 @@ public static long parseLegacyTime(TimeZoneKey timeZoneKey, String value) return TIME_FORMATTER.withZone(getDateTimeZone(timeZoneKey)).parseMillis(value); } - public static String printTimeWithTimeZone(long timeWithTimeZone) - { - DateTimeZone timeZone = unpackDateTimeZone(timeWithTimeZone); - long millis = unpackMillisUtc(timeWithTimeZone); - return TIME_WITH_TIME_ZONE_FORMATTER.withZone(timeZone).print(millis); - } - - public static String printTimeWithoutTimeZone(long value) - { - return TIME_FORMATTER.print(value); - } - - /** - * @deprecated applicable in legacy timestamp semantics only - */ - @Deprecated - public static String printTimeWithoutTimeZone(TimeZoneKey timeZoneKey, long value) - { - return TIME_FORMATTER.withZone(getDateTimeZone(timeZoneKey)).print(value); - } - private static final int YEAR_FIELD = 0; private static final int MONTH_FIELD = 1; private static final int DAY_FIELD = 3; diff --git a/core/trino-parser/src/main/java/io/trino/sql/SqlFormatter.java b/core/trino-parser/src/main/java/io/trino/sql/SqlFormatter.java index 9692ae9129a5..e703d983eb34 100644 --- a/core/trino-parser/src/main/java/io/trino/sql/SqlFormatter.java +++ b/core/trino-parser/src/main/java/io/trino/sql/SqlFormatter.java @@ -187,13 +187,6 @@ private static String formatExpression(Expression expression) return ExpressionFormatter.formatExpression(expression); } - /** - * @deprecated Use {@link #formatName(Identifier)} instead. - */ - @Deprecated - @SuppressWarnings("unused") - private static void formatExpression(Identifier identifier) {} - private static class Formatter extends AstVisitor {