Package org.apache.calcite.sql2rel
Interface InitializerContext
- All Known Implementing Classes:
SqlToRelConverter.Blackboard
public interface InitializerContext
Provides context for
InitializerExpressionFactory
methods.-
Method Summary
Modifier and TypeMethodDescriptionconvertExpression
(SqlNode expr) Converts aSqlNode
toRexNode
.default SqlNode
parseExpression
(SqlParser.Config config, String expr) Parses a column computation expression for a table.validateExpression
(RelDataType rowType, SqlNode expr) Validate the expression with a base table row type.
-
Method Details
-
getRexBuilder
RexBuilder getRexBuilder() -
parseExpression
Parses a column computation expression for a table.Usually this expression is declared in the
CREATE TABLE
statement, e.g.create table t( a int not null, b varchar(5) as (my_udf(a)) virtual, c int not null as (a + 1));
You can use the string format expression "my_udf(a)" and "a + 1" as the initializer expression of column b and c.
Calcite doesn't really need this now because the DDL nodes can be executed directly from
SqlNode
s, but we still provide the way to initialize from a SQL-like string, because a string can be used to persist easily and the column expressions are important part of the table metadata.- Parameters:
config
- parse configexpr
- the SQL-style column expression- Returns:
- a
SqlNode
instance
-
validateExpression
Validate the expression with a base table row type. The expression may reference the fields of the row type defines.- Parameters:
rowType
- the table row typeexpr
- the expression- Returns:
- a validated
SqlNode
, usually it transforms from aSqlUnresolvedFunction
to a resolved one
-
convertExpression
Converts aSqlNode
toRexNode
.Caution that the
SqlNode
must be validated, you can usevalidateExpression(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.sql.SqlNode)
to validate if theSqlNode
is un-validated.- Parameters:
expr
- the expression of sql node to convert- Returns:
- a converted
RexNode
instance
-