Search in sources :

Example 96 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class TopNQueryRunnerTest method testFullOnTopNNumericStringColumnAsFloat.

@Test
public void testFullOnTopNNumericStringColumnAsFloat() {
    TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).dimension(new DefaultDimensionSpec("qualityNumericString", "qns_alias", ValueType.FLOAT)).metric("maxIndex").threshold(4).intervals(QueryRunnerTestHelper.fullOnInterval).aggregators(Lists.<AggregatorFactory>newArrayList(Iterables.concat(QueryRunnerTestHelper.commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).build();
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<TopNResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TopNResultValue(Arrays.<Map<String, Object>>asList(ImmutableMap.<String, Object>builder().put("qns_alias", 140000.0f).put(QueryRunnerTestHelper.indexMetric, 217725.42022705078D).put("rows", 279L).put("addRowsIndexConstant", 218005.42022705078D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 1870.06103515625D).put("minIndex", 91.27055358886719D).build(), ImmutableMap.<String, Object>builder().put("qns_alias", 160000.0f).put(QueryRunnerTestHelper.indexMetric, 210865.67966461182D).put("rows", 279L).put("addRowsIndexConstant", 211145.67966461182D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 1862.7379150390625D).put("minIndex", 99.2845230102539D).build(), ImmutableMap.<String, Object>builder().put("qns_alias", 100000.0f).put(QueryRunnerTestHelper.indexMetric, 12270.807106018066D).put("rows", 93L).put("addRowsIndexConstant", 12364.807106018066D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 277.2735290527344D).put("minIndex", 71.31593322753906D).build(), ImmutableMap.<String, Object>builder().put("qns_alias", 120000.0f).put(QueryRunnerTestHelper.indexMetric, 12086.472755432129D).put("rows", 93L).put("addRowsIndexConstant", 12180.472755432129D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 193.78756713867188D).put("minIndex", 84.71052551269531D).build()))));
    assertExpectedResults(expectedResults, query);
}
Also used : DoubleMaxAggregatorFactory(io.druid.query.aggregation.DoubleMaxAggregatorFactory) HyperUniqueFinalizingPostAggregator(io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator) PostAggregator(io.druid.query.aggregation.PostAggregator) DoubleMinAggregatorFactory(io.druid.query.aggregation.DoubleMinAggregatorFactory) DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 97 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class TopNQueryRunnerTest method testFullOnTopNStringOutputAsLong.

@Test
public void testFullOnTopNStringOutputAsLong() {
    ExtractionFn strlenFn = StrlenExtractionFn.instance();
    TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).dimension(new ExtractionDimensionSpec(QueryRunnerTestHelper.qualityDimension, "alias", ValueType.LONG, strlenFn)).metric("maxIndex").threshold(4).intervals(QueryRunnerTestHelper.fullOnInterval).aggregators(Lists.<AggregatorFactory>newArrayList(Iterables.concat(QueryRunnerTestHelper.commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).build();
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<TopNResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TopNResultValue(Arrays.<Map<String, Object>>asList(ImmutableMap.<String, Object>builder().put("alias", 9L).put(QueryRunnerTestHelper.indexMetric, 217725.42022705078D).put("rows", 279L).put("addRowsIndexConstant", 218005.42022705078D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 1870.06103515625D).put("minIndex", 91.27055358886719D).build(), ImmutableMap.<String, Object>builder().put("alias", 7L).put(QueryRunnerTestHelper.indexMetric, 210865.67966461182D).put("rows", 279L).put("addRowsIndexConstant", 211145.67966461182D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 1862.7379150390625D).put("minIndex", 99.2845230102539D).build(), ImmutableMap.<String, Object>builder().put("alias", 10L).put(QueryRunnerTestHelper.indexMetric, 20479.497562408447D).put("rows", 186L).put("addRowsIndexConstant", 20666.497562408447D).put("uniques", QueryRunnerTestHelper.UNIQUES_2).put("maxIndex", 277.2735290527344D).put("minIndex", 59.02102279663086D).build(), ImmutableMap.<String, Object>builder().put("alias", 13L).put(QueryRunnerTestHelper.indexMetric, 12086.472755432129D).put("rows", 93L).put("addRowsIndexConstant", 12180.472755432129D).put("uniques", QueryRunnerTestHelper.UNIQUES_1).put("maxIndex", 193.78756713867188D).put("minIndex", 84.71052551269531D).build()))));
    assertExpectedResults(expectedResults, query);
}
Also used : DoubleMaxAggregatorFactory(io.druid.query.aggregation.DoubleMaxAggregatorFactory) HyperUniqueFinalizingPostAggregator(io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator) PostAggregator(io.druid.query.aggregation.PostAggregator) DoubleMinAggregatorFactory(io.druid.query.aggregation.DoubleMinAggregatorFactory) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) LookupExtractionFn(io.druid.query.lookup.LookupExtractionFn) ExtractionFn(io.druid.query.extraction.ExtractionFn) RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) DimExtractionFn(io.druid.query.extraction.DimExtractionFn) StrlenExtractionFn(io.druid.query.extraction.StrlenExtractionFn) JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) TimeFormatExtractionFn(io.druid.query.extraction.TimeFormatExtractionFn) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Example 98 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class TopNQueryRunnerTest method testTopNLexicographicDimExtraction.

