@@ -50,6 +50,8 @@ public class PlanTestBase {
5050
5151 protected static final CalciteCatalogReader TPCH_CATALOG ;
5252
53+ protected ConverterProvider converterProvider ;
54+
5355 static {
5456 try {
5557 String tpchCreateStatements = asString ("tpch/schema.sql" );
@@ -69,8 +71,14 @@ protected PlanTestBase() {
6971 }
7072
7173 protected PlanTestBase (SimpleExtension .ExtensionCollection extensions ) {
74+ this (extensions , new ConverterProvider (extensions ));
75+ }
76+
77+ protected PlanTestBase (
78+ SimpleExtension .ExtensionCollection extensions , ConverterProvider converterProvider ) {
7279 this .extensions = extensions ;
7380 this .substraitBuilder = new SubstraitBuilder (extensions );
81+ this .converterProvider = converterProvider ;
7482 }
7583
7684 public static String asString (String resource ) throws IOException {
@@ -134,7 +142,8 @@ protected RelRoot assertSqlSubstraitRelRoundTrip(
134142 // Return list of sql -> Substrait rel -> Calcite rel.
135143
136144 SqlToSubstrait s2s = new SqlToSubstrait ();
137- SubstraitToCalcite substraitToCalcite = new SubstraitToCalcite (extensions , typeFactory );
145+ SubstraitToCalcite substraitToCalcite =
146+ new SubstraitToCalcite (converterProvider , catalogReader );
138147
139148 // 1. SQL -> Substrait Plan
140149 Plan plan1 = s2s .convert (query , catalogReader );
@@ -146,7 +155,7 @@ protected RelRoot assertSqlSubstraitRelRoundTrip(
146155 RelRoot relRoot2 = substraitToCalcite .convert (pojo1 );
147156
148157 // 4. Calcite RelNode -> Substrait Rel
149- Plan .Root pojo2 = SubstraitRelVisitor .convert (relRoot2 , extensions );
158+ Plan .Root pojo2 = SubstraitRelVisitor .convert (relRoot2 , converterProvider );
150159
151160 assertEquals (pojo1 , pojo2 );
152161 return relRoot2 ;
@@ -181,11 +190,11 @@ protected RelRoot assertSqlSubstraitRelRoundTripLoosePojoComparison(
181190 featureBoard != null ? featureBoard : ImmutableFeatureBoard .builder ().build ();
182191
183192 SubstraitToCalcite substraitToCalcite =
184- new SubstraitToCalcite (extensions , typeFactory , TypeConverter . DEFAULT , null , features );
185- SqlToSubstrait s = new SqlToSubstrait (extensions , features );
193+ new SubstraitToCalcite (converterProvider , catalogReader );
194+ SqlToSubstrait sqlToSubstrait = new SqlToSubstrait (extensions , converterProvider , featureBoard );
186195
187196 // 1. SQL -> Substrait Plan
188- Plan plan1 = s .convert (query , catalogReader );
197+ Plan plan1 = sqlToSubstrait .convert (query , catalogReader );
189198
190199 // 2. Substrait Plan -> Substrait Root (POJO 1)
191200 Plan .Root pojo1 = plan1 .getRoots ().get (0 );
@@ -194,7 +203,7 @@ protected RelRoot assertSqlSubstraitRelRoundTripLoosePojoComparison(
194203 RelRoot relRoot2 = substraitToCalcite .convert (pojo1 );
195204
196205 // 4. Calcite RelNode -> Substrait Root (POJO 2)
197- Plan .Root pojo2 = SubstraitRelVisitor .convert (relRoot2 , extensions , features );
206+ Plan .Root pojo2 = SubstraitRelVisitor .convert (relRoot2 , converterProvider );
198207
199208 // Note: pojo1 and pojo2 may differ due to different optimization strategies applied by:
200209 // - SqlNode->RelRoot conversion during SQL->Substrait conversion
@@ -205,7 +214,7 @@ protected RelRoot assertSqlSubstraitRelRoundTripLoosePojoComparison(
205214 RelRoot relRoot3 = substraitToCalcite .convert (pojo2 );
206215
207216 // 6. Calcite RelNode -> Substrait Root (POJO 3)
208- Plan .Root pojo3 = SubstraitRelVisitor .convert (relRoot3 , extensions , features );
217+ Plan .Root pojo3 = SubstraitRelVisitor .convert (relRoot3 , converterProvider );
209218
210219 // Verify that subsequent round trips are stable (pojo2 and pojo3 should be identical)
211220 assertEquals (pojo2 , pojo3 );
0 commit comments