Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: convert sql expression into proto extended expressions #191

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
333989f
feat: convert sql expression into proto extended expressions
davisusanibar Oct 24, 2023
f4b6581
fix: implement nameToNodeMap and nameToTypeMap dyamically instead of …
davisusanibar Oct 26, 2023
a79f57d
fix: cover support also for project extended expression
davisusanibar Oct 26, 2023
a37be92
fix: cover support also for project extended expression
davisusanibar Oct 27, 2023
9f6aaf3
fix: create schema dynamically
davisusanibar Nov 15, 2023
52b41e3
fix: set function reference and extensions dinamically
davisusanibar Nov 16, 2023
74d13d3
Merge branch 'main' into feature/sql_to_extended_expression
davisusanibar Nov 16, 2023
3d80d1f
fix: clean code
davisusanibar Nov 16, 2023
ae84176
Merge branch 'main' into feature/sql_to_extended_expression
davisusanibar Nov 16, 2023
5954a62
fix: clean code
davisusanibar Nov 16, 2023
fc33a32
fix: rename variables to clean code
davisusanibar Nov 17, 2023
217f2a0
fix: from/to pojo/protobuf
davisusanibar Nov 23, 2023
75e4f48
feat: enable support from/to pojo/protobuf for extended expressions
davisusanibar Nov 24, 2023
1d23187
Merge branch 'main' into feature/from_to_protobuf_pojo
davisusanibar Nov 24, 2023
5adc79f
fix: consume core module for proto/pojo conversions
davisusanibar Nov 24, 2023
940f703
fix: clean code redundant method
davisusanibar Nov 25, 2023
e281f2f
Merge branch 'main' into feature/sql_to_extended_expression
davisusanibar Nov 25, 2023
f817eb0
fix: apply suggestions from code review
davisusanibar Nov 29, 2023
b1c96bd
fix: code review core module
davisusanibar Nov 29, 2023
3d9b927
fix: code review core module testing side
davisusanibar Nov 29, 2023
e790492
feat: support aggregation function in extended expression from/to poj…
davisusanibar Dec 6, 2023
ef7c076
fix: merge from/to proto/pojo
davisusanibar Dec 6, 2023
d1b4efb
fix: merge from/to proto/pojo
davisusanibar Dec 6, 2023
c26fecd
fix: merge from/to proto/pojo + solve comments on the PR
davisusanibar Dec 6, 2023
bdde874
Merge branch 'main' into feature/sql_to_extended_expression
davisusanibar Dec 6, 2023
0fa69c8
fix: code review suggestion
davisusanibar Dec 6, 2023
92d2cc5
refactor: bind instanceof checked variables
vbarua Dec 7, 2023
379b83f
fix: adding Aggregate.Measure POJO instead of Proto
davisusanibar Dec 8, 2023
e415785
fix: simplify extended expression immutable class
davisusanibar Dec 8, 2023
c27dd37
fix: clean code
davisusanibar Dec 8, 2023
a5d8126
fix: support any kind of expression type on extended expression conve…
davisusanibar Dec 9, 2023
50602f2
fix: error scalar function test case
davisusanibar Dec 9, 2023
f57322a
Merge branch 'feature/from_to_protobuf_pojo' into feature/sql_to_exte…
davisusanibar Dec 12, 2023
1c8b8b5
fix: support any kind of expression type on extended expression conve…
davisusanibar Dec 12, 2023
c71bff1
fix: consolidate PR and resolve conflicting files
davisusanibar Dec 14, 2023
183dcb6
fix: addressing PR comments
davisusanibar Dec 19, 2023
3835a4f
docs: update SqlExpressionToSubstrait#convert docs
vbarua Dec 20, 2023
6327a17
fix: commit suggestion code
davisusanibar Jan 10, 2024
8658558
fix: addressing PR comments
davisusanibar Jan 11, 2024
ecf3133
Merge branch 'main' into feature/sql_to_extended_expression
davisusanibar Jan 11, 2024
3ff586a
fix: delete integration with arrow project
davisusanibar Jan 11, 2024
6151bca
fix: apply suggestions from code review
davisusanibar Jan 12, 2024
96a2f25
fix: addressing PR comments
davisusanibar Jan 15, 2024
579d2af
Merge branch 'main' into feature/sql_to_extended_expression
davisusanibar Jan 17, 2024
3b110f3
refactor: remove unused nation.parquet data
vbarua Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = true
[*.{yaml,yml}]
indent_size = 2

