41
41
import com .facebook .presto .spi .plan .WindowNode ;
42
42
import com .facebook .presto .spi .relation .RowExpression ;
43
43
import com .facebook .presto .spi .relation .VariableReferenceExpression ;
44
+ import com .facebook .presto .sql .planner .optimizations .StreamPropertyDerivations .StreamProperties .StreamDistribution ;
44
45
import com .facebook .presto .sql .planner .plan .ApplyNode ;
45
46
import com .facebook .presto .sql .planner .plan .AssignUniqueId ;
46
47
import com .facebook .presto .sql .planner .plan .EnforceSingleRowNode ;
66
67
import com .google .common .collect .ImmutableSet ;
67
68
import com .google .common .collect .Iterables ;
68
69
69
- import javax .annotation .concurrent .Immutable ;
70
-
71
70
import java .util .HashMap ;
72
71
import java .util .HashSet ;
73
72
import java .util .List ;
@@ -97,20 +96,20 @@ public final class StreamPropertyDerivations
97
96
{
98
97
private StreamPropertyDerivations () {}
99
98
100
- public static StreamProperties derivePropertiesRecursively (PlanNode node , Metadata metadata , Session session )
99
+ public static StreamProperties derivePropertiesRecursively (PlanNode node , Metadata metadata , Session session , boolean nativeExecution )
101
100
{
102
101
List <StreamProperties > inputProperties = node .getSources ().stream ()
103
- .map (source -> derivePropertiesRecursively (source , metadata , session ))
102
+ .map (source -> derivePropertiesRecursively (source , metadata , session , nativeExecution ))
104
103
.collect (toImmutableList ());
105
- return StreamPropertyDerivations .deriveProperties (node , inputProperties , metadata , session );
104
+ return StreamPropertyDerivations .deriveProperties (node , inputProperties , metadata , session , nativeExecution );
106
105
}
107
106
108
- public static StreamProperties deriveProperties (PlanNode node , StreamProperties inputProperties , Metadata metadata , Session session )
107
+ public static StreamProperties deriveProperties (PlanNode node , StreamProperties inputProperties , Metadata metadata , Session session , boolean nativeExecution )
109
108
{
110
- return deriveProperties (node , ImmutableList .of (inputProperties ), metadata , session );
109
+ return deriveProperties (node , ImmutableList .of (inputProperties ), metadata , session , nativeExecution );
111
110
}
112
111
113
- public static StreamProperties deriveProperties (PlanNode node , List <StreamProperties > inputProperties , Metadata metadata , Session session )
112
+ public static StreamProperties deriveProperties (PlanNode node , List <StreamProperties > inputProperties , Metadata metadata , Session session , boolean nativeExecution )
114
113
{
115
114
requireNonNull (node , "node is null" );
116
115
requireNonNull (inputProperties , "inputProperties is null" );
@@ -128,7 +127,7 @@ public static StreamProperties deriveProperties(PlanNode node, List<StreamProper
128
127
metadata ,
129
128
session );
130
129
131
- StreamProperties result = node .accept (new Visitor (metadata , session ), inputProperties )
130
+ StreamProperties result = node .accept (new Visitor (metadata , session , nativeExecution ), inputProperties )
132
131
.withOtherActualProperties (otherProperties );
133
132
134
133
result .getPartitioningColumns ().ifPresent (columns ->
@@ -148,11 +147,13 @@ private static class Visitor
148
147
{
149
148
private final Metadata metadata ;
150
149
private final Session session ;
150
+ private final boolean nativeExecution ;
151
151
152
- private Visitor (Metadata metadata , Session session )
152
+ private Visitor (Metadata metadata , Session session , boolean nativeExecution )
153
153
{
154
154
this .metadata = metadata ;
155
155
this .session = session ;
156
+ this .nativeExecution = nativeExecution ;
156
157
}
157
158
158
159
@ Override
@@ -292,13 +293,16 @@ public StreamProperties visitTableScan(TableScanNode node, List<StreamProperties
292
293
Optional <Set <VariableReferenceExpression >> streamPartitionSymbols = layout .getStreamPartitioningColumns ()
293
294
.flatMap (columns -> getNonConstantVariables (columns , assignments , constants ));
294
295
296
+ // Native execution creates a fixed number of drivers for TableScan pipelines
297
+ StreamDistribution streamDistribution = nativeExecution ? FIXED : MULTIPLE ;
298
+
295
299
// if we are partitioned on empty set, we must say multiple of unknown partitioning, because
296
300
// the connector does not guarantee a single split in this case (since it might not understand
297
301
// that the value is a constant).
298
302
if (streamPartitionSymbols .isPresent () && streamPartitionSymbols .get ().isEmpty ()) {
299
- return new StreamProperties (MULTIPLE , Optional .empty (), false );
303
+ return new StreamProperties (streamDistribution , Optional .empty (), false );
300
304
}
301
- return new StreamProperties (MULTIPLE , streamPartitionSymbols , false );
305
+ return new StreamProperties (streamDistribution , streamPartitionSymbols , false );
302
306
}
303
307
304
308
private Optional <Set <VariableReferenceExpression >> getNonConstantVariables (Set <ColumnHandle > columnHandles , Map <ColumnHandle , VariableReferenceExpression > assignments , Set <ColumnHandle > globalConstants )
@@ -641,7 +645,6 @@ public StreamProperties visitRemoteSource(RemoteSourceNode node, List<StreamProp
641
645
}
642
646
}
643
647
644
- @ Immutable
645
648
public static final class StreamProperties
646
649
{
647
650
public enum StreamDistribution
0 commit comments