-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: account for struct fields in VirtualTableScan check
- Loading branch information
Showing
2 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.substrait.relation; | ||
|
||
import static io.substrait.expression.ExpressionCreator.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import io.substrait.expression.Expression; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class VirtualTableScanTest { | ||
|
||
@Test | ||
void check() { | ||
VirtualTableScan virtualTableScan = | ||
ImmutableVirtualTableScan.builder() | ||
.addDfsNames( | ||
"string", | ||
"struct", | ||
"struct_field1", | ||
"struct_field2", | ||
"list", | ||
"list_struct_field1", | ||
"map", | ||
"map_key_struct_field1", | ||
"map_value_struct_field1") | ||
.addRows( | ||
struct( | ||
false, | ||
string(false, "string_val"), | ||
struct( | ||
false, | ||
string(false, "struct_field1_val"), | ||
string(false, "struct_field2_val")), | ||
list(false, struct(false, string(false, "list_struct_field1_val"))), | ||
map( | ||
false, | ||
mapOf( | ||
struct(false, string(false, "map_key_struct_field1_val")), | ||
struct(false, string(false, "map_value_struct_field1_val")))))) | ||
.build(); | ||
assertDoesNotThrow(virtualTableScan::check); | ||
} | ||
|
||
private Map<Expression.Literal, Expression.Literal> mapOf( | ||
Expression.Literal key, Expression.Literal value) { | ||
// Map.of() comes only in Java 9 and the "core" module is on Java 8 | ||
HashMap<Expression.Literal, Expression.Literal> map = new HashMap<>(); | ||
map.put(key, value); | ||
return map; | ||
} | ||
} |