[{**/*.sql,**/OuterReferenceResolver.md,gradlew.bat}]
[{**/*.sql,**/OuterReferenceResolver.md,gradlew.bat,**/*.parquet}]
charset = unset
end_of_line = unset
insert_final_newline = unset
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.0
vbarua marked this conversation as resolved.
Show resolved Hide resolved
rev: v1.33.0
hooks:
- id: yamllint
args: [-c=.yamllint.yaml]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v8.0.0
rev: v9.9.0
hooks:
- id: commitlint
stages: [commit-msg]
3 changes: 3 additions & 0 deletions isthmus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ java {
}

var CALCITE_VERSION = "1.34.0"
var ARROW_VERSION = "14.0.0"

dependencies {
implementation(project(":core"))
Expand All @@ -94,6 +95,8 @@ dependencies {
implementation("org.immutables:value-annotations:2.8.8")
annotationProcessor("org.immutables:value:2.8.8")
testImplementation("org.apache.calcite:calcite-plus:${CALCITE_VERSION}")
testImplementation("org.apache.arrow:arrow-dataset:${ARROW_VERSION}")
testImplementation("org.apache.arrow:arrow-memory-netty:${ARROW_VERSION}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great integration test, but I think it would be better if we moved it to the Arrow repo instead of adding Arrow as a dependency to Isthmus. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let me delete that part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just deleted

annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2")
compileOnly("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2")
}
Expand Down
29 changes: 24 additions & 5 deletions isthmus/src/main/java/io/substrait/isthmus/SqlConverterBase.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.substrait.isthmus;

import com.github.bsideup.jabel.Desugar;
import io.substrait.extension.SimpleExtension;
import io.substrait.isthmus.calcite.SubstraitOperatorTable;
import io.substrait.type.NamedStruct;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
vbarua marked this conversation as resolved.
Show resolved Hide resolved
import java.util.*;
import java.util.function.Function;
import org.apache.calcite.config.CalciteConnectionConfig;
import org.apache.calcite.config.CalciteConnectionProperty;
Expand All @@ -22,7 +22,10 @@
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexInputRef;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.Table;
import org.apache.calcite.schema.impl.AbstractTable;
Expand Down Expand Up @@ -86,8 +89,9 @@ protected SqlConverterBase(FeatureBoard features) {
EXTENSION_COLLECTION = defaults;
}

Pair<SqlValidator, CalciteCatalogReader> registerCreateTables(List<String> tables)
throws SqlParseException {
Result registerCreateTables(List<String> tables) throws SqlParseException {
Map<String, RelDataType> nameToTypeMap = new LinkedHashMap<>();
Map<String, RexNode> nameToNodeMap = new HashMap<>();
CalciteSchema rootSchema = CalciteSchema.createRootSchema(false);
CalciteCatalogReader catalogReader =
new CalciteCatalogReader(rootSchema, List.of(), factory, config);
Expand All @@ -97,12 +101,27 @@ Pair<SqlValidator, CalciteCatalogReader> registerCreateTables(List<String> table
List<DefinedTable> tList = parseCreateTable(factory, validator, tableDef);
for (DefinedTable t : tList) {
rootSchema.add(t.getName(), t);
for (RelDataTypeField field : t.type.getFieldList()) {
nameToTypeMap.put(
field.getName(), field.getType()); // to validate the sql expression tree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle multiple tables containing a field with the same name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test this scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario is not supported. It will be updated with the last filed type declared. Calcite API is not offering an option to mark field per this table if it is duplicated.

  /**
   * Validates an expression tree. You can call this method multiple times,
   * but not reentrantly.
   *
   * @param topNode       top of expression tree to be validated
   * @param nameToTypeMap map of simple name to {@link RelDataType}; used to
   *                      resolve {@link SqlIdentifier} references
   * @return validated tree (possibly rewritten)
   */
  SqlNode validateParameterizedExpression(
      SqlNode topNode,
      Map<String, RelDataType> nameToTypeMap);

nameToNodeMap.put(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle multiple tables containing a field with the same name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test this scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario is not supported. It will be updated with the last filed type declared. Calcite API is not offering an option to mark field per this table if it is duplicated.

  /**
   * Converts an expression from {@link SqlNode} to {@link RexNode} format,
   * mapping identifier references to predefined expressions.
   *
   * @param node          Expression to translate
   * @param nameToNodeMap map from String to {@link RexNode}; when an
   *                      {@link SqlIdentifier} is encountered, it is used as a
   *                      key and translated to the corresponding value from
   *                      this map
   * @return Converted expression
   */
  public RexNode convertExpression(
      SqlNode node,
      Map<String, RexNode> nameToNodeMap) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Calcite can't handle this, then we should throw an exception if we try to build either of those maps with duplicate values. I think it's better to explode loudly than to have a last-write wins style validator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to check, does it work with qualified paths? Like if you have:

CREATE TABLE foo(a INT);

and you put the fully qualified identifier foo.a as the map key, can the expression a find it?

Then going further if you had

CREATE TABLE foo(a INT);
CREATE TABLE bar(a INT);

does Calcite reject the expression a as being ambiguous, but accept foo.a?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add that validation and also test the last scenario you mentioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Team,

I am trying to implement this, but I am seeing limitations on the current Calcite implementation of SQL Expressions for qualified paths. There are two issues I would like to register:

  1. Is needed to add support for qualified path at SqlNode validSQLNode = validator.validateParameterizedExpression(sqlNode, nameToTypeMap);
  2. Is also needed to support for qualified path at converter.convertExpression(validSQLNode, nameToNodeMap);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! If qualified paths aren't supported Calcite, then I don't think we should concern ourselves with them here. I think we still need to deal with ambiguous lookups, probably by rejecting them if there is no mechanism to specify one or the other with a qualified path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added a logic to handle illegal argument for ambiguous lookups and also added unit test to validate that.

field.getName(),
new RexInputRef(
field.getIndex(), field.getType())); // to convert sql expression into RexNode
}
}
}
}
return Pair.of(validator, catalogReader);
return new Result(validator, catalogReader, nameToTypeMap, nameToNodeMap);
}

