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

Remove unused methods and code #17448

Merged
merged 2 commits into from
May 11, 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
55 changes: 0 additions & 55 deletions core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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 = {
Expand All @@ -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();
}

/**
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void, Integer>
{
Expand Down