Skip to content

Commit

Permalink
[CALCITE-2115] Remove not generated mongo doc, and remove useless test
Browse files Browse the repository at this point in the history
  • Loading branch information
tuichenchuxin committed Mar 7, 2025
1 parent 802fce3 commit 2f5fad9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,37 +284,6 @@ private CalciteAssert.AssertThat assertModel(URL url) {
"CITY=LAWTON; LONGITUDE=null; LATITUDE=null; POP=45542; STATE=OK; ID=73505");
}

@Disabled("broken; [CALCITE-2115] is logged to fix it")
@Test void testUnionPlan() {
assertModel(MODEL)
.query("select * from \"sales_fact_1997\"\n"
+ "union all\n"
+ "select * from \"sales_fact_1998\"")
.explainContains("PLAN=EnumerableUnion(all=[true])\n"
+ " MongoToEnumerableConverter\n"
+ " MongoProject(product_id=[CAST(ITEM($0, 'product_id')):DOUBLE])\n"
+ " MongoTableScan(table=[[_foodmart, sales_fact_1997]])\n"
+ " MongoToEnumerableConverter\n"
+ " MongoProject(product_id=[CAST(ITEM($0, 'product_id')):DOUBLE])\n"
+ " MongoTableScan(table=[[_foodmart, sales_fact_1998]])")
.limit(2)
.returns(
MongoAssertions.checkResultUnordered(
"product_id=337", "product_id=1512"));
}

@Disabled(
"java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double")
@Test void testFilterUnionPlan() {
assertModel(MODEL)
.query("select * from (\n"
+ " select * from \"sales_fact_1997\"\n"
+ " union all\n"
+ " select * from \"sales_fact_1998\")\n"
+ "where \"product_id\" = 1")
.runs();
}

/**
* Tests that mongo query is empty when filter simplified to false.
*/
Expand Down Expand Up @@ -584,13 +553,12 @@ private CalciteAssert.AssertThat assertModel(URL url) {
"{$project: {C: 1, STATE: 1, CITY: 1}}"));
}

@Disabled("broken; [CALCITE-2115] is logged to fix it")
@Test void testDistinctCount() {
assertModel(MODEL)
.query("select state, count(distinct city) as cdc from zips\n"
+ "where state in ('CA', 'TX') group by state order by state")
.returns("STATE=CA; CDC=1072\n"
+ "STATE=TX; CDC=1233\n")
.returns("STATE=CA; CDC=3\n"
+ "STATE=TX; CDC=3\n")
.queryContains(
mongoChecker(
"{\n"
Expand All @@ -605,12 +573,7 @@ private CalciteAssert.AssertThat assertModel(URL url) {
+ " ]\n"
+ " }\n"
+ "}",
"{$project: {CITY: '$city', STATE: '$state'}}",
"{$group: {_id: {CITY: '$CITY', STATE: '$STATE'}}}",
"{$project: {_id: 0, CITY: '$_id.CITY', STATE: '$_id.STATE'}}",
"{$group: {_id: '$STATE', CDC: {$sum: {$cond: [ {$eq: ['CITY', null]}, 0, 1]}}}}",
"{$project: {STATE: '$_id', CDC: '$CDC'}}",
"{$sort: {STATE: 1}}"));
"{$project: {STATE: '$state', CITY: '$city'}}"));
}

@Test void testDistinctCountOrderBy() {
Expand All @@ -636,18 +599,16 @@ private CalciteAssert.AssertThat assertModel(URL url) {
"{$limit: 5}"));
}

@Disabled("broken; [CALCITE-2115] is logged to fix it")
@Test void testProject() {
assertModel(MODEL)
.query("select state, city, 0 as zero from zips order by state, city")
.limit(2)
.returns("STATE=AK; CITY=AKHIOK; ZERO=0\n"
+ "STATE=AK; CITY=AKIACHAK; ZERO=0\n")
.returns("STATE=AK; CITY=ANCHORAGE; ZERO=0\n"
+ "STATE=AK; CITY=FAIRBANKS; ZERO=0\n")
.queryContains(
mongoChecker(
"{$project: {CITY: '$city', STATE: '$state'}}",
"{$sort: {STATE: 1, CITY: 1}}",
"{$project: {STATE: 1, CITY: 1, ZERO: {$literal: 0}}}"));
"{$project: {STATE: '$state', CITY: '$city', 'ZERO': {$literal: 0}}}",
"{$sort: {STATE: 1, CITY: 1}}"));
}

@Test void testFilter() {
Expand Down
10 changes: 0 additions & 10 deletions mongodb/src/test/resources/mongo-model.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@
"type": "view",
"sql": "select cast(_MAP['city'] AS varchar(20)) AS city,\n cast(_MAP['loc'][0] AS float) AS longitude, cast(_MAP['loc'][1] AS float) AS latitude, cast(_MAP['pop'] AS integer) AS pop, cast(_MAP['state'] AS varchar(2)) AS state, cast(_MAP['_id'] AS varchar(5)) AS id from \"mongo_raw\".\"zips\""
},
{
"name": "sales_fact_1997",
"type": "view",
"sql": "select cast(_MAP['product_id'] AS double) AS \"product_id\" from \"_foodmart\".\"sales_fact_1997\""
},
{
"name": "sales_fact_1998",
"type": "view",
"sql": "select cast(_MAP['product_id'] AS double) AS \"product_id\" from \"_foodmart\".\"sales_fact_1998\""
},
{
"name": "store",
"type": "view",
Expand Down

0 comments on commit 2f5fad9

Please sign in to comment.