|
7 | 7 | import io.substrait.dsl.SubstraitBuilder; |
8 | 8 | import io.substrait.expression.Expression.UserDefinedLiteral; |
9 | 9 | import io.substrait.expression.ExpressionCreator; |
10 | | -import io.substrait.extension.ExtensionCollector; |
11 | 10 | import io.substrait.extension.SimpleExtension; |
12 | 11 | import io.substrait.isthmus.expression.AggregateFunctionConverter; |
13 | 12 | import io.substrait.isthmus.expression.FunctionMappings; |
|
16 | 15 | import io.substrait.isthmus.utils.UserTypeFactory; |
17 | 16 | import io.substrait.proto.Expression; |
18 | 17 | import io.substrait.proto.Expression.Literal.Builder; |
19 | | -import io.substrait.relation.ProtoRelConverter; |
20 | 18 | import io.substrait.relation.Rel; |
21 | | -import io.substrait.relation.RelProtoConverter; |
22 | 19 | import io.substrait.type.Type; |
23 | 20 | import io.substrait.type.TypeCreator; |
24 | 21 | import java.io.IOException; |
@@ -601,10 +598,24 @@ void customTypesLiteralInFunctionsRoundtrip() { |
601 | 598 | RelNode calciteRel = substraitToCalcite.convert(rel1); |
602 | 599 | Rel rel2 = calciteToSubstrait.apply(calciteRel); |
603 | 600 | assertEquals(rel1, rel2); |
| 601 | + } |
| 602 | + |
| 603 | + @Test |
| 604 | + void customNullableUserDefinedLiteralRoundtrip() { |
| 605 | + Builder bldr = Expression.Literal.newBuilder(); |
| 606 | + Any anyValue = Any.pack(bldr.setI32(10).build()); |
| 607 | + UserDefinedLiteral nullableLiteral = |
| 608 | + ExpressionCreator.userDefinedLiteralAny( |
| 609 | + true, URN, "a_type", java.util.Collections.emptyList(), anyValue); |
| 610 | + |
| 611 | + Rel rel = |
| 612 | + b.project( |
| 613 | + input -> List.of(nullableLiteral), |
| 614 | + b.remap(1), |
| 615 | + b.namedScan(List.of("example"), List.of("a"), List.of(N.userDefined(URN, "a_type")))); |
604 | 616 |
|
605 | | - ExtensionCollector extensionCollector = new ExtensionCollector(); |
606 | | - io.substrait.proto.Rel protoRel = new RelProtoConverter(extensionCollector).toProto(rel1); |
607 | | - Rel rel3 = new ProtoRelConverter(extensionCollector, extensionCollection).from(protoRel); |
608 | | - assertEquals(rel1, rel3); |
| 617 | + RelNode calciteRel = substraitToCalcite.convert(rel); |
| 618 | + Rel relReturned = calciteToSubstrait.apply(calciteRel); |
| 619 | + assertEquals(rel, relReturned); |
609 | 620 | } |
610 | 621 | } |
0 commit comments