Class DruidAdapterIT2


  • public class DruidAdapterIT2
    extends java.lang.Object
    Tests for the org.apache.calcite.adapter.druid package.

    Before calling this test, you need to populate Druid, as follows:

    git clone https://github.com/vlsi/calcite-test-dataset
    cd calcite-test-dataset
    mvn install

    This will create a virtual machine with Druid and test data set.

    Features not yet implemented:

    • push LIMIT into "select" query
    • push SORT and/or LIMIT into "groupBy" query
    • push HAVING into "groupBy" query

    These tests use TIMESTAMP type for the Druid timestamp column, instead of TIMESTAMP WITH LOCAL TIME ZONE type as DruidAdapterIT.

    • Field Detail

      • FOODMART

        public static final java.net.URL FOODMART
        URL of the "druid-foodmart" model.
      • ENABLED

        public static final boolean ENABLED
        Whether to run Druid tests. Enabled by default, however test is only included if "it" profile is activated (-Pit). To disable, specify -Dcalcite.test.druid=false on the Java command line.
    • Constructor Detail

      • DruidAdapterIT2

        public DruidAdapterIT2()
    • Method Detail

      • enabled

        protected boolean enabled()
        Whether to run this test.
      • druidChecker

        private static java.util.function.Consumer<java.util.List> druidChecker​(java.lang.String... lines)
        Returns a function that checks that a particular Druid query is generated to implement a query.
      • foodmartApprox

        private CalciteAssert.AssertQuery foodmartApprox​(java.lang.String sql)
        Creates a query against FOODMART with approximate parameters
      • sql

        private CalciteAssert.AssertQuery sql​(java.lang.String sql,
                                              java.net.URL url)
        Creates a query against a data set given by a map.
      • testMetadataColumns

        public void testMetadataColumns()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • testSelectDistinct

        public void testSelectDistinct()
      • testSelectGroupBySum

        public void testSelectGroupBySum()
      • testGroupbyMetric

        public void testGroupbyMetric()
      • testPushSimpleGroupBy

        public void testPushSimpleGroupBy()
      • testComplexPushGroupBy

        public void testComplexPushGroupBy()
      • testSort

        public void testSort()
      • testSortLimit

        public void testSortLimit()
      • testOffsetLimit

        public void testOffsetLimit()
      • testLimit

        public void testLimit()
      • testDistinctLimit

        public void testDistinctLimit()
      • testGroupBySingleSortLimitApprox

        public void testGroupBySingleSortLimitApprox()
        As testGroupBySingleSortLimit(), but allowing approximate results due to CalciteConnectionConfig.approximateDistinctCount(). Therefore we send a "topN" query to Druid.
      • checkGroupBySingleSortLimit

        private void checkGroupBySingleSortLimit​(boolean approx)
      • testFilterSortDesc

        public void testFilterSortDesc()
        Tests a query that contains no GROUP BY and is therefore executed as a Druid "select" query.
      • testFilterSortDescNumeric

        public void testFilterSortDescNumeric()
        As testFilterSortDesc() but the bounds are numeric.
      • testFilterOutEverything

        public void testFilterOutEverything()
        Tests a query whose filter removes all rows.
      • testNonPushableFilterSortDesc

        public void testNonPushableFilterSortDesc()
        As testFilterSortDescNumeric() but with a filter that cannot be pushed down to Druid.
      • testUnionPlan

        public void testUnionPlan()
      • testFilterUnionPlan

        public void testFilterUnionPlan()
      • testCountGroupByEmpty

        public void testCountGroupByEmpty()
      • testGroupByOneColumnNotProjected

        public void testGroupByOneColumnNotProjected()
      • testGroupByTimeAndOneColumnNotProjectedWithLimit

        public void testGroupByTimeAndOneColumnNotProjectedWithLimit()
        Unlike testGroupByTimeAndOneColumnNotProjected(), we cannot use "topN" because we have a global limit, and that requires granularity: all.
      • testGroupByTimeAndOneMetricNotProjected

        public void testGroupByTimeAndOneMetricNotProjected()
      • testGroupByTimeAndOneColumnNotProjected

        public void testGroupByTimeAndOneColumnNotProjected()
      • testOrderByOneColumnNotProjected

        public void testOrderByOneColumnNotProjected()
      • testGroupByOneColumn

        public void testGroupByOneColumn()
      • testGroupByOneColumnReversed

        public void testGroupByOneColumnReversed()
      • testGroupByAvgSumCount

        public void testGroupByAvgSumCount()
      • testGroupByMonthGranularity

        public void testGroupByMonthGranularity()
      • testGroupByMonthGranularitySortLimit

        public void testGroupByMonthGranularitySortLimit()
      • testGroupByDayGranularity

        public void testGroupByDayGranularity()
      • testGroupByMonthGranularityFiltered

        public void testGroupByMonthGranularityFiltered()
      • testTopNMonthGranularity

        public void testTopNMonthGranularity()
      • testTopNDayGranularityFiltered

        public void testTopNDayGranularityFiltered()
      • testGroupByHaving

        public void testGroupByHaving()
      • testGroupComposite

        public void testGroupComposite()
      • testDistinctCount

        public void testDistinctCount()
        Tests that distinct-count is pushed down to Druid and evaluated using "cardinality". The result is approximate, but gives the correct result in this example when rounded down using FLOOR.
      • testProject

        public void testProject()
        Tests that projections of columns are pushed into the DruidQuery, and projections of expressions that Druid cannot handle (in this case, a literal 0) stay up.
      • testFilterDistinct

        public void testFilterDistinct()
      • testFilter

        public void testFilter()
      • testFilterSwapped

        public void testFilterSwapped()
      • testGroupByMetricAndExtractTime

        public void testGroupByMetricAndExtractTime()
      • testFilterOnDouble

        public void testFilterOnDouble()
      • testPushAggregateOnTime

        public void testPushAggregateOnTime()
      • testPushAggregateOnTimeWithExtractYear

        public void testPushAggregateOnTimeWithExtractYear()
      • testPushAggregateOnTimeWithExtractMonth

        public void testPushAggregateOnTimeWithExtractMonth()
      • testPushAggregateOnTimeWithExtractDay

        public void testPushAggregateOnTimeWithExtractDay()
      • testPushAggregateOnTimeWithExtractHourOfDay

        public void testPushAggregateOnTimeWithExtractHourOfDay()
      • testPushAggregateOnTimeWithExtractYearMonthDay

        public void testPushAggregateOnTimeWithExtractYearMonthDay()
      • testPushAggregateOnTimeWithExtractYearMonthDayWithOutRenaming

        public void testPushAggregateOnTimeWithExtractYearMonthDayWithOutRenaming()
      • testPushAggregateOnTimeWithExtractWithOutRenaming

        public void testPushAggregateOnTimeWithExtractWithOutRenaming()
      • testPushComplexFilter

        public void testPushComplexFilter()
      • testPushOfFilterExtractionOnDayAndMonth

        public void testPushOfFilterExtractionOnDayAndMonth()
      • testPushOfFilterExtractionOnDayAndMonthAndYear

        public void testPushOfFilterExtractionOnDayAndMonthAndYear()
      • testFilterExtractionOnMonthWithBetween

        public void testFilterExtractionOnMonthWithBetween()
      • testFilterExtractionOnMonthWithIn

        public void testFilterExtractionOnMonthWithIn()
      • testPushOfOrderByWithMonthExtract

        public void testPushOfOrderByWithMonthExtract()
      • testGroupByFloorTimeWithoutLimit

        public void testGroupByFloorTimeWithoutLimit()
      • testGroupByFloorTimeWithLimit

        public void testGroupByFloorTimeWithLimit()
      • testPushofOrderByYearWithYearMonthExtract

        public void testPushofOrderByYearWithYearMonthExtract()
      • testPushofOrderByMetricWithYearMonthExtract

        public void testPushofOrderByMetricWithYearMonthExtract()
      • testGroupByTimeSortOverMetrics

        public void testGroupByTimeSortOverMetrics()
      • testNumericOrderingOfOrderByOperatorFullTime

        public void testNumericOrderingOfOrderByOperatorFullTime()
      • testNumericOrderingOfOrderByOperatorTimeExtract

        public void testNumericOrderingOfOrderByOperatorTimeExtract()
      • testNumericOrderingOfOrderByOperatorStringDims

        public void testNumericOrderingOfOrderByOperatorStringDims()
      • testGroupByWeekExtract

        public void testGroupByWeekExtract()
      • testFalseFilter

        public void testFalseFilter()
      • testTrueFilter

        public void testTrueFilter()
      • testFalseFilterCaseConjectionWithTrue

        public void testFalseFilterCaseConjectionWithTrue()
      • testPushFieldEqualsLiteral

        public void testPushFieldEqualsLiteral()
      • testPlusArithmeticOperation

        public void testPlusArithmeticOperation()
      • testDivideArithmeticOperation

        public void testDivideArithmeticOperation()
      • testMultiplyArithmeticOperation

        public void testMultiplyArithmeticOperation()
      • testMinusArithmeticOperation

        public void testMinusArithmeticOperation()
      • testConstantPostAggregator

        public void testConstantPostAggregator()
      • testRecursiveArithmeticOperation

        public void testRecursiveArithmeticOperation()
      • testHyperUniquePostAggregator

        public void testHyperUniquePostAggregator()
        Turn on now count(distinct )
      • testExtractFilterWorkWithPostAggregations

        public void testExtractFilterWorkWithPostAggregations()
      • testExtractFilterWorkWithPostAggregationsWithConstant

        public void testExtractFilterWorkWithPostAggregationsWithConstant()
      • testSingleAverageFunction

        public void testSingleAverageFunction()
      • testPartiallyPostAggregation

        public void testPartiallyPostAggregation()
      • testDuplicateReferenceOnPostAggregation

        public void testDuplicateReferenceOnPostAggregation()
      • testDivideByZeroDoubleTypeInfinity

        public void testDivideByZeroDoubleTypeInfinity()
      • testDivideByZeroDoubleTypeNegInfinity

        public void testDivideByZeroDoubleTypeNegInfinity()
      • testDivideByZeroDoubleTypeNaN

        public void testDivideByZeroDoubleTypeNaN()
      • testDivideByZeroIntegerType

        public void testDivideByZeroIntegerType()
      • testInterleaveBetweenAggregateAndGroupOrderByOnMetrics

        public void testInterleaveBetweenAggregateAndGroupOrderByOnMetrics()
      • testInterleaveBetweenAggregateAndGroupOrderByOnDimension

        public void testInterleaveBetweenAggregateAndGroupOrderByOnDimension()
      • testOrderByOnMetricsInSelectDruidQuery

        public void testOrderByOnMetricsInSelectDruidQuery()
      • testFilterClauseFactoredOut

        public void testFilterClauseFactoredOut()
        Tests whether an aggregate with a filter clause has it's filter factored out when there is no outer filter
      • testFilterClauseAlwaysTrueGone

        public void testFilterClauseAlwaysTrueGone()
        Tests whether filter clauses with filters that are always true disappear or not
      • testFilterClauseAlwaysTrueWithAggGone1

        public void testFilterClauseAlwaysTrueWithAggGone1()
        Tests whether filter clauses with filters that are always true disappear in the presence of another aggregate without a filter clause
      • testFilterClauseAlwaysTrueWithAggGone2

        public void testFilterClauseAlwaysTrueWithAggGone2()
        Tests whether filter clauses with filters that are always true disappear in the presence of another aggregate with a filter clause
      • testOuterFilterRemainsWithAlwaysTrueClause

        public void testOuterFilterRemainsWithAlwaysTrueClause()
        Tests whether an existing outer filter is untouched when an aggregate has a filter clause that is always true
      • testFilterClauseAlwaysFalseNotPushed

        public void testFilterClauseAlwaysFalseNotPushed()
        Tests that an aggregate with a filter clause that is always false does not get pushed in
      • testFilterClauseAlwaysFalseNotPushedWithFilter

        public void testFilterClauseAlwaysFalseNotPushedWithFilter()
        Tests that an aggregate with a filter clause that is always false does not get pushed when there is already an outer filter
      • testFilterClauseSameAsOuterFilterGone

        public void testFilterClauseSameAsOuterFilterGone()
        Tests that an aggregate with a filter clause that is the same as the outer filter has no references to that filter, and that the original outer filter remains
      • testFilterClauseNotFactoredOut1

        public void testFilterClauseNotFactoredOut1()
        Test to ensure that an aggregate with a filter clause in the presence of another aggregate without a filter clause does not have it's filter factored out into the outer filter
      • testFilterClauseNotFactoredOut2

        public void testFilterClauseNotFactoredOut2()
        Test to ensure that an aggregate with a filter clause in the presence of another aggregate without a filter clause, and an outer filter does not have it's filter factored out into the outer filter
      • testFilterClausesFactoredForPruning1

        public void testFilterClausesFactoredForPruning1()
        Test to ensure that multiple aggregates with filter clauses have their filters extracted to the outer filter field for data pruning
      • testFilterClausesFactoredForPruning2

        public void testFilterClausesFactoredForPruning2()
        Test to ensure that multiple aggregates with filter clauses have their filters extracted to the outer filter field for data pruning in the presence of an outer filter
      • testMultipleFiltersFactoredOutWithOuterFilter

        public void testMultipleFiltersFactoredOutWithOuterFilter()
        Test to ensure that multiple aggregates with the same filter clause have them factored out in the presence of an outer filter, and that they no longer refer to those filters
      • testOuterFilterFalseAfterFactorSimplification

        public void testOuterFilterFalseAfterFactorSimplification()
        Tests that when the resulting filter from factoring filter clauses out is always false, that they are still pushed to Druid to handle.
      • testFilterClauseNotPushable

        public void testFilterClauseNotPushable()
        Test to ensure that aggregates with filter clauses that Druid cannot handle are not pushed in as filtered aggregates.
      • testFilterClauseWithMetricRef

        public void testFilterClauseWithMetricRef()
      • testFilterClauseWithMetricRefAndAggregates

        public void testFilterClauseWithMetricRefAndAggregates()
      • testFilterClauseWithMetricAndTimeAndAggregates

        public void testFilterClauseWithMetricAndTimeAndAggregates()
      • testNestedFilterClauseFactored

        public void testNestedFilterClauseFactored()
        Test to ensure that an aggregate with a nested filter clause has it's filter factored out
      • testNestedFilterClauseInAggregates

        public void testNestedFilterClauseInAggregates()
        Test to ensure that aggregates with nested filters have their filters factored out into the outer filter for data pruning while still holding a reference to the filter clause
      • testCountWithNonNull

        public void testCountWithNonNull()
      • testNotFilterForm

        public void testNotFilterForm()
        Test to make sure the "not" filter has only 1 field, rather than an array of fields.
      • testDistinctCountWhenApproxResultsAccepted

        public void testDistinctCountWhenApproxResultsAccepted()
        Test to ensure that count(distinct ...) gets pushed to Druid when approximate results are acceptable
      • testDistinctCountWhenApproxResultsNotAccepted

        public void testDistinctCountWhenApproxResultsNotAccepted()
        Test to ensure that count(distinct ...) doesn't get pushed to Druid when approximate results are not acceptable
      • testDistinctCountOnMetric

        public void testDistinctCountOnMetric()
      • testCountOnMetric

        public void testCountOnMetric()
        Test to ensure that a count on a metric does not get pushed into Druid
      • testCountStar

        public void testCountStar()
        Test to ensure that count(*) is pushed into Druid
      • testCountOnMetricRenamed

        public void testCountOnMetricRenamed()
      • testDistinctCountOnMetricRenamed

        public void testDistinctCountOnMetricRenamed()
      • testCountWithApproxDistinct

        private void testCountWithApproxDistinct​(boolean approx,
                                                 java.lang.String sql,
                                                 java.lang.String expectedExplain)
      • testCountWithApproxDistinct

        private void testCountWithApproxDistinct​(boolean approx,
                                                 java.lang.String sql,
                                                 java.lang.String expectedExplain,
                                                 java.lang.String expectedDruidQuery)
      • testComplexMetricAlsoDimension

        public void testComplexMetricAlsoDimension()
        Test to make sure that if a complex metric is also a dimension, then DruidTable should allow it to be used like any other column.
      • testTableMapReused

        public void testTableMapReused()
        Test to make sure that the mapping from a Table name to a Table returned from DruidSchema is always the same Java object.
      • testPushEqualsCastDimension

        public void testPushEqualsCastDimension()
      • testPushNotEqualsCastDimension

        public void testPushNotEqualsCastDimension()
      • testIsNull

        public void testIsNull()
      • testIsNotNull

        public void testIsNotNull()
      • testFilterWithFloorOnTime

        public void testFilterWithFloorOnTime()
      • testSelectFloorOnTimeWithFilterOnFloorOnTime

        public void testSelectFloorOnTimeWithFilterOnFloorOnTime()
      • testTimeWithFilterOnFloorOnTimeAndCastToTimestamp

        public void testTimeWithFilterOnFloorOnTimeAndCastToTimestamp()
      • testFloorToDateRangeWithTimeZone

        public void testFloorToDateRangeWithTimeZone()
      • testExpressionsFilter

        public void testExpressionsFilter()
      • testExpressionsFilter2

        public void testExpressionsFilter2()
      • testExpressionsLikeFilter

        public void testExpressionsLikeFilter()
      • testExpressionsSTRLENFilter

        public void testExpressionsSTRLENFilter()
      • testExpressionsUpperLowerFilter

        public void testExpressionsUpperLowerFilter()
      • testExpressionsLowerUpperFilter

        public void testExpressionsLowerUpperFilter()
      • testExpressionsLowerFilterNotMatching

        public void testExpressionsLowerFilterNotMatching()
      • testExpressionsLowerFilterMatching

        public void testExpressionsLowerFilterMatching()
      • testExpressionsUpperFilterNotMatching

        public void testExpressionsUpperFilterNotMatching()
      • testExpressionsUpperFilterMatching

        public void testExpressionsUpperFilterMatching()
      • testExpressionsConcatFilter

        public void testExpressionsConcatFilter()
      • testExpressionsNotNull

        public void testExpressionsNotNull()
      • testComplexExpressionsIsNull

        public void testComplexExpressionsIsNull()
      • testExpressionsConcatFilterMultipleColumns

        public void testExpressionsConcatFilterMultipleColumns()
      • testAndCombinationOfExpAndSimpleFilter

        public void testAndCombinationOfExpAndSimpleFilter()
      • testOrCombinationOfExpAndSimpleFilter

        public void testOrCombinationOfExpAndSimpleFilter()
      • testColumnAEqColumnB

        public void testColumnAEqColumnB()
      • testColumnANotEqColumnB

        public void testColumnANotEqColumnB()
      • testAndCombinationOfComplexExpAndSimpleFilter

        public void testAndCombinationOfComplexExpAndSimpleFilter()
      • testExpressionsFilterWithCast

        public void testExpressionsFilterWithCast()
      • testExpressionsFilterWithCastTimeToDateToChar

        public void testExpressionsFilterWithCastTimeToDateToChar()
      • testExpressionsFilterWithExtract

        public void testExpressionsFilterWithExtract()
      • testExtractYearFilterExpression

        public void testExtractYearFilterExpression()
      • testExtractMonthFilterExpression

        public void testExtractMonthFilterExpression()
      • testTimeFloorExpressions

        public void testTimeFloorExpressions()
      • testDruidTimeFloorAndTimeParseExpressions

        public void testDruidTimeFloorAndTimeParseExpressions()
      • testDruidTimeFloorAndTimeParseExpressions2

        public void testDruidTimeFloorAndTimeParseExpressions2()
      • testFilterFloorOnMetricColumn

        public void testFilterFloorOnMetricColumn()
      • testExpressionFilterSimpleColumnAEqColumnB

        public void testExpressionFilterSimpleColumnAEqColumnB()
      • testCastPlusMathOps

        public void testCastPlusMathOps()
      • testBooleanFilterExpressions

        public void testBooleanFilterExpressions()
      • testCombinationOfValidAndNotValidFilters

        public void testCombinationOfValidAndNotValidFilters()
      • testCeilFilterExpression

        public void testCeilFilterExpression()
      • testSubStringExpressionFilter

        public void testSubStringExpressionFilter()
      • testSubStringWithNonConstantIndexes

        public void testSubStringWithNonConstantIndexes()
      • testSubStringWithNonConstantIndex

        public void testSubStringWithNonConstantIndex()
      • testFilterClauseWithNoConjunction

        public void testFilterClauseWithNoConjunction()
        Test case for https://issues.apache.org/jira/browse/CALCITE-2098. Need to make sure that when there we have a valid filter with no conjunction we still push all the valid filters.
      • testBetweenFilterWithCastOverNumeric

        public void testBetweenFilterWithCastOverNumeric()
        Test case for https://issues.apache.org/jira/browse/CALCITE-2123
      • testTrigonometryMathFunctions

        public void testTrigonometryMathFunctions()
      • testCastLiteralToTimestamp

        public void testCastLiteralToTimestamp()
      • testNotTrueSimpleFilter

        public void testNotTrueSimpleFilter()
      • testPushOfSimpleMathOps

        public void testPushOfSimpleMathOps()
      • testPushOfSimpleColumnAPlusColumnB

        public void testPushOfSimpleColumnAPlusColumnB()
      • testSelectExtractMonth

        public void testSelectExtractMonth()
      • testAggOnArithmeticProject

        public void testAggOnArithmeticProject()
      • testAggOnArithmeticProject2

        public void testAggOnArithmeticProject2()
      • testAggOnArithmeticProject3

        public void testAggOnArithmeticProject3()
      • testGroupByVirtualColumn

        public void testGroupByVirtualColumn()
      • testCountOverVirtualColumn

        public void testCountOverVirtualColumn()
      • testAggOverStringToLong

        public void testAggOverStringToLong()
      • testAggOnTimeExtractColumn2

        public void testAggOnTimeExtractColumn2()
      • testStackedAggregateFilters

        public void testStackedAggregateFilters()
      • testCastOverPostAggregates

        public void testCastOverPostAggregates()
      • testSubStringOverPostAggregates

        public void testSubStringOverPostAggregates()
      • testTableQueryExtractYearQuarter

        public void testTableQueryExtractYearQuarter()
      • testTableauQueryExtractMonthDayYear

        public void testTableauQueryExtractMonthDayYear()
      • testTableauQuerySubStringHourMinutes

        public void testTableauQuerySubStringHourMinutes()
      • testTableauQueryMinutesSecondsExtract

        public void testTableauQueryMinutesSecondsExtract()
      • testCastConcatOverPostAggregates

        public void testCastConcatOverPostAggregates()
      • testHavingSpecs

        public void testHavingSpecs()
      • testTransposableHavingFilter

        public void testTransposableHavingFilter()
      • testProjectSameColumnMultipleTimes

        public void testProjectSameColumnMultipleTimes()
      • testProjectSameMetricsColumnMultipleTimes

        public void testProjectSameMetricsColumnMultipleTimes()
      • testAggSameColumnMultipleTimes

        public void testAggSameColumnMultipleTimes()
      • testGroupBy1

        public void testGroupBy1()
      • testFloorQuarter

        public void testFloorQuarter()
      • testFloorQuarterPlusDim

        public void testFloorQuarterPlusDim()
      • testExtractQuarterPlusDim

        public void testExtractQuarterPlusDim()
      • testExtractQuarter

        public void testExtractQuarter()
      • testCastTimestamp

        public void testCastTimestamp()