@Desugar
public record Result(
vbarua marked this conversation as resolved.
Show resolved Hide resolved
SqlValidator validator,
CalciteCatalogReader catalogReader,
Map<String, RelDataType> nameToTypeMap,
Map<String, RexNode> nameToNodeMap) {}

Pair<SqlValidator, CalciteCatalogReader> registerCreateTables(
Function<List<String>, NamedStruct> tableLookup) throws SqlParseException {
Function<List<String>, Table> lookup =
Expand Down
204 changes: 199 additions & 5 deletions isthmus/src/main/java/io/substrait/isthmus/SqlToSubstrait.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
package io.substrait.isthmus;

import com.github.bsideup.jabel.Desugar;
import com.google.common.annotations.VisibleForTesting;
import io.substrait.extension.ExtensionCollector;
import io.substrait.extension.SimpleExtension;
import io.substrait.isthmus.expression.RexExpressionConverter;
import io.substrait.isthmus.expression.ScalarFunctionConverter;
import io.substrait.proto.Expression;
import io.substrait.proto.Expression.ScalarFunction;
import io.substrait.proto.ExpressionReference;
import io.substrait.proto.ExtendedExpression;
vbarua marked this conversation as resolved.
Show resolved Hide resolved
import io.substrait.proto.FunctionArgument;
import io.substrait.proto.Plan;
import io.substrait.proto.PlanRel;
import io.substrait.proto.SimpleExtensionDeclaration;
import io.substrait.proto.SimpleExtensionURI;
import io.substrait.relation.RelProtoConverter;
import io.substrait.type.NamedStruct;
import java.util.List;
import io.substrait.type.TypeCreator;
import io.substrait.type.proto.TypeProtoConverter;
import java.io.IOException;
import java.util.*;
vbarua marked this conversation as resolved.
Show resolved Hide resolved
import java.util.function.Function;
import org.apache.calcite.plan.hep.HepPlanner;
import org.apache.calcite.plan.hep.HepProgram;
import org.apache.calcite.prepare.CalciteCatalogReader;
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexCall;
import org.apache.calcite.rex.RexInputRef;
import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.parser.SqlParseException;
Expand All @@ -24,6 +43,12 @@
/** Take a SQL statement and a set of table definitions and return a substrait plan. */
public class SqlToSubstrait extends SqlConverterBase {

private final ScalarFunctionConverter functionConverter =
new ScalarFunctionConverter(EXTENSION_COLLECTION.scalarFunctions(), factory);

private final RexExpressionConverter rexExpressionConverter =
new RexExpressionConverter(functionConverter);

public SqlToSubstrait() {
this(null);
}
Expand All @@ -39,19 +64,30 @@ public Plan execute(String sql, Function<List<String>, NamedStruct> tableLookup)
}

public Plan execute(String sql, List<String> tables) throws SqlParseException {
var pair = registerCreateTables(tables);
return executeInner(sql, factory, pair.left, pair.right);
var result = registerCreateTables(tables);
return executeInner(sql, factory, result.validator(), result.catalogReader());
vbarua marked this conversation as resolved.
Show resolved Hide resolved
}

public Plan execute(String sql, String name, Schema schema) throws SqlParseException {
var pair = registerSchema(name, schema);
return executeInner(sql, factory, pair.left, pair.right);
}

public ExtendedExpression executeExpression(String expr, List<String> tables)
throws SqlParseException {
var result = registerCreateTables(tables);
return executeInnerExpression(
expr,
result.validator(),
result.catalogReader(),
result.nameToTypeMap(),
result.nameToNodeMap());
}
vbarua marked this conversation as resolved.
Show resolved Hide resolved

// Package protected for testing
List<RelRoot> sqlToRelNode(String sql, List<String> tables) throws SqlParseException {
var pair = registerCreateTables(tables);
return sqlToRelNode(sql, pair.left, pair.right);
var result = registerCreateTables(tables);
return sqlToRelNode(sql, result.validator(), result.catalogReader());
}

// Package protected for testing
Expand Down Expand Up @@ -91,6 +127,150 @@ private Plan executeInner(
return plan.build();
}

private ExtendedExpression executeInnerExpression(
String sql,
SqlValidator validator,
CalciteCatalogReader catalogReader,
Map<String, RelDataType> nameToTypeMap,
Map<String, RexNode> nameToNodeMap)
throws SqlParseException {
ExtendedExpression.Builder extendedExpressionBuilder = ExtendedExpression.newBuilder();
ExtensionCollector functionCollector = new ExtensionCollector();
RexNode rexNode = sqlToRexNode(sql, validator, catalogReader, nameToTypeMap, nameToNodeMap);
ResulTraverseRowExpression result = new TraverseRexNode().getRowExpression(rexNode);
io.substrait.proto.Type output =
TypeCreator.NULLABLE.BOOLEAN.accept(new TypeProtoConverter(functionCollector));
List<FunctionArgument> functionArgumentList = new ArrayList<>();
result
.expressionBuilderMap()
.forEach(
(k, v) -> {
functionArgumentList.add(FunctionArgument.newBuilder().setValue(v).build());
});

ScalarFunction.Builder scalarFunctionBuilder =
ScalarFunction.newBuilder()
.setFunctionReference(1) // rel_01
.setOutputType(output)
.addAllArguments(functionArgumentList);

Expression.Builder expressionBuilder =
Expression.newBuilder().setScalarFunction(scalarFunctionBuilder);

ExpressionReference.Builder expressionReferenceBuilder =
ExpressionReference.newBuilder()
.setExpression(expressionBuilder)
.addOutputNames(result.ref().getName());

extendedExpressionBuilder.addReferredExpr(0, expressionReferenceBuilder);

io.substrait.expression.Expression.ScalarFunctionInvocation func =
(io.substrait.expression.Expression.ScalarFunctionInvocation)
rexNode.accept(rexExpressionConverter);
String declaration = func.declaration().key(); // values example: gt:any_any, add:i64_i64

// this is not mandatory to be defined; it is working without this definition. It is
// only created here to create a proto message that has the correct semantics
HashMap<String, SimpleExtensionURI> extensionUris = new HashMap<>();
SimpleExtensionURI simpleExtensionURI;
try {
simpleExtensionURI =
SimpleExtensionURI.newBuilder()
.setExtensionUriAnchor(1) // rel_02
.setUri(
SimpleExtension.loadDefaults().scalarFunctions().stream()
.filter(s -> s.toString().equalsIgnoreCase(declaration))
.findFirst()
.orElseThrow(
() ->
new IllegalArgumentException(
String.format("Failed to get URI resource for %s.", declaration)))
.uri())
.build();
} catch (IOException e) {
throw new RuntimeException(e);
}
extensionUris.put("uri", simpleExtensionURI);

ArrayList<SimpleExtensionDeclaration> extensions = new ArrayList<>();
SimpleExtensionDeclaration extensionFunctionLowerThan =
SimpleExtensionDeclaration.newBuilder()
.setExtensionFunction(
SimpleExtensionDeclaration.ExtensionFunction.newBuilder()
.setFunctionAnchor(scalarFunctionBuilder.getFunctionReference()) // rel_01
.setName(declaration)
.setExtensionUriReference(simpleExtensionURI.getExtensionUriAnchor())) // rel_02
.build();
extensions.add(extensionFunctionLowerThan);

System.out.println(
"extendedExpressionBuilder.getExtensionUrisList(): "
+ extendedExpressionBuilder.getExtensionUrisList());
// adding it for semantic purposes, it is not mandatory or needed
extendedExpressionBuilder.addAllExtensionUris(extensionUris.values());
extendedExpressionBuilder.addAllExtensions(extensions);

NamedStruct namedStruct = TypeConverter.DEFAULT.toNamedStruct(nameToTypeMap);
extendedExpressionBuilder.setBaseSchema(
namedStruct.toProto(new TypeProtoConverter(functionCollector)));

return extendedExpressionBuilder.build();
}

class TraverseRexNode {
RexInputRef ref = null;
int control = 0;
Expression.Builder referenceBuilder = null;
Expression.Builder literalBuilder = null;
Map<Integer, Expression.Builder> expressionBuilderMap = new LinkedHashMap<>();

ResulTraverseRowExpression getRowExpression(RexNode rexNode) {
switch (rexNode.getClass().getSimpleName().toUpperCase()) {
case "REXCALL":
for (RexNode rexInternal : ((RexCall) rexNode).operands) {
getRowExpression(rexInternal);
}
;
break;
case "REXINPUTREF":
ref = (RexInputRef) rexNode;
referenceBuilder =
Expression.newBuilder()
.setSelection(
Expression.FieldReference.newBuilder()
.setDirectReference(
Expression.ReferenceSegment.newBuilder()
.setStructField(
Expression.ReferenceSegment.StructField.newBuilder()
.setField(ref.getIndex()))));
expressionBuilderMap.put(control, referenceBuilder);
control++;
break;
case "REXLITERAL":
RexLiteral literal = (RexLiteral) rexNode;
literalBuilder =
Expression.newBuilder()
.setLiteral(
Expression.Literal.newBuilder().setI32(literal.getValueAs(Integer.class)));
expressionBuilderMap.put(control, literalBuilder);
control++;
break;
default:
throw new AssertionError(
"Unsupported type for: " + rexNode.getClass().getSimpleName().toUpperCase());
}
return new ResulTraverseRowExpression(
ref, referenceBuilder, literalBuilder, expressionBuilderMap);
}
}

@Desugar
private record ResulTraverseRowExpression(
RexInputRef ref,
Expression.Builder referenceBuilder,
Expression.Builder literalBuilder,
Map<Integer, Expression.Builder> expressionBuilderMap) {}

private List<RelRoot> sqlToRelNode(
String sql, SqlValidator validator, CalciteCatalogReader catalogReader)
throws SqlParseException {
Expand All @@ -107,6 +287,20 @@ private List<RelRoot> sqlToRelNode(
return roots;
}

private RexNode sqlToRexNode(
String sql,
SqlValidator validator,
CalciteCatalogReader catalogReader,
Map<String, RelDataType> nameToTypeMap,
Map<String, RexNode> nameToNodeMap)
throws SqlParseException {
SqlParser parser = SqlParser.create(sql, parserConfig);
SqlNode sqlNode = parser.parseExpression();
SqlNode validSQLNode = validator.validateParameterizedExpression(sqlNode, nameToTypeMap);
SqlToRelConverter converter = createSqlToRelConverter(validator, catalogReader);
return converter.convertExpression(validSQLNode, nameToNodeMap);
}

@VisibleForTesting
SqlToRelConverter createSqlToRelConverter(
SqlValidator validator, CalciteCatalogReader catalogReader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public SubstraitToSql() {

public RelNode substraitRelToCalciteRel(Rel relRoot, List<String> tables)
throws SqlParseException {
var pair = registerCreateTables(tables);
return SubstraitRelNodeConverter.convert(relRoot, relOptCluster, pair.right, parserConfig);
var result = registerCreateTables(tables);
return SubstraitRelNodeConverter.convert(
relRoot, relOptCluster, result.catalogReader(), parserConfig);
}

public RelNode substraitRelToCalciteRel(
Expand Down
Loading