Interface InitializerContext

All Known Implementing Classes:
SqlToRelConverter.Blackboard

public interface InitializerContext
Provides context for InitializerExpressionFactory methods.
  • Method Details

    • getRexBuilder

      RexBuilder getRexBuilder()
    • parseExpression

      default SqlNode parseExpression(SqlParser.Config config, String expr)
      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 SqlNodes, 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 config
      expr - the SQL-style column expression
      Returns:
      a SqlNode instance
    • validateExpression

      SqlNode validateExpression(RelDataType rowType, SqlNode expr)
      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 type
      expr - the expression
      Returns:
      a validated SqlNode, usually it transforms from a SqlUnresolvedFunction to a resolved one
    • convertExpression

      RexNode convertExpression(SqlNode expr)
      Converts a SqlNode to RexNode.

      Caution that the SqlNode must be validated, you can use validateExpression(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.sql.SqlNode) to validate if the SqlNode is un-validated.

      Parameters:
      expr - the expression of sql node to convert
      Returns:
      a converted RexNode instance