Class SqlValidatorImpl

java.lang.Object
org.apache.calcite.sql.validate.SqlValidatorImpl
All Implemented Interfaces:
org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorWithHints
Direct Known Subclasses:
FlinkCalciteSqlValidator, SqlValidatorWithSnapshot

public class SqlValidatorImpl extends Object implements org.apache.calcite.sql.validate.SqlValidatorWithHints
Default implementation of SqlValidator, the class was copied over because of CALCITE-4554.

Lines 200 ~ 203, Flink improves error message for functions without appropriate arguments in handleUnresolvedFunction.

Lines 2000 ~ 2020, Flink improves error message for functions without appropriate arguments in handleUnresolvedFunction at handleUnresolvedFunction(org.apache.calcite.sql.SqlCall, org.apache.calcite.sql.SqlOperator, java.util.List<org.apache.calcite.rel.type.RelDataType>, java.util.List<java.lang.String>).

Lines 3814 ~ 3818, 6458 ~ 6464 Flink improves Optimize the retrieval of sub-operands in SqlCall when using NamedParameters at checkRollUp(org.apache.calcite.sql.SqlNode, org.apache.calcite.sql.SqlNode, org.apache.calcite.sql.SqlNode, org.apache.calcite.sql.validate.SqlValidatorScope, java.lang.String).

Lines 5196 ~ 5209, Flink enables TIMESTAMP and TIMESTAMP_LTZ for system time period specification type at validateSnapshot(org.apache.calcite.sql.SqlNode, org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.validate.SqlValidatorNamespace).

