Package com.twilio.kudu.sql.rules
Class KuduAggregationLimitRule
java.lang.Object
org.apache.calcite.plan.RelOptRule
com.twilio.kudu.sql.rules.KuduAggregationLimitRule
public class KuduAggregationLimitRule
extends org.apache.calcite.plan.RelOptRule
Rule to match a limit over a sort over aggregation. There must be a common
prefix between the sort columns and the primary key columns of the table.
If a table has three columns A, B and C with a PK(A, B) this rule can be
applied if sorting by (A, SUM(C)) and grouping by (A, B) with a limit. For
eg: (A,B,C) (1, 1, 4), (1, 2, 2), (2, 1, 1). If we query with a limit of 2,
then we can stop reading rows when we process the 3rd row as we will have 2
groups (1,1) and (1,2).
This rule limits the number of rows read from kudu, but rows still need to be
sorted on the client.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule
org.apache.calcite.plan.RelOptRule.ConverterRelOptRuleOperand
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.calcite.plan.RelOptRule
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
Constructor Summary
ConstructorsConstructorDescriptionKuduAggregationLimitRule
(org.apache.calcite.tools.RelBuilderFactory factory) -
Method Summary
Modifier and TypeMethodDescriptiongetSortPkPrefix
(org.apache.calcite.rel.RelCollation newCollation, KuduQuery query, Optional<org.apache.calcite.rel.core.Filter> filter) void
onMatch
(org.apache.calcite.plan.RelOptRuleCall call) protected void
perform
(org.apache.calcite.plan.RelOptRuleCall call, org.apache.calcite.rel.core.Sort originalSort, org.apache.calcite.rel.core.Aggregate originalAggregate, org.apache.calcite.rel.core.Project project, org.apache.calcite.rel.core.Filter filter, KuduQuery query) Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
Field Details
-
AGGREGATION_LIMIT_RULE
public static final org.apache.calcite.plan.RelOptRule AGGREGATION_LIMIT_RULE
-
-
Constructor Details
-
KuduAggregationLimitRule
public KuduAggregationLimitRule(org.apache.calcite.tools.RelBuilderFactory factory)
-
-
Method Details
-
onMatch
public void onMatch(org.apache.calcite.plan.RelOptRuleCall call) - Specified by:
onMatch
in classorg.apache.calcite.plan.RelOptRule
-
perform
protected void perform(org.apache.calcite.plan.RelOptRuleCall call, org.apache.calcite.rel.core.Sort originalSort, org.apache.calcite.rel.core.Aggregate originalAggregate, org.apache.calcite.rel.core.Project project, org.apache.calcite.rel.core.Filter filter, KuduQuery query) -
getSortPkPrefix
-