vdiravka commented on a change in pull request #1466: DRILL-6381: Add support for index based planning and execution URL: https://github.com/apache/drill/pull/1466#discussion_r223660964
########## File path: contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/index/StatisticsTest.java ########## @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.mapr.drill.maprdb.tests.index; + +import com.google.common.collect.Lists; +import com.mapr.db.Admin; +import com.mapr.drill.maprdb.tests.MaprDBTestsSuite; +import com.mapr.drill.maprdb.tests.json.BaseJsonTest; +import com.mapr.tests.annotations.ClusterTest; +import org.apache.drill.PlanTestBase; +import org.apache.hadoop.hbase.TableName; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.util.List; + +@Category(ClusterTest.class) +public class StatisticsTest extends IndexPlanTest { + /** + * A sample row of this 10K table: + ------------------+-----------------------------+--------+ + | 1012 | {"city":"pfrrs","state":"pc"} | {"email":"[email protected]","phone":"6500005471"} | + {"ssn":"100007423"} | {"fname":"KfFzK","lname":"UZwNk"} | {"age":53.0,"income":45.0} | 1012 | + * + * This test suite generate random content to fill all the rows, since the random function always start from + * the same seed for different runs, when the row count is not changed, the data in table will always be the same, + * thus the query result could be predicted and verified. + */ + + @Test + @Ignore("Currently untested; re-enable after stats/costing integration complete") + public void testFilters() throws Exception { + String query; + String explain = "explain plan including all attributes for "; + + // Top-level ANDs - Leading columns (personal.age), (address.state) + query = "select * from hbase.`index_test_primary` t " + + " where (t.personal.age < 30 or t.personal.age > 100)" + + " and (t.address.state = 'mo' or t.address.state = 'ca')"; + PlanTestBase.testPlanMatchingPatterns(explain+query, + new String[] {".*JsonTableGroupScan.*tableName=.*index_test_primary.*rows=10000"}, + new String[] {} + ); + + // Top-level ORs - Cannot split top-level ORs so use defaults + query = "select * from hbase.`index_test_primary` t " + + " where (t.personal.age > 30 and t.personal.age < 100)" + + " or (t.address.state = 'mo')"; + PlanTestBase.testPlanMatchingPatterns(explain+query, + new String[] {".*JsonTableGroupScan.*tableName=.*index_test_primary.*rows=10000"}, + new String[] {} + ); + + // ANDed condition - Leading index column(personal.age) and non-leading column(address.city) + query = "select * from hbase.`index_test_primary` t " + + " where (t.personal.age < 30 or t.personal.age > 100)" + + " and `address.city` = 'sf'"; + PlanTestBase.testPlanMatchingPatterns(explain+query, + new String[] {".*JsonTableGroupScan.*tableName=.*index_test_primary.*rows=10000"}, + new String[] {} + ); + + // ANDed condition - Leading index columns (address.state) and (address.city) + query = "select * from hbase.`index_test_primary` t " + + " where (`address.state` = 'mo' or `address.state` = 'ca') " // Leading index column + + " and `address.city` = 'sf'"; // Non leading index column + PlanTestBase.testPlanMatchingPatterns(explain+query, + new String[] {".*JsonTableGroupScan.*tableName=.*index_test_primary.*rows=10000"}, + new String[] {} Review comment: There is an overloaded method without `excludedPatterns` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
