28
28
import io .substrait .relation .Set ;
29
29
import io .substrait .relation .Sort ;
30
30
import io .substrait .relation .physical .HashJoin ;
31
+ import io .substrait .relation .physical .MergeJoin ;
31
32
import io .substrait .relation .physical .NestedLoopJoin ;
32
33
import io .substrait .type .ImmutableType ;
33
34
import io .substrait .type .NamedStruct ;
@@ -201,27 +202,32 @@ public HashJoin hashJoin(
201
202
.build ();
202
203
}
203
204
204
- public NamedScan namedScan (
205
- Iterable <String > tableName , Iterable <String > columnNames , Iterable <Type > types ) {
206
- return namedScan (tableName , columnNames , types , Optional .empty ());
207
- }
208
-
209
- public NamedScan namedScan (
210
- Iterable <String > tableName ,
211
- Iterable <String > columnNames ,
212
- Iterable <Type > types ,
213
- Rel .Remap remap ) {
214
- return namedScan (tableName , columnNames , types , Optional .of (remap ));
205
+ public MergeJoin mergeJoin (
206
+ List <Integer > leftKeys ,
207
+ List <Integer > rightKeys ,
208
+ MergeJoin .JoinType joinType ,
209
+ Rel left ,
210
+ Rel right ) {
211
+ return mergeJoin (leftKeys , rightKeys , joinType , Optional .empty (), left , right );
215
212
}
216
213
217
- private NamedScan namedScan (
218
- Iterable <String > tableName ,
219
- Iterable <String > columnNames ,
220
- Iterable <Type > types ,
221
- Optional <Rel .Remap > remap ) {
222
- var struct = Type .Struct .builder ().addAllFields (types ).nullable (false ).build ();
223
- var namedStruct = NamedStruct .of (columnNames , struct );
224
- return NamedScan .builder ().names (tableName ).initialSchema (namedStruct ).remap (remap ).build ();
214
+ public MergeJoin mergeJoin (
215
+ List <Integer > leftKeys ,
216
+ List <Integer > rightKeys ,
217
+ MergeJoin .JoinType joinType ,
218
+ Optional <Rel .Remap > remap ,
219
+ Rel left ,
220
+ Rel right ) {
221
+ return MergeJoin .builder ()
222
+ .left (left )
223
+ .right (right )
224
+ .leftKeys (
225
+ this .fieldReferences (left , leftKeys .stream ().mapToInt (Integer ::intValue ).toArray ()))
226
+ .rightKeys (
227
+ this .fieldReferences (right , rightKeys .stream ().mapToInt (Integer ::intValue ).toArray ()))
228
+ .joinType (joinType )
229
+ .remap (remap )
230
+ .build ();
225
231
}
226
232
227
233
public NestedLoopJoin nestedLoopJoin (
@@ -248,6 +254,29 @@ private NestedLoopJoin nestedLoopJoin(
248
254
.build ();
249
255
}
250
256
257
+ public NamedScan namedScan (
258
+ Iterable <String > tableName , Iterable <String > columnNames , Iterable <Type > types ) {
259
+ return namedScan (tableName , columnNames , types , Optional .empty ());
260
+ }
261
+
262
+ public NamedScan namedScan (
263
+ Iterable <String > tableName ,
264
+ Iterable <String > columnNames ,
265
+ Iterable <Type > types ,
266
+ Rel .Remap remap ) {
267
+ return namedScan (tableName , columnNames , types , Optional .of (remap ));
268
+ }
269
+
270
+ private NamedScan namedScan (
271
+ Iterable <String > tableName ,
272
+ Iterable <String > columnNames ,
273
+ Iterable <Type > types ,
274
+ Optional <Rel .Remap > remap ) {
275
+ var struct = Type .Struct .builder ().addAllFields (types ).nullable (false ).build ();
276
+ var namedStruct = NamedStruct .of (columnNames , struct );
277
+ return NamedScan .builder ().names (tableName ).initialSchema (namedStruct ).remap (remap ).build ();
278
+ }
279
+
251
280
public Project project (Function <Rel , Iterable <? extends Expression >> expressionsFn , Rel input ) {
252
281
return project (expressionsFn , Optional .empty (), input );
253
282
}
0 commit comments