private void checkDateRange(Fixture f, RexNode e, Matcher<String> intervalMatcher) { e = DateRangeRules.replaceTimeUnits(f.rexBuilder, e, "UTC"); final RexNode e2 = f.simplify.simplify(e); List<Interval> intervals = DruidDateTimeUtils.createInterval(e2); if (intervals == null) { throw new AssertionError("null interval"); } assertThat(intervals.toString(), intervalMatcher); }
.literalValue(e, TimeZone.getTimeZone(timeZone)); if (timestampString == null) { throw new AssertionError( case EXTRACT: final RexCall call = (RexCall) e; assert DruidDateTimeUtils.extractGranularity(call, timeZone) != null; index = RelOptUtil.InputFinder.bits(e).asList().get(0); break;
/** * Generates a list of {@link Interval}s equivalent to a given * expression. Assumes that all the predicates in the input * reference a single column: the timestamp column. */ public static List<Interval> createInterval(RexNode e, String timeZone) { final List<Range<TimestampString>> ranges = extractRanges(e, TimeZone.getTimeZone(timeZone), false); if (ranges == null) { // We did not succeed, bail out return null; } final TreeRangeSet condensedRanges = TreeRangeSet.create(); for (Range r : ranges) { condensedRanges.add(r); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Inferred ranges on interval : " + condensedRanges); } return toInterval( ImmutableList.<Range>copyOf(condensedRanges.asRanges())); }
case BETWEEN: case IN: return leafToRanges((RexCall) node, timeZone, withNot); return extractRanges(((RexCall) node).getOperands().get(0), timeZone, !withNot); for (RexNode child : call.getOperands()) { List<Range<TimestampString>> extracted = extractRanges(child, timeZone, withNot); if (extracted != null) { intervals.addAll(extracted); for (RexNode child : call.getOperands()) { List<Range<TimestampString>> extractedRanges = extractRanges(child, timeZone, false); if (extractedRanges == null || extractedRanges.isEmpty()) {
EXTRACT_COLUMN_NAME_PREFIX + "_" + Objects .requireNonNull(DruidDateTimeUtils .extractGranularity(project, druidQuery.getConnectionConfig().timeZone()) .getType().lowerName); } else if (project.getKind() == SqlKind.FLOOR) { FLOOR_COLUMN_NAME_PREFIX + "_" + Objects .requireNonNull(DruidDateTimeUtils .extractGranularity(project, druidQuery.getConnectionConfig().timeZone()) .getType().lowerName); } else {
&& literalValue(call.getOperands().get(1)) != null) { value = literalValue(call.getOperands().get(1)); } else if (call.getOperands().get(1) instanceof RexInputRef && literalValue(call.getOperands().get(0)) != null) { value = literalValue(call.getOperands().get(0)); } else { return null; if (literalValue(call.getOperands().get(2)) != null && literalValue(call.getOperands().get(3)) != null) { value1 = literalValue(call.getOperands().get(2)); value2 = literalValue(call.getOperands().get(3)); } else { return null; ImmutableList.builder(); for (RexNode operand : Util.skip(call.operands)) { final Long element = literalValue(operand); if (element == null) { return null;
.extractGranularity(call, tz.getID()); if (granularity == null) { return null; String isoPeriodFormat = DruidDateTimeUtils.toISOPeriodFormat(granularity.getType()); if (isoPeriodFormat == null) { return null;
final Granularity.Type type = DruidDateTimeUtils.toDruidGranularity(timeUnit); if (type == null) { String isoPeriodFormat = DruidDateTimeUtils.toISOPeriodFormat(type); if (isoPeriodFormat == null) { return null;
case BETWEEN: case IN: return leafToRanges((RexCall) node, withNot); return extractRanges(((RexCall) node).getOperands().get(0), !withNot); for (RexNode child : call.getOperands()) { List<Range<Long>> extracted = extractRanges(child, withNot); if (extracted != null) { intervals.addAll(extracted); for (RexNode child : call.getOperands()) { List<Range<Long>> extractedRanges = extractRanges(child, false); if (extractedRanges == null || extractedRanges.isEmpty()) {
DruidDateTimeUtils.extractGranularity(call, config.timeZone()); if (funcGranularity != null) { final String extractColumnName;
&& literalValue(call.getOperands().get(1), timeZone) != null) { value = literalValue(call.getOperands().get(1), timeZone); } else if (call.getOperands().get(1) instanceof RexInputRef && literalValue(call.getOperands().get(0), timeZone) != null) { value = literalValue(call.getOperands().get(0), timeZone); } else { return null; if (literalValue(call.getOperands().get(2), timeZone) != null && literalValue(call.getOperands().get(3), timeZone) != null) { value1 = literalValue(call.getOperands().get(2), timeZone); value2 = literalValue(call.getOperands().get(3), timeZone); } else { return null; ImmutableList.builder(); for (RexNode operand : Util.skip(call.operands)) { final TimestampString element = literalValue(operand, timeZone); if (element == null) { return null;
private void checkDateRangeNoSimplify(Fixture f, RexNode e, Matcher<String> intervalMatcher) { e = DateRangeRules.replaceTimeUnits(f.rexBuilder, e, "UTC"); final List<Interval> intervals = DruidDateTimeUtils.createInterval(e); assertThat(intervals, notNullValue()); assertThat(intervals.toString(), intervalMatcher); }
/** * Generates a list of {@link Interval}s equivalent to a given * expression. Assumes that all the predicates in the input * reference a single column: the timestamp column. */ @Nullable public static List<Interval> createInterval(RexNode e) { final List<Range<Long>> ranges = extractRanges(e, false); if (ranges == null) { // We did not succeed, bail out return null; } final TreeRangeSet condensedRanges = TreeRangeSet.create(); for (Range r : ranges) { condensedRanges.add(r); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Inferred ranges on interval : " + condensedRanges); } return toInterval( ImmutableList.<Range>copyOf(condensedRanges.asRanges())); }
.unwrap(CalciteConnectionConfig.class).timeZone(); assert timeZone != null; assert DruidDateTimeUtils.extractGranularity(call, timeZone) != null; if (call.getKind() == SqlKind.FLOOR) { newSet.addAll(RelOptUtil.InputFinder.bits(call));
|| SqlTypeName.TIMESTAMP == rhsLiteral.getTypeName() || SqlTypeName.DATE == rhsLiteral.getTypeName()) { Long millisSinceEpoch = DruidDateTimeUtils.literalValue(rexNode); if (millisSinceEpoch == null) { throw new AssertionError(
.unwrap(CalciteConnectionConfig.class).timeZone(); assert timeZone != null; intervals = DruidDateTimeUtils.createInterval( RexUtil.composeConjunction(rexBuilder, triple.getLeft(), false), timeZone);
.unwrap(CalciteConnectionConfig.class).timeZone(); assert timeZone != null; if (DruidDateTimeUtils.extractGranularity(call, timeZone) == null) { return -1;
|| SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE == sqlTypeName) { return DruidExpressions.numberLiteral( DruidDateTimeUtils.literalValue(rexNode)); } else if (SqlTypeName.BOOLEAN == sqlTypeName) { return DruidExpressions.numberLiteral(RexLiteral.booleanValue(rexNode) ? 1 : 0);
.unwrap(CalciteConnectionConfig.class).timeZone(); assert timeZone != null; intervals = DruidDateTimeUtils.createInterval( RexUtil.composeConjunction(rexBuilder, triple.getLeft())); if (intervals == null || intervals.isEmpty()) {
.unwrap(CalciteConnectionConfig.class).timeZone(); assert timeZone != null; assert DruidDateTimeUtils.extractGranularity(call, timeZone) != null;