@InputFunction public static void weightedInput(@AggregationState DigestAndPercentileArrayState state, @SqlType(StandardTypes.DOUBLE) double value, @SqlType(StandardTypes.BIGINT) long weight, @SqlType("array(double)") Block percentilesArrayBlock) { ApproximateLongPercentileArrayAggregations.weightedInput(state, doubleToSortableLong(value), weight, percentilesArrayBlock); }
@Description("time zone minute of the given timestamp") @ScalarFunction("timezone_minute") @SqlType(StandardTypes.BIGINT) public static long timeZoneMinuteFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return extractZoneOffsetMinutes(timestampWithTimeZone) % 60; }
@Description("difference of the given times in the given unit") @ScalarFunction("date_diff") @LiteralParameters("x") @SqlType(StandardTypes.BIGINT) public static long diffTimestampWithTimeZone( @SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone1, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone2) { return getTimestampField(unpackChronology(timestampWithTimeZone1), unit).getDifferenceAsLong(unpackMillisUtc(timestampWithTimeZone2), unpackMillisUtc(timestampWithTimeZone1)); }
@Description("millisecond of the second of the given time") @ScalarFunction("millisecond") @SqlType(StandardTypes.BIGINT) public static long millisecondFromTimeWithTimeZone(@SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long time) { // No need to check the associated zone here. A zone always has offset of whole minutes. return MILLISECOND_OF_SECOND.get(unpackMillisUtc(time)); }
@Description("truncate to the specified precision") @ScalarFunction("date_trunc") @LiteralParameters("x") @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long truncateTimeWithTimeZone(@SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long timeWithTimeZone) { long millis = getTimeField(unpackChronology(timeWithTimeZone), unit).roundFloor(unpackMillisUtc(timeWithTimeZone)); return updateMillisUtc(millis, timeWithTimeZone); }
@Description("day of the month of the given timestamp") @ScalarFunction(value = "day", alias = "day_of_month") @SqlType(StandardTypes.BIGINT) public static long dayFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return unpackChronology(timestampWithTimeZone).dayOfMonth().get(unpackMillisUtc(timestampWithTimeZone)); }
@Description("quarter of the year of the given timestamp") @ScalarFunction("quarter") @SqlType(StandardTypes.BIGINT) public static long quarterFromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { return QUARTER_OF_YEAR.getField(unpackChronology(timestampWithTimeZone)).get(unpackMillisUtc(timestampWithTimeZone)); }
@InputFunction public static void doubleInput(@AggregationState VarianceState state, @SqlType(StandardTypes.DOUBLE) double value) { updateVarianceState(state, value); }
@InputFunction public static void input(@AggregationState LongState state, @SqlType(StandardTypes.BOOLEAN) boolean value) { if (value) { state.setLong(state.getLong() + 1); } }
@Description("minute of the hour of the given time") @ScalarFunction("minute") @SqlType(StandardTypes.BIGINT) public static long minuteFromTime(ConnectorSession session, @SqlType(StandardTypes.TIME) long time) { if (session.isLegacyTimestamp()) { return getChronology(session.getTimeZoneKey()).minuteOfHour().get(time); } else { return MINUTE_OF_HOUR.get(time); } }
@Description("month of the year of the given timestamp") @ScalarFunction("month") @SqlType(StandardTypes.BIGINT) public static long monthFromTimestamp(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long timestamp) { if (session.isLegacyTimestamp()) { return getChronology(session.getTimeZoneKey()).monthOfYear().get(timestamp); } else { return MONTH_OF_YEAR.get(timestamp); } }
@InputFunction public static void input(@AggregationState LongAndDoubleState state, @SqlType(StandardTypes.DOUBLE) double value) { state.setLong(state.getLong() + 1); state.setDouble(state.getDouble() + Math.log(value)); }
@InputFunction @TypeParameter("T") public static void input( @OperatorDependency(operator = XX_HASH_64, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle methodHandle, @AggregationState HyperLogLogState state, @SqlType("T") Slice value) { ApproximateCountDistinctAggregation.input(methodHandle, state, value, DEFAULT_STANDARD_ERROR); }
@Description("current time zone") @ScalarFunction("current_timezone") @SqlType(StandardTypes.VARCHAR) public static Slice currentTimeZone(ConnectorSession session) { return utf8Slice(session.getTimeZoneKey().getId()); }
@InputFunction public static void input(@AggregationState LongAndDoubleState state, @SqlType(StandardTypes.BIGINT) long value) { state.setLong(state.getLong() + 1); state.setDouble(state.getDouble() + value); }
@InputFunction public static void input(@AggregationState LongAndDoubleState state, @SqlType(StandardTypes.DOUBLE) double value) { state.setLong(state.getLong() + 1); state.setDouble(state.getDouble() + value); }
@InputFunction public static void bitAnd(@AggregationState NullableLongState state, @SqlType(StandardTypes.BIGINT) long value) { if (state.isNull()) { state.setLong(value); } else { state.setLong(state.getLong() & value); } state.setNull(false); }