return null; if (!getConnectionConfig().approximateTopN() || groupByKeyDims.size() != 1 || limit.limit == null || limit.collations == null || limit.collations.size() != 1) { return null;
@Before public void testSetup() { druidQuery = Mockito.mock(DruidQuery.class); final CalciteConnectionConfig connectionConfigMock = Mockito .mock(CalciteConnectionConfig.class); Mockito.when(connectionConfigMock.timeZone()).thenReturn("UTC"); Mockito.when(druidQuery.getConnectionConfig()).thenReturn(connectionConfigMock); Mockito.when(druidQuery.getDruidTable()) .thenReturn( new DruidTable(Mockito.mock(DruidSchema.class), "dataSource", null, ImmutableSet.of(), "timestamp", null, null, null)); } @Test public void testInFilter() throws IOException {
@Override public String toDruidExpression( RexNode rexNode, RelDataType rowType, DruidQuery query) { final RexCall call = (RexCall) rexNode; final RexLiteral flag = (RexLiteral) call.getOperands().get(0); final TimeUnitRange calciteUnit = (TimeUnitRange) flag.getValue(); final RexNode arg = call.getOperands().get(1); final String input = DruidExpressions.toDruidExpression(arg, rowType, query); if (input == null) { return null; } final String druidUnit = EXTRACT_UNIT_MAP.get(calciteUnit); if (druidUnit == null) { return null; } final TimeZone tz = arg.getType().getSqlTypeName() == SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE ? TimeZone.getTimeZone(query.getConnectionConfig().timeZone()) : DateTimeUtils.UTC_ZONE; return DruidExpressions.applyTimeExtract(input, druidUnit, tz); } }
final String timeZoneConf = druidQuery.getConnectionConfig().timeZone(); final TimeZone timeZone = TimeZone.getTimeZone(timeZoneConf == null ? "UTC" : timeZoneConf); final boolean nullEqualToEmpty = druidQuery.getConnectionConfig().nullEqualToEmpty(); Period.days(1).toString(), "", TimeZone.getTimeZone(druidQuery.getConnectionConfig().timeZone())); } else { return typeCastExpression;
tz = TimeZone.getTimeZone(druidQuery.getConnectionConfig().timeZone()); } else { tz = DateTimeUtils.UTC_ZONE;
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 {
tz = TimeZone.getTimeZone(query.getConnectionConfig().timeZone()); } else { tz = DateTimeUtils.UTC_ZONE;
} else if (SqlTypeFamily.EXACT_NUMERIC.getTypeNames().contains(sqlTypeName) && (type.getScale() == 0 || druidQuery.getConnectionConfig().approximateDecimal())) {
List<Integer> collationIndexes, List<Direction> collationDirections, ImmutableBitSet numericCollationIndexes, Integer fetch, Project postProject) { final CalciteConnectionConfig config = getConnectionConfig(); QueryType queryType = QueryType.SCAN; final Translator translator = new Translator(druidTable, rowType, config.timeZone());
CalciteConnectionConfig config = getConnectionConfig();
final DruidQuery query = triple.getRight(); final CalciteConnectionConfig config = query.getConnectionConfig(); for (AggregateCall aggregateCall : aggregate.getAggCallList()) { switch (aggregateCall.getAggregation().getKind()) {
final SqlTypeName sqlTypeName = type.getSqlTypeName(); final JsonAggregation aggregation; final CalciteConnectionConfig config = druidQuery.getConnectionConfig();
case EXTRACT: granularity = DruidDateTimeUtils .extractGranularity(rexNode, druidQuery.getConnectionConfig().timeZone()); if (granularity == null) { granularity, druidQuery.getConnectionConfig().timeZone()); columnName = extractColumnName(extractValueNode, rowType, druidQuery); } else { case FLOOR: granularity = DruidDateTimeUtils .extractGranularity(rexNode, druidQuery.getConnectionConfig().timeZone()); if (granularity == null) { || toTypeName == SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE) { extractionFunction = TimeExtractionFunction.translateCastToTimeExtract(rexNode, TimeZone.getTimeZone(druidQuery.getConnectionConfig().timeZone())); if (extractionFunction == null) {