amrishlal commented on a change in pull request #7568:
URL: https://github.com/apache/pinot/pull/7568#discussion_r746093704
##########
File path:
pinot-broker/src/test/java/org/apache/pinot/broker/requesthandler/LiteralOnlyBrokerRequestTest.java
##########
@@ -177,4 +177,55 @@ public void testBrokerRequestHandlerWithAsFunction()
Assert.assertEquals(brokerResponse.getResultTable().getRows().get(0)[1],
1577836800000L);
Assert.assertEquals(brokerResponse.getTotalDocs(), 0);
}
+
+ /** Tests for EXPLAIN PLAN for literal only queries. */
+ @Test
+ public void testExplainPlanLiteralOnly()
+ throws Exception {
+ SingleConnectionBrokerRequestHandler requestHandler =
+ new SingleConnectionBrokerRequestHandler(new PinotConfiguration(),
null, ACCESS_CONTROL_FACTORY, null, null,
+ new BrokerMetrics("", PinotMetricUtils.getPinotMetricsRegistry(),
true, Collections.emptySet()), null);
+
+ // Test 1: select constant
+ JsonNode request = new ObjectMapper().readTree("{\"sql\":\"EXPLAIN PLAN
FOR SELECT 1.5, 'test'\"}");
+ RequestStatistics requestStats = new RequestStatistics();
+ BrokerResponseNative brokerResponse =
requestHandler.handleRequest(request, null, requestStats);
+
+ checkExplainResultSchema(brokerResponse.getResultTable().getDataSchema(),
+ new String[]{"Operator", "Operator_Id", "Parent_Id"},
+ new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.STRING,
DataSchema.ColumnDataType.INT,
+ DataSchema.ColumnDataType.INT});
+
+ Assert.assertEquals(brokerResponse.getResultTable().getRows().size(), 1);
+ Assert.assertEquals(brokerResponse.getResultTable().getRows().get(0),
+ new Object[]{"SELECT(selectList:literal)", 0, -1});
+ Assert.assertEquals(brokerResponse.getTotalDocs(), 0);
+
+ // Test 2: invoke compile time function -> literal only
+ long currentTsMin = System.currentTimeMillis();
+ request = new ObjectMapper().readTree(
+ "{\"sql\":\"EXPLAIN PLAN FOR SELECT 6+8 as addition,
fromDateTime('2020-01-01 UTC', 'yyyy-MM-dd z') as "
+ + "firstDayOf2020\"}");
+ requestStats = new RequestStatistics();
+ brokerResponse = requestHandler.handleRequest(request, null, requestStats);
+
+ checkExplainResultSchema(brokerResponse.getResultTable().getDataSchema(),
+ new String[]{"Operator", "Operator_Id", "Parent_Id"},
+ new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.STRING,
DataSchema.ColumnDataType.INT,
+ DataSchema.ColumnDataType.INT});
+
+ Assert.assertEquals(brokerResponse.getResultTable().getRows().size(), 1);
+ Assert.assertEquals(brokerResponse.getResultTable().getRows().get(0),
+ new Object[]{"SELECT(selectList:literal)", 0, -1});
Review comment:
`SELECT(selectList:literal)` will only show up if ALL the column in the
select list are literals, so no point in displaying something like
`SELECT(selectList:literal, literal, literal, ...)`. Changed it to plural
though: `SELECT(selectList:literals)`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]