Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-2115] Remove not generated mongo doc, and remove useless test #4228

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we directly deleted the test cases that couldn't run. A better approach should be to make them run as we want.

@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