@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long value) { // round down the current timestamp to days ISOChronology chronology = unpackChronology(value); long date = chronology.dayOfYear().roundFloor(unpackMillisUtc(value)); // date is currently midnight in timezone of the original value // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return unpackChronology(timestampWithTimeZone).dayOfYear().get(unpackMillisUtc(timestampWithTimeZone)); }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) { ISOChronology chronology; if (session.isLegacyTimestamp()) { // round down the current timestamp to days chronology = getChronology(session.getTimeZoneKey()); long date = chronology.dayOfYear().roundFloor(value); // date is currently midnight in timezone of the session // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); } else { return TimeUnit.MILLISECONDS.toDays(value); } }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestamp(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long timestamp) { if (session.isLegacyTimestamp()) { return getChronology(session.getTimeZoneKey()).dayOfYear().get(timestamp); } else { return DAY_OF_YEAR.get(timestamp); } }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) { // round down the current timestamp to days ISOChronology chronology = getChronology(session.getTimeZoneKey()); long date = chronology.dayOfYear().roundFloor(value); // date is currently midnight in timezone of the session // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long value) { // round down the current timestamp to days ISOChronology chronology = unpackChronology(value); long date = chronology.dayOfYear().roundFloor(unpackMillisUtc(value)); // date is currently midnight in timezone of the original value // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long value) { // round down the current timestamp to days ISOChronology chronology = unpackChronology(value); long date = chronology.dayOfYear().roundFloor(unpackMillisUtc(value)); // date is currently midnight in timezone of the original value // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long value) { // round down the current timestamp to days ISOChronology chronology = unpackChronology(value); long date = chronology.dayOfYear().roundFloor(unpackMillisUtc(value)); // date is currently midnight in timezone of the original value // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) { ISOChronology chronology; if (session.isLegacyTimestamp()) { // round down the current timestamp to days chronology = getChronology(session.getTimeZoneKey()); long date = chronology.dayOfYear().roundFloor(value); // date is currently midnight in timezone of the session // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); } else { return TimeUnit.MILLISECONDS.toDays(value); } }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return unpackChronology(timestampWithTimeZone).dayOfYear().get(unpackMillisUtc(timestampWithTimeZone)); }
@ScalarFunction("date") @ScalarOperator(CAST) @SqlType(StandardTypes.DATE) public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) { ISOChronology chronology; if (session.isLegacyTimestamp()) { // round down the current timestamp to days chronology = getChronology(session.getTimeZoneKey()); long date = chronology.dayOfYear().roundFloor(value); // date is currently midnight in timezone of the session // convert to UTC long millis = date + chronology.getZone().getOffset(date); return TimeUnit.MILLISECONDS.toDays(millis); } else { return TimeUnit.MILLISECONDS.toDays(value); } }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return unpackChronology(timestampWithTimeZone).dayOfYear().get(unpackMillisUtc(timestampWithTimeZone)); }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestamp(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long timestamp) { return getChronology(session.getTimeZoneKey()).dayOfYear().get(timestamp); }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return unpackChronology(timestampWithTimeZone).dayOfYear().get(unpackMillisUtc(timestampWithTimeZone)); }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestamp(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long timestamp) { if (session.isLegacyTimestamp()) { return getChronology(session.getTimeZoneKey()).dayOfYear().get(timestamp); } else { return DAY_OF_YEAR.get(timestamp); } }
@Description("day of the year of the given timestamp") @ScalarFunction(value = "day_of_year", alias = "doy") @SqlType(StandardTypes.BIGINT) public static long dayOfYearFromTimestamp(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long timestamp) { if (session.isLegacyTimestamp()) { return getChronology(session.getTimeZoneKey()).dayOfYear().get(timestamp); } else { return DAY_OF_YEAR.get(timestamp); } }