Lines 5553 ~ 5559, Flink enables TIMESTAMP and TIMESTAMP_LTZ for first orderBy column in matchRecognize at validateMatchRecognize(org.apache.calcite.sql.SqlCall).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Common base class for DML statement namespaces.
    protected static class 
    Utility object used to maintain information about the parameters in a function call.
    protected static class 
    Information about an identifier in a particular scope.
    static enum 
    Validation status.

    Nested classes/interfaces inherited from interface org.apache.calcite.sql.validate.SqlValidator

    org.apache.calcite.sql.validate.SqlValidator.Config
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final IdentityHashMap<org.apache.calcite.sql.SqlCall,List<org.apache.calcite.rel.type.RelDataType>>
    Provides the data for getValidatedOperandTypes(SqlCall).
    Stack of objects that maintain information about function calls.
    Maps SqlParserPos strings to the SqlIdentifier identifier objects at these positions.
    protected final IdentityHashMap<org.apache.calcite.sql.SqlNode,org.apache.calcite.sql.validate.SqlValidatorNamespace>
    Maps a node to the namespace which describes what columns they contain.
    protected final IdentityHashMap<org.apache.calcite.sql.SqlNode,org.apache.calcite.sql.validate.SqlValidatorScope>
    Maps query node objects to the SqlValidatorScope scope created from them.
    protected final org.apache.calcite.rel.type.TimeFrameSet
     
    static final org.slf4j.Logger
     
    protected final org.apache.calcite.rel.type.RelDataTypeFactory
     
    protected final org.apache.calcite.rel.type.RelDataType
     
    static final String
    Alias prefix generated for source columns when rewriting UPDATE to MERGE.
    static final String
    Alias generated for the source table when rewriting UPDATE to MERGE.
    static final String
    Alias generated for the target table when rewriting UPDATE to MERGE if no alias was specified by the user.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SqlValidatorImpl(org.apache.calcite.sql.SqlOperatorTable opTab, org.apache.calcite.sql.validate.SqlValidatorCatalogReader catalogReader, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.sql.validate.SqlValidator.Config config)
    Creates a validator.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addToSelectList(List<org.apache.calcite.sql.SqlNode> list, Set<String> aliases, List<Map.Entry<String,org.apache.calcite.rel.type.RelDataType>> fieldList, org.apache.calcite.sql.SqlNode exp, org.apache.calcite.sql.validate.SelectScope scope, boolean includeSystemVars)
    Adds an expression to a select list, ensuring that its alias does not clash with any existing expressions on the list.
    protected void
    checkTypeAssignment(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope sourceScope, org.apache.calcite.sql.validate.SqlValidatorTable table, org.apache.calcite.rel.type.RelDataType sourceRowType, org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.SqlNode query)
    Checks the type assignment of an INSERT or UPDATE query.
    org.apache.calcite.sql.validate.SqlValidator.Config
     
    protected org.apache.calcite.sql.validate.MatchRecognizeNamespace
    createMatchRecognizeNameSpace(org.apache.calcite.sql.SqlMatchRecognize call, org.apache.calcite.sql.SqlNode enclosingNode)
     
    protected org.apache.calcite.sql.validate.PivotNamespace
    createPivotNameSpace(org.apache.calcite.sql.SqlPivot call, org.apache.calcite.sql.SqlNode enclosingNode)
     
    protected org.apache.calcite.sql.validate.SelectNamespace
    createSelectNamespace(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.SqlNode enclosingNode)
    Creates a namespace for a SELECT node.
    protected org.apache.calcite.sql.validate.SetopNamespace
    createSetopNamespace(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.SqlNode enclosingNode)
    Creates a namespace for a set operation (UNION, INTERSECT, or EXCEPT).
    protected org.apache.calcite.sql.SqlSelect
    createSourceSelectForDelete(org.apache.calcite.sql.SqlDelete call)
    Creates the SELECT statement that putatively feeds rows into a DELETE statement to be deleted.
    protected org.apache.calcite.sql.SqlSelect
    createSourceSelectForUpdate(org.apache.calcite.sql.SqlUpdate call)
    Creates the SELECT statement that putatively feeds rows into an UPDATE statement to be updated.
    protected org.apache.calcite.rel.type.RelDataType
    createTargetRowType(org.apache.calcite.sql.validate.SqlValidatorTable table, @Nullable org.apache.calcite.sql.SqlNodeList targetColumnList, boolean append)
    Derives a row-type for INSERT and UPDATE operations.
    protected org.apache.calcite.sql.validate.UnpivotNamespace
    createUnpivotNameSpace(org.apache.calcite.sql.SqlUnpivot call, org.apache.calcite.sql.SqlNode enclosingNode)
     
    void
    declareCursor(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.validate.SqlValidatorScope parentScope)
     
    @Nullable String
    deriveAlias(org.apache.calcite.sql.SqlNode node, int ordinal)
     
    org.apache.calcite.rel.type.RelDataType
    deriveConstructorType(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.SqlFunction unresolvedConstructor, @Nullable org.apache.calcite.sql.SqlFunction resolvedConstructor, List<org.apache.calcite.rel.type.RelDataType> argTypes)
     
    org.apache.calcite.rel.type.RelDataType
    deriveType(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlNode expr)
     
    org.apache.calcite.sql.SqlNode
    expand(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    org.apache.calcite.sql.SqlNode
    expandOrderExpr(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.SqlNode orderExpr)
     
    org.apache.calcite.sql.SqlNode
    expandSelectExpr(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.validate.SelectScope scope, org.apache.calcite.sql.SqlSelect select)
     
    org.apache.calcite.sql.SqlNodeList
    expandStar(org.apache.calcite.sql.SqlNodeList selectList, org.apache.calcite.sql.SqlSelect select, boolean includeSystemVars)
     
    org.apache.calcite.sql.SqlNode
    extendedExpandGroupBy(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlSelect select)
     
    protected @Nullable org.apache.calcite.sql.SqlNode
    getAggregate(org.apache.calcite.sql.SqlSelect select)
    Returns the parse tree node (GROUP BY, HAVING, or an aggregate function call) that causes select to be an aggregate query, or null if it is not an aggregate query.
    org.apache.calcite.sql.validate.SqlValidatorCatalogReader
     
    org.apache.calcite.sql.validate.SqlConformance
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getCursorScope(org.apache.calcite.sql.SqlSelect select)
     
    org.apache.calcite.sql.validate.SqlValidatorScope
     
    List<@Nullable List<String>>
    getFieldOrigins(org.apache.calcite.sql.SqlNode sqlQuery)
     
    @Nullable org.apache.calcite.sql.validate.SqlValidatorScope
    getFromScope(org.apache.calcite.sql.SqlSelect select)
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getGroupScope(org.apache.calcite.sql.SqlSelect select)
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getHavingScope(org.apache.calcite.sql.SqlSelect select)
     
    @Nullable org.apache.calcite.sql.validate.SqlValidatorScope
    getJoinScope(org.apache.calcite.sql.SqlNode node)
     
    protected org.apache.calcite.rel.type.RelDataType
    getLogicalSourceRowType(org.apache.calcite.rel.type.RelDataType sourceRowType, org.apache.calcite.sql.SqlInsert insert)
     
    protected org.apache.calcite.rel.type.RelDataType
    getLogicalTargetRowType(org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.SqlInsert insert)
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getMatchRecognizeScope(org.apache.calcite.sql.SqlMatchRecognize node)
     
    @Nullable org.apache.calcite.sql.validate.SqlValidatorNamespace
    getNamespace(org.apache.calcite.sql.SqlNode node)
     
    org.apache.calcite.sql.SqlOperatorTable
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getOrderScope(org.apache.calcite.sql.SqlSelect select)
     
    org.apache.calcite.sql.SqlNode
    getOriginal(org.apache.calcite.sql.SqlNode expr)
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getOverScope(org.apache.calcite.sql.SqlNode node)
     
    org.apache.calcite.rel.type.RelDataType
    getParameterRowType(org.apache.calcite.sql.SqlNode sqlQuery)
     
    @Nullable String
    getParentCursor(String columnListParamName)
     
    @Nullable org.apache.calcite.sql.validate.SelectScope
    getRawSelectScope(org.apache.calcite.sql.SqlSelect select)
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getSelectScope(org.apache.calcite.sql.SqlSelect select)
     
    protected @Nullable org.apache.calcite.sql.SqlNode
    getSelfJoinExprForUpdate(org.apache.calcite.sql.SqlNode table, String alias)
    Allows a subclass to provide information about how to convert an UPDATE into a MERGE via self-join.
    org.apache.calcite.rel.type.TimeFrameSet
     
    org.apache.calcite.sql.validate.implicit.TypeCoercion
     
    org.apache.calcite.rel.type.RelDataTypeFactory
     
    org.apache.calcite.rel.type.RelDataType
     
    org.apache.calcite.rel.type.RelDataType
    getValidatedNodeType(org.apache.calcite.sql.SqlNode node)
     
    @Nullable org.apache.calcite.rel.type.RelDataType
    getValidatedNodeTypeIfKnown(org.apache.calcite.sql.SqlNode node)
     
    @Nullable List<org.apache.calcite.rel.type.RelDataType>
    getValidatedOperandTypes(org.apache.calcite.sql.SqlCall call)
     
    org.apache.calcite.sql.validate.SqlValidatorImpl.ValidationErrorFunction
     
    org.apache.calcite.sql.validate.SqlValidatorScope
    getWhereScope(org.apache.calcite.sql.SqlSelect select)
     
    protected org.apache.calcite.sql.SqlWindow
    getWindowByName(org.apache.calcite.sql.SqlIdentifier id, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    @Nullable org.apache.calcite.sql.validate.SqlValidatorScope
    getWithScope(org.apache.calcite.sql.SqlNode withItem)
     
    org.apache.calcite.runtime.CalciteException
    handleUnresolvedFunction(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.SqlOperator unresolvedFunction, List<org.apache.calcite.rel.type.RelDataType> argTypes, @Nullable List<String> argNames)
     
    protected void
    inferUnknownTypes(org.apache.calcite.rel.type.RelDataType inferredType, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlNode node)
     
    boolean
    isAggregate(org.apache.calcite.sql.SqlNode selectNode)
    Deprecated.
    boolean
    isAggregate(org.apache.calcite.sql.SqlSelect select)
     
    protected boolean
    isNestedAggregateWindow(org.apache.calcite.sql.SqlNode node)
     
    protected boolean
    isOverAggregateWindow(org.apache.calcite.sql.SqlNode node)
     
    boolean
    isSystemField(org.apache.calcite.rel.type.RelDataTypeField field)
     
    List<org.apache.calcite.sql.validate.SqlMoniker>
    lookupHints(org.apache.calcite.sql.SqlNode topNode, org.apache.calcite.sql.parser.SqlParserPos pos)
     
    final void
    lookupNameCompletionHints(org.apache.calcite.sql.validate.SqlValidatorScope scope, List<String> names, org.apache.calcite.sql.parser.SqlParserPos pos, Collection<org.apache.calcite.sql.validate.SqlMoniker> hintList)
    Populates a list of all the valid alternatives for an identifier.
    @Nullable org.apache.calcite.sql.validate.SqlMoniker
    lookupQualifiedName(org.apache.calcite.sql.SqlNode topNode, org.apache.calcite.sql.parser.SqlParserPos pos)
     
    @Nullable org.apache.calcite.sql.SqlCall
    makeNullaryCall(org.apache.calcite.sql.SqlIdentifier id)
     
    org.apache.calcite.runtime.CalciteContextException
    newValidationError(org.apache.calcite.sql.SqlNode node, org.apache.calcite.runtime.Resources.ExInst<org.apache.calcite.sql.validate.SqlValidatorException> e)
     
    protected @PolyNull org.apache.calcite.sql.SqlNode
    performUnconditionalRewrites(@PolyNull org.apache.calcite.sql.SqlNode node, boolean underFrom)
    Performs expression rewrites which are always used unconditionally.
    void
     
    void
     
    protected void
    registerNamespace(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope usingScope, @Nullable String alias, org.apache.calcite.sql.validate.SqlValidatorNamespace ns, boolean forceNullable)
    Registers a new namespace, and adds it as a child of its parent scope.
    void
    removeValidatedNodeType(org.apache.calcite.sql.SqlNode node)
     
    org.apache.calcite.sql.SqlLiteral
    resolveLiteral(org.apache.calcite.sql.SqlLiteral literal)
     
    org.apache.calcite.sql.SqlWindow
    resolveWindow(org.apache.calcite.sql.SqlNode windowOrRef, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    void
    setOriginal(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.SqlNode original)
     
    final void
    setValidatedNodeType(org.apache.calcite.sql.SqlNode node, org.apache.calcite.rel.type.RelDataType type)
    Saves the type of a SqlNode, now that it has been validated.
    protected boolean
     
    protected boolean
     
    org.apache.calcite.sql.validate.SqlValidator
    transform(UnaryOperator<org.apache.calcite.sql.validate.SqlValidator.Config> transform)
     
    @Nullable List<String>
    usingNames(org.apache.calcite.sql.SqlJoin join)
    Returns the set of field names in the join condition specified by USING or implicitly by NATURAL, de-duplicated and in order.
    org.apache.calcite.sql.SqlNode
    validate(org.apache.calcite.sql.SqlNode topNode)
     
    void
    validateAggregateParams(org.apache.calcite.sql.SqlCall aggCall, @Nullable org.apache.calcite.sql.SqlNode filter, @Nullable org.apache.calcite.sql.SqlNodeList distinctList, @Nullable org.apache.calcite.sql.SqlNodeList orderList, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    void
    validateCall(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    void
    validateColumnListParams(org.apache.calcite.sql.SqlFunction function, List<org.apache.calcite.rel.type.RelDataType> argTypes, List<org.apache.calcite.sql.SqlNode> operands)
     
    void
    validateDataType(org.apache.calcite.sql.SqlDataTypeSpec dataType)
     
    void
    validateDelete(org.apache.calcite.sql.SqlDelete call)
     
    void
    validateDynamicParam(org.apache.calcite.sql.SqlDynamicParam dynamicParam)
     
    protected void
    validateFeature(org.apache.calcite.runtime.Feature feature, org.apache.calcite.sql.parser.SqlParserPos context)
    Validates that a particular feature is enabled.
    protected void
    validateFrom(org.apache.calcite.sql.SqlNode node, org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.validate.SqlValidatorScope scope)
    Validates the FROM clause of a query, or (recursively) a child node of the FROM clause: AS, OVER, JOIN, VALUES, or sub-query.
    protected void
    validateGroupClause(org.apache.calcite.sql.SqlSelect select)
    Validates the GROUP BY clause of a SELECT statement.
    protected void
    validateHavingClause(org.apache.calcite.sql.SqlSelect select)
     
    void
    validateIdentifier(org.apache.calcite.sql.SqlIdentifier id, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    void
    validateInsert(org.apache.calcite.sql.SqlInsert insert)
     
    void
    validateIntervalQualifier(org.apache.calcite.sql.SqlIntervalQualifier qualifier)
     
    protected void
    validateJoin(org.apache.calcite.sql.SqlJoin join, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    void
    validateLiteral(org.apache.calcite.sql.SqlLiteral literal)
     
    void
    validateMatchRecognize(org.apache.calcite.sql.SqlCall call)
     
    void
    validateMerge(org.apache.calcite.sql.SqlMerge call)
     
    boolean
    validateModality(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.validate.SqlModality modality, boolean fail)
     
    protected void
    validateNamespace(org.apache.calcite.sql.validate.SqlValidatorNamespace namespace, org.apache.calcite.rel.type.RelDataType targetRowType)
    Validates a namespace.
    protected void
    validateOrderList(org.apache.calcite.sql.SqlSelect select)
    Validates the ORDER BY clause of a SELECT statement.
    protected void
    validateOver(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    org.apache.calcite.sql.SqlNode
    validateParameterizedExpression(org.apache.calcite.sql.SqlNode topNode, Map<String,org.apache.calcite.rel.type.RelDataType> nameToTypeMap)
     
    void
    validatePivot(org.apache.calcite.sql.SqlPivot pivot)
     
    protected void
    validateQualifyClause(org.apache.calcite.sql.SqlSelect select)
     
    void
    validateQuery(org.apache.calcite.sql.SqlNode node, @Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.rel.type.RelDataType targetRowType)
     
    protected void
    validateSelect(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.rel.type.RelDataType targetRowType)
    Validates a SELECT statement.
    protected org.apache.calcite.rel.type.RelDataType
    validateSelectList(org.apache.calcite.sql.SqlNodeList selectItems, org.apache.calcite.sql.SqlSelect select, org.apache.calcite.rel.type.RelDataType targetRowType)
     
    void
    validateSequenceValue(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlIdentifier id)
     
    protected void
    validateTableFunction(org.apache.calcite.sql.SqlCall node, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.rel.type.RelDataType targetRowType)
     
    org.apache.calcite.rel.type.TimeFrame
    validateTimeFrame(org.apache.calcite.sql.SqlIntervalQualifier qualifier)
     
    protected void
    validateUnnest(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.rel.type.RelDataType targetRowType)
     
    void
    validateUnpivot(org.apache.calcite.sql.SqlUnpivot unpivot)
     
    void
    validateUpdate(org.apache.calcite.sql.SqlUpdate call)
     
    protected void
    validateValues(org.apache.calcite.sql.SqlCall node, org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.validate.SqlValidatorScope scope)
    Validates a VALUES clause.
    protected void
    validateWhereClause(org.apache.calcite.sql.SqlSelect select)
     
    protected void
    validateWhereOrOn(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlNode condition, String clause)
     
    void
    validateWindow(org.apache.calcite.sql.SqlNode windowOrId, org.apache.calcite.sql.validate.SqlValidatorScope scope, @Nullable org.apache.calcite.sql.SqlCall call)
     
    protected void
    validateWindowClause(org.apache.calcite.sql.SqlSelect select)
     
    void
    validateWith(org.apache.calcite.sql.SqlWith with, org.apache.calcite.sql.validate.SqlValidatorScope scope)
     
    void
    validateWithItem(org.apache.calcite.sql.SqlWithItem withItem)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.calcite.sql.validate.SqlValidator

    resolveWindow
  • Field Details

    • TRACER

      public static final org.slf4j.Logger TRACER
    • UPDATE_SRC_ALIAS

      public static final String UPDATE_SRC_ALIAS
      Alias generated for the source table when rewriting UPDATE to MERGE.
      See Also:
    • UPDATE_TGT_ALIAS

      public static final String UPDATE_TGT_ALIAS
      Alias generated for the target table when rewriting UPDATE to MERGE if no alias was specified by the user.
      See Also:
    • UPDATE_ANON_PREFIX

      public static final String UPDATE_ANON_PREFIX
      Alias prefix generated for source columns when rewriting UPDATE to MERGE.
      See Also:
    • idPositions

      protected final Map<String,SqlValidatorImpl.IdInfo> idPositions
      Maps SqlParserPos strings to the SqlIdentifier identifier objects at these positions.
    • scopes

      protected final IdentityHashMap<org.apache.calcite.sql.SqlNode,org.apache.calcite.sql.validate.SqlValidatorScope> scopes
      Maps query node objects to the SqlValidatorScope scope created from them.
    • namespaces

      protected final IdentityHashMap<org.apache.calcite.sql.SqlNode,org.apache.calcite.sql.validate.SqlValidatorNamespace> namespaces
      Maps a node to the namespace which describes what columns they contain.
    • functionCallStack

      protected final Deque<SqlValidatorImpl.FunctionParamInfo> functionCallStack
      Stack of objects that maintain information about function calls. A stack is needed to handle nested function calls. The function call currently being validated is at the top of the stack.
    • typeFactory

      protected final org.apache.calcite.rel.type.RelDataTypeFactory typeFactory
    • unknownType

      protected final org.apache.calcite.rel.type.RelDataType unknownType
    • timeFrameSet

      protected final org.apache.calcite.rel.type.TimeFrameSet timeFrameSet
    • callToOperandTypesMap

      public final IdentityHashMap<org.apache.calcite.sql.SqlCall,List<org.apache.calcite.rel.type.RelDataType>> callToOperandTypesMap
      Provides the data for getValidatedOperandTypes(SqlCall).
  • Constructor Details

    • SqlValidatorImpl

      protected SqlValidatorImpl(org.apache.calcite.sql.SqlOperatorTable opTab, org.apache.calcite.sql.validate.SqlValidatorCatalogReader catalogReader, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.sql.validate.SqlValidator.Config config)
      Creates a validator.
      Parameters:
      opTab - Operator table
      catalogReader - Catalog reader
      typeFactory - Type factory
      config - Config
  • Method Details

    • getConformance

      public org.apache.calcite.sql.validate.SqlConformance getConformance()
    • getCatalogReader

      @Pure public org.apache.calcite.sql.validate.SqlValidatorCatalogReader getCatalogReader()
      Specified by:
      getCatalogReader in interface org.apache.calcite.sql.validate.SqlValidator
    • getOperatorTable

      @Pure public org.apache.calcite.sql.SqlOperatorTable getOperatorTable()
      Specified by:
      getOperatorTable in interface org.apache.calcite.sql.validate.SqlValidator
    • getTypeFactory

      @Pure public org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()
      Specified by:
      getTypeFactory in interface org.apache.calcite.sql.validate.SqlValidator
    • getUnknownType

      public org.apache.calcite.rel.type.RelDataType getUnknownType()
      Specified by:
      getUnknownType in interface org.apache.calcite.sql.validate.SqlValidator
    • getTimeFrameSet

      public org.apache.calcite.rel.type.TimeFrameSet getTimeFrameSet()
      Specified by:
      getTimeFrameSet in interface org.apache.calcite.sql.validate.SqlValidator
    • expandStar

      public org.apache.calcite.sql.SqlNodeList expandStar(org.apache.calcite.sql.SqlNodeList selectList, org.apache.calcite.sql.SqlSelect select, boolean includeSystemVars)
      Specified by:
      expandStar in interface org.apache.calcite.sql.validate.SqlValidator
    • declareCursor

      public void declareCursor(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.validate.SqlValidatorScope parentScope)
      Specified by:
      declareCursor in interface org.apache.calcite.sql.validate.SqlValidator
    • pushFunctionCall

      public void pushFunctionCall()
      Specified by:
      pushFunctionCall in interface org.apache.calcite.sql.validate.SqlValidator
    • popFunctionCall

      public void popFunctionCall()
      Specified by:
      popFunctionCall in interface org.apache.calcite.sql.validate.SqlValidator
    • getParentCursor

      public @Nullable String getParentCursor(String columnListParamName)
      Specified by:
      getParentCursor in interface org.apache.calcite.sql.validate.SqlValidator
    • usingNames

      public @Nullable List<String> usingNames(org.apache.calcite.sql.SqlJoin join)
      Returns the set of field names in the join condition specified by USING or implicitly by NATURAL, de-duplicated and in order.
    • validate

      public org.apache.calcite.sql.SqlNode validate(org.apache.calcite.sql.SqlNode topNode)
      Specified by:
      validate in interface org.apache.calcite.sql.validate.SqlValidator
    • lookupHints

      public List<org.apache.calcite.sql.validate.SqlMoniker> lookupHints(org.apache.calcite.sql.SqlNode topNode, org.apache.calcite.sql.parser.SqlParserPos pos)
      Specified by:
      lookupHints in interface org.apache.calcite.sql.validate.SqlValidatorWithHints
    • lookupQualifiedName

      public @Nullable org.apache.calcite.sql.validate.SqlMoniker lookupQualifiedName(org.apache.calcite.sql.SqlNode topNode, org.apache.calcite.sql.parser.SqlParserPos pos)
      Specified by:
      lookupQualifiedName in interface org.apache.calcite.sql.validate.SqlValidatorWithHints
    • lookupNameCompletionHints

      public final void lookupNameCompletionHints(org.apache.calcite.sql.validate.SqlValidatorScope scope, List<String> names, org.apache.calcite.sql.parser.SqlParserPos pos, Collection<org.apache.calcite.sql.validate.SqlMoniker> hintList)
      Populates a list of all the valid alternatives for an identifier.
      Parameters:
      scope - Validation scope
      names - Components of the identifier
      pos - position
      hintList - a list of valid options
    • validateParameterizedExpression

      public org.apache.calcite.sql.SqlNode validateParameterizedExpression(org.apache.calcite.sql.SqlNode topNode, Map<String,org.apache.calcite.rel.type.RelDataType> nameToTypeMap)
      Specified by:
      validateParameterizedExpression in interface org.apache.calcite.sql.validate.SqlValidator
    • validateQuery

      public void validateQuery(org.apache.calcite.sql.SqlNode node, @Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.rel.type.RelDataType targetRowType)
      Specified by:
      validateQuery in interface org.apache.calcite.sql.validate.SqlValidator
    • validateNamespace

      protected void validateNamespace(org.apache.calcite.sql.validate.SqlValidatorNamespace namespace, org.apache.calcite.rel.type.RelDataType targetRowType)
      Validates a namespace.
      Parameters:
      namespace - Namespace
      targetRowType - Desired row type, must not be null, may be the data type 'unknown'.
    • getEmptyScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getEmptyScope()
    • getCursorScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getCursorScope(org.apache.calcite.sql.SqlSelect select)
    • getWhereScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getWhereScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getWhereScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getSelectScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getSelectScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getSelectScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getRawSelectScope

      public @Nullable org.apache.calcite.sql.validate.SelectScope getRawSelectScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getRawSelectScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getHavingScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getHavingScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getHavingScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getGroupScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getGroupScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getGroupScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getFromScope

      public @Nullable org.apache.calcite.sql.validate.SqlValidatorScope getFromScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getFromScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getOrderScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getOrderScope(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      getOrderScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getMatchRecognizeScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getMatchRecognizeScope(org.apache.calcite.sql.SqlMatchRecognize node)
      Specified by:
      getMatchRecognizeScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getJoinScope

      public @Nullable org.apache.calcite.sql.validate.SqlValidatorScope getJoinScope(org.apache.calcite.sql.SqlNode node)
      Specified by:
      getJoinScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getOverScope

      public org.apache.calcite.sql.validate.SqlValidatorScope getOverScope(org.apache.calcite.sql.SqlNode node)
      Specified by:
      getOverScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getNamespace

      public @Nullable org.apache.calcite.sql.validate.SqlValidatorNamespace getNamespace(org.apache.calcite.sql.SqlNode node)
      Specified by:
      getNamespace in interface org.apache.calcite.sql.validate.SqlValidator
    • performUnconditionalRewrites

      protected @PolyNull org.apache.calcite.sql.SqlNode performUnconditionalRewrites(@PolyNull org.apache.calcite.sql.SqlNode node, boolean underFrom)
      Performs expression rewrites which are always used unconditionally. These rewrites massage the expression tree into a standard form so that the rest of the validation logic can be simpler.

      Returns null if and only if the original expression is null.

      Parameters:
      node - expression to be rewritten
      underFrom - whether node appears directly under a FROM clause
      Returns:
      rewritten expression, or null if the original expression is null
    • getSelfJoinExprForUpdate

      protected @Nullable org.apache.calcite.sql.SqlNode getSelfJoinExprForUpdate(org.apache.calcite.sql.SqlNode table, String alias)
      Allows a subclass to provide information about how to convert an UPDATE into a MERGE via self-join. If this method returns null, then no such conversion takes place. Otherwise, this method should return a suitable unique identifier expression for the given table.
      Parameters:
      table - identifier for table being updated
      alias - alias to use for qualifying columns in expression, or null for unqualified references; if this is equal to "SYS$SRC", then column references have been anonymized to "SYS$ANONx", where x is the 1-based column number.
      Returns:
      expression for unique identifier, or null to prevent conversion
    • createSourceSelectForUpdate

      protected org.apache.calcite.sql.SqlSelect createSourceSelectForUpdate(org.apache.calcite.sql.SqlUpdate call)
      Creates the SELECT statement that putatively feeds rows into an UPDATE statement to be updated.
      Parameters:
      call - Call to the UPDATE operator
      Returns:
      select statement
    • createSourceSelectForDelete

      protected org.apache.calcite.sql.SqlSelect createSourceSelectForDelete(org.apache.calcite.sql.SqlDelete call)
      Creates the SELECT statement that putatively feeds rows into a DELETE statement to be deleted.
      Parameters:
      call - Call to the DELETE operator
      Returns:
      select statement
    • getValidatedNodeType

      public org.apache.calcite.rel.type.RelDataType getValidatedNodeType(org.apache.calcite.sql.SqlNode node)
      Specified by:
      getValidatedNodeType in interface org.apache.calcite.sql.validate.SqlValidator
    • getValidatedNodeTypeIfKnown

      public @Nullable org.apache.calcite.rel.type.RelDataType getValidatedNodeTypeIfKnown(org.apache.calcite.sql.SqlNode node)
      Specified by:
      getValidatedNodeTypeIfKnown in interface org.apache.calcite.sql.validate.SqlValidator
    • getValidatedOperandTypes

      public @Nullable List<org.apache.calcite.rel.type.RelDataType> getValidatedOperandTypes(org.apache.calcite.sql.SqlCall call)
      Specified by:
      getValidatedOperandTypes in interface org.apache.calcite.sql.validate.SqlValidator
    • setValidatedNodeType

      public final void setValidatedNodeType(org.apache.calcite.sql.SqlNode node, org.apache.calcite.rel.type.RelDataType type)
      Saves the type of a SqlNode, now that it has been validated.

      Unlike the base class method, this method is not deprecated. It is available from within Calcite, but is not part of the public API.

      Specified by:
      setValidatedNodeType in interface org.apache.calcite.sql.validate.SqlValidator
      Parameters:
      node - A SQL parse tree node, never null
      type - Its type; must not be null
    • removeValidatedNodeType

      public void removeValidatedNodeType(org.apache.calcite.sql.SqlNode node)
      Specified by:
      removeValidatedNodeType in interface org.apache.calcite.sql.validate.SqlValidator
    • makeNullaryCall

      public @Nullable org.apache.calcite.sql.SqlCall makeNullaryCall(org.apache.calcite.sql.SqlIdentifier id)
      Specified by:
      makeNullaryCall in interface org.apache.calcite.sql.validate.SqlValidator
    • deriveType

      public org.apache.calcite.rel.type.RelDataType deriveType(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlNode expr)
      Specified by:
      deriveType in interface org.apache.calcite.sql.validate.SqlValidator
    • deriveConstructorType

      public org.apache.calcite.rel.type.RelDataType deriveConstructorType(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.SqlFunction unresolvedConstructor, @Nullable org.apache.calcite.sql.SqlFunction resolvedConstructor, List<org.apache.calcite.rel.type.RelDataType> argTypes)
      Specified by:
      deriveConstructorType in interface org.apache.calcite.sql.validate.SqlValidator
    • handleUnresolvedFunction

      public org.apache.calcite.runtime.CalciteException handleUnresolvedFunction(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.SqlOperator unresolvedFunction, List<org.apache.calcite.rel.type.RelDataType> argTypes, @Nullable List<String> argNames)
      Specified by:
      handleUnresolvedFunction in interface org.apache.calcite.sql.validate.SqlValidator
    • inferUnknownTypes

      protected void inferUnknownTypes(org.apache.calcite.rel.type.RelDataType inferredType, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlNode node)
    • addToSelectList

      protected void addToSelectList(List<org.apache.calcite.sql.SqlNode> list, Set<String> aliases, List<Map.Entry<String,org.apache.calcite.rel.type.RelDataType>> fieldList, org.apache.calcite.sql.SqlNode exp, org.apache.calcite.sql.validate.SelectScope scope, boolean includeSystemVars)
      Adds an expression to a select list, ensuring that its alias does not clash with any existing expressions on the list.
    • deriveAlias

      public @Nullable String deriveAlias(org.apache.calcite.sql.SqlNode node, int ordinal)
      Specified by:
      deriveAlias in interface org.apache.calcite.sql.validate.SqlValidator
    • shouldAllowIntermediateOrderBy

      protected boolean shouldAllowIntermediateOrderBy()
    • createMatchRecognizeNameSpace

      protected org.apache.calcite.sql.validate.MatchRecognizeNamespace createMatchRecognizeNameSpace(org.apache.calcite.sql.SqlMatchRecognize call, org.apache.calcite.sql.SqlNode enclosingNode)
    • createPivotNameSpace

      protected org.apache.calcite.sql.validate.PivotNamespace createPivotNameSpace(org.apache.calcite.sql.SqlPivot call, org.apache.calcite.sql.SqlNode enclosingNode)
    • createUnpivotNameSpace

      protected org.apache.calcite.sql.validate.UnpivotNamespace createUnpivotNameSpace(org.apache.calcite.sql.SqlUnpivot call, org.apache.calcite.sql.SqlNode enclosingNode)
    • registerNamespace

      protected void registerNamespace(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope usingScope, @Nullable String alias, org.apache.calcite.sql.validate.SqlValidatorNamespace ns, boolean forceNullable)
      Registers a new namespace, and adds it as a child of its parent scope. Derived class can override this method to tinker with namespaces as they are created.
      Parameters:
      usingScope - Parent scope (which will want to look for things in this namespace)
      alias - Alias by which parent will refer to this namespace
      ns - Namespace
      forceNullable - Whether to force the type of namespace to be nullable
    • shouldAllowOverRelation

      protected boolean shouldAllowOverRelation()
    • createSelectNamespace

      protected org.apache.calcite.sql.validate.SelectNamespace createSelectNamespace(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.SqlNode enclosingNode)
      Creates a namespace for a SELECT node. Derived class may override this factory method.
      Parameters:
      select - Select node
      enclosingNode - Enclosing node
      Returns:
      Select namespace
    • createSetopNamespace

      protected org.apache.calcite.sql.validate.SetopNamespace createSetopNamespace(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.SqlNode enclosingNode)
      Creates a namespace for a set operation (UNION, INTERSECT, or EXCEPT). Derived class may override this factory method.
      Parameters:
      call - Call to set operation
      enclosingNode - Enclosing node
      Returns:
      Set operation namespace
    • isAggregate

      public boolean isAggregate(org.apache.calcite.sql.SqlSelect select)
      Specified by:
      isAggregate in interface org.apache.calcite.sql.validate.SqlValidator
    • isNestedAggregateWindow

      protected boolean isNestedAggregateWindow(org.apache.calcite.sql.SqlNode node)
    • isOverAggregateWindow

      protected boolean isOverAggregateWindow(org.apache.calcite.sql.SqlNode node)
    • getAggregate

      protected @Nullable org.apache.calcite.sql.SqlNode getAggregate(org.apache.calcite.sql.SqlSelect select)
      Returns the parse tree node (GROUP BY, HAVING, or an aggregate function call) that causes select to be an aggregate query, or null if it is not an aggregate query.

      The node is useful context for error messages, but you cannot assume that the node is the only aggregate function.

    • isAggregate

      @Deprecated public boolean isAggregate(org.apache.calcite.sql.SqlNode selectNode)
      Deprecated.
      Specified by:
      isAggregate in interface org.apache.calcite.sql.validate.SqlValidator
    • validateIdentifier

      public void validateIdentifier(org.apache.calcite.sql.SqlIdentifier id, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Specified by:
      validateIdentifier in interface org.apache.calcite.sql.validate.SqlValidator
    • validateLiteral

      public void validateLiteral(org.apache.calcite.sql.SqlLiteral literal)
      Specified by:
      validateLiteral in interface org.apache.calcite.sql.validate.SqlValidator
    • validateIntervalQualifier

      public void validateIntervalQualifier(org.apache.calcite.sql.SqlIntervalQualifier qualifier)
      Specified by:
      validateIntervalQualifier in interface org.apache.calcite.sql.validate.SqlValidator
    • validateTimeFrame

      public org.apache.calcite.rel.type.TimeFrame validateTimeFrame(org.apache.calcite.sql.SqlIntervalQualifier qualifier)
      Specified by:
      validateTimeFrame in interface org.apache.calcite.sql.validate.SqlValidator
    • validateFrom

      protected void validateFrom(org.apache.calcite.sql.SqlNode node, org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Validates the FROM clause of a query, or (recursively) a child node of the FROM clause: AS, OVER, JOIN, VALUES, or sub-query.
      Parameters:
      node - Node in FROM clause, typically a table or derived table
      targetRowType - Desired row type of this expression, or unknownType if not fussy. Must not be null.
      scope - Scope
    • validateTableFunction

      protected void validateTableFunction(org.apache.calcite.sql.SqlCall node, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.rel.type.RelDataType targetRowType)
    • validateOver

      protected void validateOver(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.validate.SqlValidatorScope scope)
    • validateUnnest

      protected void validateUnnest(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.rel.type.RelDataType targetRowType)
    • validateJoin

      protected void validateJoin(org.apache.calcite.sql.SqlJoin join, org.apache.calcite.sql.validate.SqlValidatorScope scope)
    • validateSelect

      protected void validateSelect(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.rel.type.RelDataType targetRowType)
      Validates a SELECT statement.
      Parameters:
      select - Select statement
      targetRowType - Desired row type, must not be null, may be the data type 'unknown'.
    • validateModality

      public boolean validateModality(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.validate.SqlModality modality, boolean fail)
      Specified by:
      validateModality in interface org.apache.calcite.sql.validate.SqlValidator
    • validateWindowClause

      protected void validateWindowClause(org.apache.calcite.sql.SqlSelect select)
    • validateQualifyClause

      protected void validateQualifyClause(org.apache.calcite.sql.SqlSelect select)
    • validateWith

      public void validateWith(org.apache.calcite.sql.SqlWith with, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Specified by:
      validateWith in interface org.apache.calcite.sql.validate.SqlValidator
    • validateWithItem

      public void validateWithItem(org.apache.calcite.sql.SqlWithItem withItem)
      Specified by:
      validateWithItem in interface org.apache.calcite.sql.validate.SqlValidator
    • validateSequenceValue

      public void validateSequenceValue(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlIdentifier id)
      Specified by:
      validateSequenceValue in interface org.apache.calcite.sql.validate.SqlValidator
    • getWithScope

      public @Nullable org.apache.calcite.sql.validate.SqlValidatorScope getWithScope(org.apache.calcite.sql.SqlNode withItem)
      Specified by:
      getWithScope in interface org.apache.calcite.sql.validate.SqlValidator
    • getTypeCoercion

      public org.apache.calcite.sql.validate.implicit.TypeCoercion getTypeCoercion()
      Specified by:
      getTypeCoercion in interface org.apache.calcite.sql.validate.SqlValidator
    • config

      public org.apache.calcite.sql.validate.SqlValidator.Config config()
      Specified by:
      config in interface org.apache.calcite.sql.validate.SqlValidator
    • transform

      public org.apache.calcite.sql.validate.SqlValidator transform(UnaryOperator<org.apache.calcite.sql.validate.SqlValidator.Config> transform)
      Specified by:
      transform in interface org.apache.calcite.sql.validate.SqlValidator
    • validateOrderList

      protected void validateOrderList(org.apache.calcite.sql.SqlSelect select)
      Validates the ORDER BY clause of a SELECT statement.
      Parameters:
      select - Select statement
    • expandOrderExpr

      public org.apache.calcite.sql.SqlNode expandOrderExpr(org.apache.calcite.sql.SqlSelect select, org.apache.calcite.sql.SqlNode orderExpr)
      Specified by:
      expandOrderExpr in interface org.apache.calcite.sql.validate.SqlValidator
    • validateGroupClause

      protected void validateGroupClause(org.apache.calcite.sql.SqlSelect select)
      Validates the GROUP BY clause of a SELECT statement. This method is called even if no GROUP BY clause is present.
    • validateWhereClause

      protected void validateWhereClause(org.apache.calcite.sql.SqlSelect select)
    • validateWhereOrOn

      protected void validateWhereOrOn(org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlNode condition, String clause)
    • validateHavingClause

      protected void validateHavingClause(org.apache.calcite.sql.SqlSelect select)
    • validateSelectList

      protected org.apache.calcite.rel.type.RelDataType validateSelectList(org.apache.calcite.sql.SqlNodeList selectItems, org.apache.calcite.sql.SqlSelect select, org.apache.calcite.rel.type.RelDataType targetRowType)
    • createTargetRowType

      protected org.apache.calcite.rel.type.RelDataType createTargetRowType(org.apache.calcite.sql.validate.SqlValidatorTable table, @Nullable org.apache.calcite.sql.SqlNodeList targetColumnList, boolean append)
      Derives a row-type for INSERT and UPDATE operations.
      Parameters:
      table - Target table for INSERT/UPDATE
      targetColumnList - List of target columns, or null if not specified
      append - Whether to append fields to those in baseRowType
      Returns:
      Rowtype
    • validateInsert

      public void validateInsert(org.apache.calcite.sql.SqlInsert insert)
      Specified by:
      validateInsert in interface org.apache.calcite.sql.validate.SqlValidator
    • getLogicalTargetRowType

      protected org.apache.calcite.rel.type.RelDataType getLogicalTargetRowType(org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.SqlInsert insert)
    • getLogicalSourceRowType

      protected org.apache.calcite.rel.type.RelDataType getLogicalSourceRowType(org.apache.calcite.rel.type.RelDataType sourceRowType, org.apache.calcite.sql.SqlInsert insert)
    • checkTypeAssignment

      protected void checkTypeAssignment(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope sourceScope, org.apache.calcite.sql.validate.SqlValidatorTable table, org.apache.calcite.rel.type.RelDataType sourceRowType, org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.SqlNode query)
      Checks the type assignment of an INSERT or UPDATE query.

      Skip the virtual columns(can not insert into) type assignment check if the source fields count equals with the real target table fields count, see how #checkFieldCount was used.

      Parameters:
      sourceScope - Scope of query source which is used to infer node type
      table - Target table
      sourceRowType - Source row type
      targetRowType - Target row type, it should either contain all the virtual columns (can not insert into) or exclude all the virtual columns
      query - The query
    • validateDelete

      public void validateDelete(org.apache.calcite.sql.SqlDelete call)
      Specified by:
      validateDelete in interface org.apache.calcite.sql.validate.SqlValidator
    • validateUpdate

      public void validateUpdate(org.apache.calcite.sql.SqlUpdate call)
      Specified by:
      validateUpdate in interface org.apache.calcite.sql.validate.SqlValidator
    • validateMerge

      public void validateMerge(org.apache.calcite.sql.SqlMerge call)
      Specified by:
      validateMerge in interface org.apache.calcite.sql.validate.SqlValidator
    • validateValues

      protected void validateValues(org.apache.calcite.sql.SqlCall node, org.apache.calcite.rel.type.RelDataType targetRowType, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Validates a VALUES clause.
      Parameters:
      node - Values clause
      targetRowType - Row type which expression must conform to
      scope - Scope within which clause occurs
    • validateDataType

      public void validateDataType(org.apache.calcite.sql.SqlDataTypeSpec dataType)
      Specified by:
      validateDataType in interface org.apache.calcite.sql.validate.SqlValidator
    • validateDynamicParam

      public void validateDynamicParam(org.apache.calcite.sql.SqlDynamicParam dynamicParam)
      Specified by:
      validateDynamicParam in interface org.apache.calcite.sql.validate.SqlValidator
    • getValidationErrorFunction

      public org.apache.calcite.sql.validate.SqlValidatorImpl.ValidationErrorFunction getValidationErrorFunction()
    • newValidationError

      public org.apache.calcite.runtime.CalciteContextException newValidationError(org.apache.calcite.sql.SqlNode node, org.apache.calcite.runtime.Resources.ExInst<org.apache.calcite.sql.validate.SqlValidatorException> e)
      Specified by:
      newValidationError in interface org.apache.calcite.sql.validate.SqlValidator
    • getWindowByName

      protected org.apache.calcite.sql.SqlWindow getWindowByName(org.apache.calcite.sql.SqlIdentifier id, org.apache.calcite.sql.validate.SqlValidatorScope scope)
    • resolveWindow

      public org.apache.calcite.sql.SqlWindow resolveWindow(org.apache.calcite.sql.SqlNode windowOrRef, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Specified by:
      resolveWindow in interface org.apache.calcite.sql.validate.SqlValidator
    • getOriginal

      public org.apache.calcite.sql.SqlNode getOriginal(org.apache.calcite.sql.SqlNode expr)
    • setOriginal

      public void setOriginal(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.SqlNode original)
    • validateWindow

      public void validateWindow(org.apache.calcite.sql.SqlNode windowOrId, org.apache.calcite.sql.validate.SqlValidatorScope scope, @Nullable org.apache.calcite.sql.SqlCall call)
      Specified by:
      validateWindow in interface org.apache.calcite.sql.validate.SqlValidator
    • validateMatchRecognize

      public void validateMatchRecognize(org.apache.calcite.sql.SqlCall call)
      Specified by:
      validateMatchRecognize in interface org.apache.calcite.sql.validate.SqlValidator
    • validatePivot

      public void validatePivot(org.apache.calcite.sql.SqlPivot pivot)
    • validateUnpivot

      public void validateUnpivot(org.apache.calcite.sql.SqlUnpivot unpivot)
    • validateAggregateParams

      public void validateAggregateParams(org.apache.calcite.sql.SqlCall aggCall, @Nullable org.apache.calcite.sql.SqlNode filter, @Nullable org.apache.calcite.sql.SqlNodeList distinctList, @Nullable org.apache.calcite.sql.SqlNodeList orderList, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Specified by:
      validateAggregateParams in interface org.apache.calcite.sql.validate.SqlValidator
    • validateCall

      public void validateCall(org.apache.calcite.sql.SqlCall call, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Specified by:
      validateCall in interface org.apache.calcite.sql.validate.SqlValidator
    • validateFeature

      protected void validateFeature(org.apache.calcite.runtime.Feature feature, org.apache.calcite.sql.parser.SqlParserPos context)
      Validates that a particular feature is enabled. By default, all features are enabled; subclasses may override this method to be more discriminating.
      Parameters:
      feature - feature being used, represented as a resource instance
      context - parser position context for error reporting, or null if
    • resolveLiteral

      public org.apache.calcite.sql.SqlLiteral resolveLiteral(org.apache.calcite.sql.SqlLiteral literal)
      Specified by:
      resolveLiteral in interface org.apache.calcite.sql.validate.SqlValidator
    • expandSelectExpr

      public org.apache.calcite.sql.SqlNode expandSelectExpr(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.validate.SelectScope scope, org.apache.calcite.sql.SqlSelect select)
    • expand

      public org.apache.calcite.sql.SqlNode expand(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.validate.SqlValidatorScope scope)
      Specified by:
      expand in interface org.apache.calcite.sql.validate.SqlValidator
    • extendedExpandGroupBy

      public org.apache.calcite.sql.SqlNode extendedExpandGroupBy(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.sql.validate.SqlValidatorScope scope, org.apache.calcite.sql.SqlSelect select)
    • isSystemField

      public boolean isSystemField(org.apache.calcite.rel.type.RelDataTypeField field)
      Specified by:
      isSystemField in interface org.apache.calcite.sql.validate.SqlValidator
    • getFieldOrigins

      public List<@Nullable List<String>> getFieldOrigins(org.apache.calcite.sql.SqlNode sqlQuery)
      Specified by:
      getFieldOrigins in interface org.apache.calcite.sql.validate.SqlValidator
    • getParameterRowType

      public org.apache.calcite.rel.type.RelDataType getParameterRowType(org.apache.calcite.sql.SqlNode sqlQuery)
      Specified by:
      getParameterRowType in interface org.apache.calcite.sql.validate.SqlValidator
    • validateColumnListParams

      public void validateColumnListParams(org.apache.calcite.sql.SqlFunction function, List<org.apache.calcite.rel.type.RelDataType> argTypes, List<org.apache.calcite.sql.SqlNode> operands)
      Specified by:
      validateColumnListParams in interface org.apache.calcite.sql.validate.SqlValidator