2
2
3
3
import io .substrait .extension .SimpleExtension ;
4
4
import io .substrait .isthmus .calcite .SubstraitOperatorTable ;
5
+ import io .substrait .isthmus .calcite .SubstraitTable ;
5
6
import java .util .ArrayList ;
6
7
import java .util .List ;
7
8
import org .apache .calcite .config .CalciteConnectionConfig ;
20
21
import org .apache .calcite .rel .type .RelDataTypeFactory ;
21
22
import org .apache .calcite .rex .RexBuilder ;
22
23
import org .apache .calcite .schema .Schema ;
23
- import org .apache .calcite .schema .impl .AbstractTable ;
24
24
import org .apache .calcite .sql .SqlNode ;
25
25
import org .apache .calcite .sql .SqlNodeList ;
26
26
import org .apache .calcite .sql .SqlOperatorTable ;
@@ -79,8 +79,8 @@ CalciteCatalogReader registerCreateTables(List<String> tables) throws SqlParseEx
79
79
SqlValidator validator = Validator .create (factory , catalogReader , SqlValidator .Config .DEFAULT );
80
80
if (tables != null ) {
81
81
for (String tableDef : tables ) {
82
- List <DefinedTable > tList = parseCreateTable (factory , validator , tableDef );
83
- for (DefinedTable t : tList ) {
82
+ List <SubstraitTable > tList = parseCreateTable (factory , validator , tableDef );
83
+ for (SubstraitTable t : tList ) {
84
84
rootSchema .add (t .getName (), t );
85
85
}
86
86
}
@@ -97,10 +97,10 @@ CalciteCatalogReader registerSchema(String name, Schema schema) {
97
97
return new CalciteCatalogReader (rootSchema , List .of (), factory , config );
98
98
}
99
99
100
- protected List <DefinedTable > parseCreateTable (
100
+ protected List <SubstraitTable > parseCreateTable (
101
101
RelDataTypeFactory factory , SqlValidator validator , String sql ) throws SqlParseException {
102
102
SqlParser parser = SqlParser .create (sql , parserConfig );
103
- List <DefinedTable > definedTableList = new ArrayList <>();
103
+ List <SubstraitTable > tableList = new ArrayList <>();
104
104
105
105
SqlNodeList nodeList = parser .parseStmtList ();
106
106
for (SqlNode parsed : nodeList ) {
@@ -140,12 +140,12 @@ protected List<DefinedTable> parseCreateTable(
140
140
columnTypes .add (col .dataType .deriveType (validator ));
141
141
}
142
142
143
- definedTableList .add (
144
- new DefinedTable (
145
- create .name .names .get (0 ), factory , factory .createStructType (columnTypes , names )));
143
+ tableList .add (
144
+ new SubstraitTable (
145
+ create .name .names .get (0 ), factory .createStructType (columnTypes , names )));
146
146
}
147
147
148
- return definedTableList ;
148
+ return tableList ;
149
149
}
150
150
151
151
protected static SqlParseException fail (String text , SqlParserPos pos ) {
@@ -173,30 +173,4 @@ public static Validator create(
173
173
return new Validator (SubstraitOperatorTable .INSTANCE , validatorCatalog , factory , config );
174
174
}
175
175
}
176
-
177
- /** A fully defined pre-specified table. */
178
- protected static final class DefinedTable extends AbstractTable {
179
-
180
- private final String name ;
181
- private final RelDataTypeFactory factory ;
182
- private final RelDataType type ;
183
-
184
- public DefinedTable (String name , RelDataTypeFactory factory , RelDataType type ) {
185
- this .name = name ;
186
- this .factory = factory ;
187
- this .type = type ;
188
- }
189
-
190
- @ Override
191
- public RelDataType getRowType (RelDataTypeFactory typeFactory ) {
192
- // if (factory != typeFactory) {
193
- // throw new IllegalStateException("Different type factory than previously used.");
194
- // }
195
- return type ;
196
- }
197
-
198
- public String getName () {
199
- return name ;
200
- }
201
- }
202
176
}
0 commit comments