@Override public void setup() { int timeZoneIndex = contextInfo.getRootFragmentTimeZone(); org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.arrow.vector.util.DateUtility.getTimeZone(timeZoneIndex)); org.joda.time.LocalDateTime now = new org.joda.time.LocalDateTime(contextInfo.getQueryStartTime(), timeZone); queryStartTime= (now.getHourOfDay() * org.apache.arrow.vector.util.DateUtility.hoursToMillis) + (now.getMinuteOfHour() * org.apache.arrow.vector.util.DateUtility.minutesToMillis) + (now.getSecondOfMinute() * org.apache.arrow.vector.util.DateUtility.secondsToMillis) + (now.getMillisOfSecond()); }
@Override public void setup() { int timeZoneIndex = contextInfo.getRootFragmentTimeZone(); org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.arrow.vector.util.DateUtility.getTimeZone(timeZoneIndex)); org.joda.time.LocalDateTime now = new org.joda.time.LocalDateTime(contextInfo.getQueryStartTime(), timeZone); queryStartDate = (new org.joda.time.DateMidnight(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), timeZone)). withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis(); }
@Override public RexNode convertCall(SqlRexContext cx, SqlCall call) { final int timeZoneIndex = getContextInformation().getRootFragmentTimeZone(); final DateTimeZone timeZone = DateTimeZone.forID(DateUtility.getTimeZone(timeZoneIndex)); final LocalDateTime dateTime = new LocalDateTime(getContextInformation().getQueryStartTime(), timeZone); final long queryStartTime = (dateTime.getHourOfDay() * DateUtility.hoursToMillis) + (dateTime.getMinuteOfHour() * DateUtility.minutesToMillis) + (dateTime.getSecondOfMinute() * DateUtility.secondsToMillis) + (dateTime.getMillisOfSecond()); return cx.getRexBuilder() .makeTimeLiteral( DateTimes.toDateTime(new LocalDateTime(queryStartTime, DateTimeZone.UTC)) .toCalendar(null), // null sets locale to default locale getReturnTypePrecision(cx, call)); } }
@Override public RexNode convertCall(SqlRexContext cx, SqlCall call) { final int timeZoneIndex = getContextInformation().getRootFragmentTimeZone(); final DateTimeZone timeZone = DateTimeZone.forID(DateUtility.getTimeZone(timeZoneIndex)); final LocalDateTime dateTime = new LocalDateTime(getContextInformation().getQueryStartTime(), timeZone); final long midNightAsMillis = new DateMidnight(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), timeZone) .withZoneRetainFields(DateTimeZone.UTC) .getMillis(); return cx.getRexBuilder() .makeDateLiteral(DateTimes.toDateTime( new LocalDateTime(midNightAsMillis, DateTimeZone.UTC)) .toCalendar(null)); // null sets locale to default locale } }