@@ -46,17 +46,29 @@ public class LogicalSort<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYP
46
46
47
47
private final List <OrderKey > orderKeys ;
48
48
49
+ private final boolean orderKeysPruned ;
50
+
49
51
public LogicalSort (List <OrderKey > orderKeys , CHILD_TYPE child ) {
50
52
this (orderKeys , Optional .empty (), Optional .empty (), child );
51
53
}
52
54
55
+ public LogicalSort (List <OrderKey > orderKeys , CHILD_TYPE child , boolean orderKeysPruned ) {
56
+ this (orderKeys , Optional .empty (), Optional .empty (), child , orderKeysPruned );
57
+ }
58
+
53
59
/**
54
60
* Constructor for LogicalSort.
55
61
*/
56
62
public LogicalSort (List <OrderKey > orderKeys , Optional <GroupExpression > groupExpression ,
57
63
Optional <LogicalProperties > logicalProperties , CHILD_TYPE child ) {
64
+ this (orderKeys , groupExpression , logicalProperties , child , false );
65
+ }
66
+
67
+ public LogicalSort (List <OrderKey > orderKeys , Optional <GroupExpression > groupExpression ,
68
+ Optional <LogicalProperties > logicalProperties , CHILD_TYPE child , boolean orderKeysPruned ) {
58
69
super (PlanType .LOGICAL_SORT , groupExpression , logicalProperties , child );
59
70
this .orderKeys = ImmutableList .copyOf (Objects .requireNonNull (orderKeys , "orderKeys can not be null" ));
71
+ this .orderKeysPruned = orderKeysPruned ;
60
72
}
61
73
62
74
@ Override
@@ -68,6 +80,10 @@ public List<OrderKey> getOrderKeys() {
68
80
return orderKeys ;
69
81
}
70
82
83
+ public boolean isOrderKeysPruned () {
84
+ return orderKeysPruned ;
85
+ }
86
+
71
87
@ Override
72
88
public String toString () {
73
89
return Utils .toSqlString ("LogicalSort[" + id .asInt () + "]" ,
@@ -106,21 +122,27 @@ public List<? extends Expression> getExpressions() {
106
122
@ Override
107
123
public LogicalSort <Plan > withChildren (List <Plan > children ) {
108
124
Preconditions .checkArgument (children .size () == 1 );
109
- return new LogicalSort <>(orderKeys , children .get (0 ));
125
+ return new LogicalSort <>(orderKeys , children .get (0 ), orderKeysPruned );
110
126
}
111
127
112
128
@ Override
113
129
public LogicalSort <Plan > withGroupExpression (Optional <GroupExpression > groupExpression ) {
114
- return new LogicalSort <>(orderKeys , groupExpression , Optional .of (getLogicalProperties ()), child ());
130
+ return new LogicalSort <>(orderKeys , groupExpression , Optional .of (getLogicalProperties ()), child (),
131
+ orderKeysPruned );
115
132
}
116
133
117
134
@ Override
118
135
public LogicalSort <Plan > withLogicalProperties (Optional <LogicalProperties > logicalProperties ) {
119
- return new LogicalSort <>(orderKeys , Optional .empty (), logicalProperties , child ());
136
+ return new LogicalSort <>(orderKeys , Optional .empty (), logicalProperties , child (), false );
120
137
}
121
138
122
139
public LogicalSort <Plan > withOrderKeys (List <OrderKey > orderKeys ) {
123
140
return new LogicalSort <>(orderKeys , Optional .empty (),
124
- Optional .of (getLogicalProperties ()), child ());
141
+ Optional .of (getLogicalProperties ()), child (), false );
142
+ }
143
+
144
+ public LogicalSort <Plan > withOrderKeysPruned (boolean orderKeysPruned ) {
145
+ return new LogicalSort <>(orderKeys , groupExpression , Optional .of (getLogicalProperties ()), child (),
146
+ orderKeysPruned );
125
147
}
126
148
}
0 commit comments