vvysotskyi commented on a change in pull request #1968: DRILL-7570: Fix
unstable statistics tests
URL: https://github.com/apache/drill/pull/1968#discussion_r375318988
##########
File path:
exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestAnalyze.java
##########
@@ -522,46 +601,45 @@ public void testHistogramWithColumnsWithAllNulls()
throws Exception {
.go();
} finally {
- resetSessionOption("planner.slice_target");
- resetSessionOption("store.format");
+ client.resetSession(ExecConstants.SLICE_TARGET);
+ client.resetSession(ExecConstants.OUTPUT_FORMAT_OPTION);
}
}
@Test
public void testHistogramWithIntervalPredicate() throws Exception {
try {
- test("ALTER SESSION SET `planner.slice_target` = 1");
- test("ALTER SESSION SET `store.format` = 'parquet'");
- test("create table dfs.tmp.orders2 as select * from
cp.`tpch/orders.parquet`");
- test("analyze table dfs.tmp.orders2 compute statistics");
- test("alter session set `planner.statistics.use` = true");
+ client.alterSession(ExecConstants.SLICE_TARGET, 1);
+ client.alterSession(ExecConstants.OUTPUT_FORMAT_OPTION, "parquet");
+ run("create table dfs.tmp.orders2 as select * from
cp.`tpch/orders.parquet`");
+ run("analyze table dfs.tmp.orders2 compute statistics");
+ client.alterSession(PlannerSettings.STATISTICS_USE.getOptionName(),
true);
String query = "select 1 from dfs.tmp.orders2 o where o.o_orderdate >=
date '1996-10-01' and o.o_orderdate < date '1996-10-01' + interval '3' month";
String[] expectedPlan1 = {"Filter\\(condition.*\\).*rowcount =
59?.*,.*", "Scan.*columns=\\[`o_orderdate`\\].*rowcount = 15000.0.*"};
- PlanTestBase.testPlanWithAttributesMatchingPatterns(query,
expectedPlan1, new String[]{});
+ queryBuilder()
+ .sql(query)
+ .detailedPlanMatcher()
+ .include(expectedPlan1)
+ .match();
} finally {
- resetSessionOption("planner.slice_target");
- resetSessionOption("store.format");
+ client.resetSession(ExecConstants.SLICE_TARGET);
+ client.resetSession(ExecConstants.OUTPUT_FORMAT_OPTION);
}
}
//Helper function to verify output of ANALYZE statement
private void verifyAnalyzeOutput(String query, String message) throws
Exception {
- List<QueryDataBatch>result = testRunAndReturn(QueryType.SQL, query);
- List<List<String>> output = new ArrayList<>();
- assertTrue(result.size() == 1);
- final QueryDataBatch batch = result.get(0);
- final RecordBatchLoader loader = new
RecordBatchLoader(getDrillbitContext().getAllocator());
- loader.load(batch.getHeader().getDef(), batch.getData());
- output.add(new ArrayList<String>());
- for (VectorWrapper<?> vw: loader) {
- ValueVector.Accessor accessor = vw.getValueVector().getAccessor();
- Object o = accessor.getObject(0);
- output.get(0).add(o == null ? null: o.toString());
+ DirectRowSet rowSet = queryBuilder().sql(query).rowSet();
+ assertEquals(1, rowSet.rowCount());
+
+ RowSetReader reader = rowSet.reader();
+ assertEquals(2, reader.columnCount());
+ while (reader.next()) {
+ ObjectReader column = reader.column(1);
+ assertEquals(message, column.isNull() ? null:
column.getObject().toString());
}
- batch.release();
- loader.clear();
- assertTrue(output.get(0).size() == 2);
- assertEquals(message, output.get(0).get(1));
+
+ rowSet.clear();
Review comment:
Thanks, done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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