@Test
public void testTopNLexicographicDimExtraction() {
    TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).dimension(new ExtractionDimensionSpec(QueryRunnerTestHelper.marketDimension, QueryRunnerTestHelper.marketDimension, new RegexDimExtractionFn("(.)", false, null))).metric(new DimensionTopNMetricSpec(null, StringComparators.LEXICOGRAPHIC)).threshold(4).intervals(QueryRunnerTestHelper.firstToThird).aggregators(QueryRunnerTestHelper.commonAggregators).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).build();
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<TopNResultValue>(new DateTime("2011-04-01T00:00:00.000Z"), new TopNResultValue(Arrays.<Map<String, Object>>asList(ImmutableMap.<String, Object>of(QueryRunnerTestHelper.marketDimension, "s", "rows", 18L, "index", 2231.8768157958984D, "addRowsIndexConstant", 2250.8768157958984D, "uniques", QueryRunnerTestHelper.UNIQUES_9), ImmutableMap.<String, Object>of(QueryRunnerTestHelper.marketDimension, "t", "rows", 4L, "index", 5351.814697265625D, "addRowsIndexConstant", 5356.814697265625D, "uniques", QueryRunnerTestHelper.UNIQUES_2), ImmutableMap.<String, Object>of(QueryRunnerTestHelper.marketDimension, "u", "rows", 4L, "index", 4875.669677734375D, "addRowsIndexConstant", 4880.669677734375D, "uniques", QueryRunnerTestHelper.UNIQUES_2)))));
    assertExpectedResults(expectedResults, query);
}
Also used : HyperUniqueFinalizingPostAggregator(io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator) PostAggregator(io.druid.query.aggregation.PostAggregator) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) RegexDimExtractionFn(io.druid.query.extraction.RegexDimExtractionFn) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Example 99 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class TopNQueryRunnerTest method testFullOnTopNLongTimeColumn.

@Test
public void testFullOnTopNLongTimeColumn() {
    TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).dimension(new DefaultDimensionSpec(Column.TIME_COLUMN_NAME, "time_alias", ValueType.LONG)).metric("maxIndex").threshold(4).intervals(QueryRunnerTestHelper.fullOnInterval).aggregators(Lists.<AggregatorFactory>newArrayList(Iterables.concat(QueryRunnerTestHelper.commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).build();
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<TopNResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TopNResultValue(Arrays.<Map<String, Object>>asList(ImmutableMap.<String, Object>builder().put("time_alias", 1296345600000L).put(QueryRunnerTestHelper.indexMetric, 5497.331253051758D).put("rows", 13L).put("addRowsIndexConstant", 5511.331253051758D).put("uniques", QueryRunnerTestHelper.UNIQUES_9).put("maxIndex", 1870.06103515625D).put("minIndex", 97.02391052246094D).build(), ImmutableMap.<String, Object>builder().put("time_alias", 1298678400000L).put(QueryRunnerTestHelper.indexMetric, 6541.463027954102D).put("rows", 13L).put("addRowsIndexConstant", 6555.463027954102D).put("uniques", QueryRunnerTestHelper.UNIQUES_9).put("maxIndex", 1862.7379150390625D).put("minIndex", 83.099365234375D).build(), ImmutableMap.<String, Object>builder().put("time_alias", 1301529600000L).put(QueryRunnerTestHelper.indexMetric, 6814.467971801758D).put("rows", 13L).put("addRowsIndexConstant", 6828.467971801758D).put("uniques", QueryRunnerTestHelper.UNIQUES_9).put("maxIndex", 1734.27490234375D).put("minIndex", 93.39083862304688D).build(), ImmutableMap.<String, Object>builder().put("time_alias", 1294876800000L).put(QueryRunnerTestHelper.indexMetric, 6077.949111938477D).put("rows", 13L).put("addRowsIndexConstant", 6091.949111938477D).put("uniques", QueryRunnerTestHelper.UNIQUES_9).put("maxIndex", 1689.0128173828125D).put("minIndex", 94.87471008300781D).build()))));
    assertExpectedResults(expectedResults, query);
}
Also used : DoubleMaxAggregatorFactory(io.druid.query.aggregation.DoubleMaxAggregatorFactory) HyperUniqueFinalizingPostAggregator(io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator) PostAggregator(io.druid.query.aggregation.PostAggregator) DoubleMinAggregatorFactory(io.druid.query.aggregation.DoubleMinAggregatorFactory) DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 100 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class TopNQueryRunnerTest method testAlphaNumericTopNWithNullPreviousStop.

@Test
public void testAlphaNumericTopNWithNullPreviousStop() {
    TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(Granularities.ALL).dimension(QueryRunnerTestHelper.marketDimension).metric(new DimensionTopNMetricSpec(null, StringComparators.ALPHANUMERIC)).threshold(2).intervals(QueryRunnerTestHelper.secondOnly).aggregators(duplicateAggregators(QueryRunnerTestHelper.rowsCount, new CountAggregatorFactory("rows1"))).build();
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<>(new DateTime("2011-04-02T00:00:00.000Z"), new TopNResultValue(withDuplicateResults(Arrays.asList(ImmutableMap.<String, Object>of("market", "spot", "rows", 9L), ImmutableMap.<String, Object>of("market", "total_market", "rows", 2L)), "rows", "rows1"))));
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, new HashMap<String, Object>()));
}
Also used : CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Aggregations

DateTime (org.joda.time.DateTime)5683 Test (org.junit.Test)1667 Test (org.testng.annotations.Test)774 ArrayList (java.util.ArrayList)545 Date (java.util.Date)389 LocalDate (org.joda.time.LocalDate)374 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)353 ResponseBody (okhttp3.ResponseBody)335 Interval (org.joda.time.Interval)307 Test (org.junit.jupiter.api.Test)281 HashMap (java.util.HashMap)272 BigDecimal (java.math.BigDecimal)234 DateTimeZone (org.joda.time.DateTimeZone)220 UUID (java.util.UUID)195 List (java.util.List)194 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)178 Map (java.util.Map)171 IOException (java.io.IOException)158 Result (io.druid.query.Result)153 ServiceCall (com.microsoft.rest.ServiceCall)148