Class MongoAdapterTest
- java.lang.Object
-
- org.apache.calcite.adapter.mongodb.MongoAdapterTest
-
- All Implemented Interfaces:
org.apache.calcite.schema.SchemaFactory
- Direct Known Subclasses:
MongoAdapterIT
public class MongoAdapterTest extends java.lang.Object implements org.apache.calcite.schema.SchemaFactory
Testing mongo adapter functionality. By default runs with Fongo unlessIT
maven profile is enabled (via$ mvn -Pit install
).- See Also:
MongoDatabasePolicy
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.net.URL
MODEL
Connection factory based on the "mongo-zips" model.static MongoDatabasePolicy
POLICY
private static org.apache.calcite.adapter.mongodb.MongoSchema
schema
protected static int
ZIPS_SIZE
Number of records in local file
-
Constructor Summary
Constructors Constructor Description MongoAdapterTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private CalciteAssert.AssertThat
assertModel(java.lang.String model)
private CalciteAssert.AssertThat
assertModel(java.net.URL url)
private void
checkPredicate(int expected, java.lang.String q)
org.apache.calcite.schema.Schema
create(org.apache.calcite.schema.SchemaPlus parentSchema, java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> operand)
Returns always the same schema to avoid initialization costs.private static java.util.function.Consumer<java.util.List>
mongoChecker(java.lang.String... strings)
Returns a function that checks that a particular MongoDB pipeline is generated to implement a query.private static void
populate(com.mongodb.client.MongoCollection<org.bson.Document> collection, java.net.URL resource)
static void
setUp()
void
testCountGroupByEmpty()
void
testCountGroupByEmptyMultiplyBy2()
void
testCountViaInt()
Test case for [CALCITE-665] ClassCastException in MongoDB adapter.void
testDate()
Test case for [CALCITE-286] Error casting MongoDB date.void
testDistinctCount()
void
testDistinctCountOrderBy()
void
testFilter()
void
testFilterPair()
MongoDB's predicates are handed (they can only accept literals on the right-hand size) so it's worth testing that we handle them right both ways around.void
testFilterRedundant()
Tests that we don't generate multiple constraints on the same column.void
testFilterReversed()
MongoDB's predicates are handed (they can only accept literals on the right-hand size) so it's worth testing that we handle them right both ways around.void
testFilterSort()
void
testFilterSortDesc()
void
testFilterUnionPlan()
void
testGroupByAvg()
void
testGroupByAvgSumCount()
void
testGroupByHaving()
void
testGroupByHaving2()
void
testGroupByMinMaxSum()
void
testGroupByOneColumn()
void
testGroupByOneColumnNotProjected()
void
testGroupByOneColumnReversed()
void
testGroupComposite()
void
testInPlan()
void
testLimit()
void
testOffsetLimit()
void
testProject()
void
testSelectWhere()
void
testSort()
void
testSortLimit()
void
testUnionPlan()
void
testZips()
Simple query based on the "mongo-zips" model.
-
-
-
Field Detail
-
MODEL
protected static final java.net.URL MODEL
Connection factory based on the "mongo-zips" model.
-
ZIPS_SIZE
protected static final int ZIPS_SIZE
Number of records in local file- See Also:
- Constant Field Values
-
POLICY
public static final MongoDatabasePolicy POLICY
-
schema
private static org.apache.calcite.adapter.mongodb.MongoSchema schema
-
-
Method Detail
-
setUp
public static void setUp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
populate
private static void populate(com.mongodb.client.MongoCollection<org.bson.Document> collection, java.net.URL resource) throws java.io.IOException
- Throws:
java.io.IOException
-
create
public org.apache.calcite.schema.Schema create(org.apache.calcite.schema.SchemaPlus parentSchema, java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> operand)
Returns always the same schema to avoid initialization costs.- Specified by:
create
in interfaceorg.apache.calcite.schema.SchemaFactory
-
assertModel
private CalciteAssert.AssertThat assertModel(java.lang.String model)
-
assertModel
private CalciteAssert.AssertThat assertModel(java.net.URL url)
-
testSort
public void testSort()
-
testSortLimit
public void testSortLimit()
-
testOffsetLimit
public void testOffsetLimit()
-
testLimit
public void testLimit()
-
testFilterSort
public void testFilterSort()
-
testFilterSortDesc
public void testFilterSortDesc()
-
testUnionPlan
public void testUnionPlan()
-
testFilterUnionPlan
public void testFilterUnionPlan()
-
testFilterRedundant
public void testFilterRedundant()
Tests that we don't generate multiple constraints on the same column. MongoDB doesn't like it. If there is an '=', it supersedes all other operators.
-
testSelectWhere
public void testSelectWhere()
-
testInPlan
public void testInPlan()
-
testZips
public void testZips()
Simple query based on the "mongo-zips" model.
-
testCountGroupByEmpty
public void testCountGroupByEmpty()
-
testCountGroupByEmptyMultiplyBy2
public void testCountGroupByEmptyMultiplyBy2()
-
testGroupByOneColumnNotProjected
public void testGroupByOneColumnNotProjected()
-
testGroupByOneColumn
public void testGroupByOneColumn()
-
testGroupByOneColumnReversed
public void testGroupByOneColumnReversed()
-
testGroupByAvg
public void testGroupByAvg()
-
testGroupByAvgSumCount
public void testGroupByAvgSumCount()
-
testGroupByHaving
public void testGroupByHaving()
-
testGroupByHaving2
public void testGroupByHaving2()
-
testGroupByMinMaxSum
public void testGroupByMinMaxSum()
-
testGroupComposite
public void testGroupComposite()
-
testDistinctCount
public void testDistinctCount()
-
testDistinctCountOrderBy
public void testDistinctCountOrderBy()
-
testProject
public void testProject()
-
testFilter
public void testFilter()
-
testFilterReversed
public void testFilterReversed()
MongoDB's predicates are handed (they can only accept literals on the right-hand size) so it's worth testing that we handle them right both ways around.
-
testFilterPair
public void testFilterPair()
MongoDB's predicates are handed (they can only accept literals on the right-hand size) so it's worth testing that we handle them right both ways around.Test case for [CALCITE-740] Redundant WHERE clause causes wrong result in MongoDB adapter.
-
checkPredicate
private void checkPredicate(int expected, java.lang.String q)
-
testDate
public void testDate()
Test case for [CALCITE-286] Error casting MongoDB date.
-
testCountViaInt
public void testCountViaInt()
Test case for [CALCITE-665] ClassCastException in MongoDB adapter.
-
mongoChecker
private static java.util.function.Consumer<java.util.List> mongoChecker(java.lang.String... strings)
Returns a function that checks that a particular MongoDB pipeline is generated to implement a query.- Parameters:
strings
- Expected expressions- Returns:
- validation function
-
-