Amrish Lal
04/13/2021, 11:19 PMQueryOptimizer.optimize
function for PinotQuery
). Basically, if we can precompute the value of an Expression
or Function
, then precomputed
will contain that value. This will help in adding type support as discussed and also further predicate pruning and optimization in future. Let me know if there are suggestions or alternate ideas for this?
alal@alal-mn1 amrish-pinot-1 % git diff pinot-common/src/thrift/query.thrift
diff --git a/pinot-common/src/thrift/query.thrift b/pinot-common/src/thrift/query.thrift
index 98329f5ac..5445ce645 100644
--- a/pinot-common/src/thrift/query.thrift
+++ b/pinot-common/src/thrift/query.thrift
@@ -47,6 +47,7 @@ struct Expression {
2: optional Function functionCall;
3: optional Literal literal;
4: optional Identifier identifier;
+ 5: optional Literal precomputed;
}
struct Identifier {
@@ -67,4 +68,5 @@ union Literal {
struct Function {
1: required string operator;
2: optional list<Expression> operands;
+ 3: optional Literal precomputed;
}
Jackie
04/13/2021, 11:29 PMprecomputed
fieldJackie
04/13/2021, 11:30 PMAmrish Lal
04/13/2021, 11:48 PMAmrish Lal
04/13/2021, 11:54 PMAmrish Lal
04/13/2021, 11:58 PMSELECT * from mytable WHERE intColumn = 5.5
, the predicate here will always evaluate to false and hence the query will become SELECT * from mytable
.Amrish Lal
04/14/2021, 12:02 AMSELECT * from mytable WHERE FALSE
and then short-circuit the query if predicate is FALSE
? There could be more complicated cases such as SELECT * FROM mytable WHERE FALSE AND (intColumn > 5 OR FALSE)
. I think this approach will avoid adding precomputed to Expression
and Function
, etc while ensuring that we have the information that we need to short-circuit the query. Sounds ok?Amrish Lal
04/14/2021, 12:04 AMSELECT * from mytable WHERE FALSE
isn't a valid query, but its just a temporary form that we are using for optimization so should be ok.Jackie
04/14/2021, 12:24 AMtrue
or it evaluates to false
as a child under AND
Jackie
04/14/2021, 12:24 AMJackie
04/14/2021, 12:27 AMtrue
or false
) into the return value of the FilterOptimizer
to pass it back to the callerJackie
04/14/2021, 12:42 AM1.0
-> 1
)Amrish Lal
04/14/2021, 12:46 AMSELECT * from mytable WHERE intColumn = 5.5
, is rewritten to SELECT * from mytable WHERE FALSE
and that will allow us to do everything including circuiting without adding precomputed.Amrish Lal
04/14/2021, 12:47 AMJackie
04/14/2021, 12:47 AMAmrish Lal
04/14/2021, 12:47 AMAmrish Lal
04/14/2021, 12:47 AMAmrish Lal
04/14/2021, 12:47 AMJackie
04/14/2021, 12:48 AMFALSE
?Amrish Lal
04/14/2021, 12:48 AMSELECT * FROM mytable WHERE FALSE
and if it the query gets rewritten to SELECT * FROM mytable WHERE TRUE
then we drop the WHERE clause.Jackie
04/14/2021, 12:50 AMJackie
04/14/2021, 12:50 AMAmrish Lal
04/14/2021, 12:50 AMAmrish Lal
04/14/2021, 12:51 AMJackie
04/14/2021, 12:53 AMTRUE
and FALSE
as valid predicate
2. Implement the filter optimizer to rewrite values
3. Short circuit the query if the predicate is FALSE
Jackie
04/14/2021, 12:54 AMTRUE
and FALSE
to pass around the informationAmrish Lal
04/14/2021, 12:56 AMIntroduce TRUE and FALSE as valid predicate in Broker optimizer.
As a separate ticket item, we could add SQL querying support for queries that contain TRUE/FALSE in WHERE clause.Jackie
04/14/2021, 12:57 AMAmrish Lal
04/14/2021, 12:58 AMKavin Kuppusamy
11/06/2021, 5:55 PM