Skip to content

Commit 0defc1f

Browse files
committed
[CALCITE-2115] Populate sales_fact_1997, sales_fact_1998 for MongoAdapterTest
1 parent 618e601 commit 0defc1f

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public static void setUp() throws Exception {
104104
populate(database.getCollection("warehouse"),
105105
requireNonNull(FoodmartJson.class.getResource("/warehouse.json"),
106106
"url"));
107+
populate(database.getCollection("sales_fact_1997"),
108+
requireNonNull(FoodmartJson.class.getResource("/sales_fact_1997.json"),
109+
"url"));
110+
populate(database.getCollection("sales_fact_1998"),
111+
requireNonNull(FoodmartJson.class.getResource("/sales_fact_1998.json"),
112+
"url"));
107113

108114
// Manually insert data for data-time test.
109115
MongoCollection<BsonDocument> datatypes = database.getCollection("datatypes")
@@ -284,7 +290,6 @@ private CalciteAssert.AssertThat assertModel(URL url) {
284290
"CITY=LAWTON; LONGITUDE=null; LATITUDE=null; POP=45542; STATE=OK; ID=73505");
285291
}
286292

287-
@Disabled("broken; [CALCITE-2115] is logged to fix it")
288293
@Test void testUnionPlan() {
289294
assertModel(MODEL)
290295
.query("select * from \"sales_fact_1997\"\n"
@@ -303,8 +308,6 @@ private CalciteAssert.AssertThat assertModel(URL url) {
303308
"product_id=337", "product_id=1512"));
304309
}
305310

306-
@Disabled(
307-
"java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double")
308311
@Test void testFilterUnionPlan() {
309312
assertModel(MODEL)
310313
.query("select * from (\n"
@@ -584,13 +587,19 @@ private CalciteAssert.AssertThat assertModel(URL url) {
584587
"{$project: {C: 1, STATE: 1, CITY: 1}}"));
585588
}
586589

587-
@Disabled("broken; [CALCITE-2115] is logged to fix it")
588590
@Test void testDistinctCount() {
589591
assertModel(MODEL)
590592
.query("select state, count(distinct city) as cdc from zips\n"
591593
+ "where state in ('CA', 'TX') group by state order by state")
592-
.returns("STATE=CA; CDC=1072\n"
593-
+ "STATE=TX; CDC=1233\n")
594+
.returns("STATE=CA; CDC=3\n"
595+
+ "STATE=TX; CDC=3\n")
596+
.explainContains("PLAN=EnumerableSort(sort0=[$0], dir0=[ASC])\n"
597+
+ " EnumerableAggregate(group=[{0}], CDC=[COUNT($1)])\n"
598+
+ " EnumerableAggregate(group=[{0, 1}])\n"
599+
+ " MongoToEnumerableConverter\n"
600+
+ " MongoProject(STATE=[CAST(ITEM($0, 'state')):VARCHAR(2)], CITY=[CAST(ITEM($0, 'city')):VARCHAR(20)])\n"
601+
+ " MongoFilter(condition=[SEARCH(CAST(CAST(ITEM($0, 'state')):VARCHAR(2)):CHAR(2), Sarg['CA', 'TX']:CHAR(2))])\n"
602+
+ " MongoTableScan(table=[[mongo_raw, zips]])\n\n")
594603
.queryContains(
595604
mongoChecker(
596605
"{\n"
@@ -605,12 +614,7 @@ private CalciteAssert.AssertThat assertModel(URL url) {
605614
+ " ]\n"
606615
+ " }\n"
607616
+ "}",
608-
"{$project: {CITY: '$city', STATE: '$state'}}",
609-
"{$group: {_id: {CITY: '$CITY', STATE: '$STATE'}}}",
610-
"{$project: {_id: 0, CITY: '$_id.CITY', STATE: '$_id.STATE'}}",
611-
"{$group: {_id: '$STATE', CDC: {$sum: {$cond: [ {$eq: ['CITY', null]}, 0, 1]}}}}",
612-
"{$project: {STATE: '$_id', CDC: '$CDC'}}",
613-
"{$sort: {STATE: 1}}"));
617+
"{$project: {STATE: '$state', CITY: '$city'}}"));
614618
}
615619

616620
@Test void testDistinctCountOrderBy() {
@@ -636,18 +640,16 @@ private CalciteAssert.AssertThat assertModel(URL url) {
636640
"{$limit: 5}"));
637641
}
638642

639-
@Disabled("broken; [CALCITE-2115] is logged to fix it")
640643
@Test void testProject() {
641644
assertModel(MODEL)
642645
.query("select state, city, 0 as zero from zips order by state, city")
643646
.limit(2)
644-
.returns("STATE=AK; CITY=AKHIOK; ZERO=0\n"
645-
+ "STATE=AK; CITY=AKIACHAK; ZERO=0\n")
647+
.returns("STATE=AK; CITY=ANCHORAGE; ZERO=0\n"
648+
+ "STATE=AK; CITY=FAIRBANKS; ZERO=0\n")
646649
.queryContains(
647650
mongoChecker(
648-
"{$project: {CITY: '$city', STATE: '$state'}}",
649-
"{$sort: {STATE: 1, CITY: 1}}",
650-
"{$project: {STATE: 1, CITY: 1, ZERO: {$literal: 0}}}"));
651+
"{$project: {STATE: '$state', CITY: '$city', 'ZERO': {$literal: 0}}}",
652+
"{$sort: {STATE: 1, CITY: 1}}"));
651653
}
652654

653655
@Test void testFilter() {

0 commit comments

Comments
 (0)