Skip to content

Commit 3117a09

Browse files
committed
feat(istmus): add ddl support to sql->substrait
# Conflicts: # isthmus/src/main/java/io/substrait/isthmus/SqlToSubstrait.java # Conflicts: # isthmus/src/main/java/io/substrait/isthmus/SqlToSubstrait.java # Conflicts: # isthmus/src/main/java/io/substrait/isthmus/SqlToSubstrait.java # isthmus/src/test/java/io/substrait/isthmus/DdlRoundtripTest.java
1 parent 07912c9 commit 3117a09

1 file changed

Lines changed: 3 additions & 37 deletions

File tree

isthmus/src/test/java/io/substrait/isthmus/DdlRoundtripTest.java

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5-
import io.substrait.isthmus.operation.CalciteOperation;
65
import io.substrait.isthmus.sql.SubstraitCreateStatementParser;
76
import io.substrait.plan.Plan;
87
import io.substrait.plan.PlanProtoConverter;
98
import io.substrait.plan.ProtoPlanConverter;
10-
import io.substrait.relation.Rel;
119
import org.apache.calcite.prepare.Prepare;
1210
import org.apache.calcite.sql.parser.SqlParseException;
1311
import org.junit.jupiter.api.Test;
@@ -30,55 +28,23 @@ void testSqlToSubstrait(String sqlStatement) throws SqlParseException {
3028
assertEquals(protoPlan, protoPlan1);
3129
}
3230

33-
protected void assertCalciteOperationSubstraitRelRoundTrip(
34-
String query, Prepare.CatalogReader catalogReader) throws Exception {
35-
// sql <--> substrait round trip test.
36-
// Assert (sql -> calcite -> substrait) and (sql -> substrait -> calcite -> substrait) are same.
37-
// Return list of sql -> Substrait rel -> Calcite rel.
38-
SqlToSubstrait s = new SqlToSubstrait();
39-
40-
// 1. SQL -> Substrait Plan
41-
Plan plan1 = s.convert(query, catalogReader);
42-
43-
// 2. Substrait Plan -> Substrait Rel
44-
Plan.Root pojo1 = plan1.getRoots().get(0);
45-
46-
// 3. Substrait Rel -> CalciteOperation
47-
48-
SubstraitToCalciteOperation substraitToCalciteOperation =
49-
new SubstraitToCalciteOperation(extensions, typeFactory, catalogReader, s.parserConfig);
50-
Rel rel = plan1.getRoots().get(0).getInput();
51-
CalciteOperation calciteOperation =
52-
rel.accept(substraitToCalciteOperation, SubstraitRelNodeConverter.Context.newContext());
53-
54-
// 4. CalciteOperation -> Substrait Rel
55-
CalciteOperationToSubstrait calciteOperationToSubstrait =
56-
new CalciteOperationToSubstrait(extensions, s.featureBoard);
57-
Plan.Root pojo2 = calciteOperation.accept(calciteOperationToSubstrait);
58-
59-
assertEquals(pojo1, pojo2);
60-
}
61-
62-
void testPlanRoundTrip(String sqlStatement) throws Exception {
31+
void testPlanRoundTrip(String sqlStatement) throws SqlParseException {
6332
SqlToSubstrait sql2subst = new SqlToSubstrait();
6433
final Plan plan = sql2subst.convert(sqlStatement, catalogReader);
6534

6635
assertPlanRoundtrip(plan);
67-
assertCalciteOperationSubstraitRelRoundTrip(sqlStatement, catalogReader);
68-
69-
// assertFullRoundTrip(sqlStatement, catalogReader);
7036
}
7137

7238
@Test
73-
void testCreateTable() throws Exception {
39+
void testCreateTable() throws SqlParseException {
7440
String sql = "create table dst1 as select * from src1";
7541
testSqlToSubstrait(sql);
7642
// TBD: full roundtrip is not possible because there is no relational algebra for DDL
7743
testPlanRoundTrip(sql);
7844
}
7945

8046
@Test
81-
void testCreateView() throws Exception {
47+
void testCreateView() throws SqlParseException {
8248
String sql = "create view dst1 as select * from src1";
8349
testSqlToSubstrait(sql);
8450
testPlanRoundTrip(sql);

0 commit comments

Comments
 (0)