Class CastRuleProvider

java.lang.Object
org.apache.flink.table.planner.functions.casting.CastRuleProvider

@Internal public class CastRuleProvider extends Object
This class resolves CastRule using the input and the target type.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canFail(org.apache.flink.table.types.logical.LogicalType inputType, org.apache.flink.table.types.logical.LogicalType targetType)
    Resolves the rule and returns the result of CastRule.canFail(LogicalType, LogicalType).
    static Object
    cast(CastRule.Context context, org.apache.flink.table.types.logical.LogicalType inputLogicalType, org.apache.flink.table.types.logical.LogicalType targetLogicalType, Object value)
    Create a CastExecutor and execute the cast on the provided value.
    static org.apache.flink.table.data.utils.CastExecutor<?,?>
    create(CastRule.Context context, org.apache.flink.table.types.logical.LogicalType inputLogicalType, org.apache.flink.table.types.logical.LogicalType targetLogicalType)
    Create a CastExecutor for the provided input type and target type.
    static boolean
    exists(org.apache.flink.table.types.logical.LogicalType inputType, org.apache.flink.table.types.logical.LogicalType targetType)
    Returns true if and only if a CastRule can be resolved for the provided input type and target type.
    generateCodeBlock(CodeGeneratorCastRule.Context context, String inputTerm, String inputIsNullTerm, org.apache.flink.table.types.logical.LogicalType inputLogicalType, org.apache.flink.table.types.logical.LogicalType targetLogicalType)
    Create a CastCodeBlock for the provided input type and target type.
    static CastRule<?,?>
    resolve(org.apache.flink.table.types.logical.LogicalType inputType, org.apache.flink.table.types.logical.LogicalType targetType)
    Resolve a CastRule for the provided input type and target type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CastRuleProvider

      public CastRuleProvider()
  • Method Details

    • resolve

      @Nullable public static CastRule<?,?> resolve(org.apache.flink.table.types.logical.LogicalType inputType, org.apache.flink.table.types.logical.LogicalType targetType)
      Resolve a CastRule for the provided input type and target type. Returns null if no rule can be resolved.
    • exists

      public static boolean exists(org.apache.flink.table.types.logical.LogicalType inputType, org.apache.flink.table.types.logical.LogicalType targetType)
      Returns true if and only if a CastRule can be resolved for the provided input type and target type.
    • canFail

      public static boolean canFail(org.apache.flink.table.types.logical.LogicalType inputType, org.apache.flink.table.types.logical.LogicalType targetType)
      Resolves the rule and returns the result of CastRule.canFail(LogicalType, LogicalType). Fails with NullPointerException if the rule cannot be resolved.
    • create

      @Nullable public static org.apache.flink.table.data.utils.CastExecutor<?,?> create(CastRule.Context context, org.apache.flink.table.types.logical.LogicalType inputLogicalType, org.apache.flink.table.types.logical.LogicalType targetLogicalType)
      Create a CastExecutor for the provided input type and target type. Returns null if no rule can be resolved.
      See Also:
    • generateCodeBlock

      @Nullable public static CastCodeBlock generateCodeBlock(CodeGeneratorCastRule.Context context, String inputTerm, String inputIsNullTerm, org.apache.flink.table.types.logical.LogicalType inputLogicalType, org.apache.flink.table.types.logical.LogicalType targetLogicalType)
      Create a CastCodeBlock for the provided input type and target type. Returns null if no rule can be resolved or the resolved rule is not instance of CodeGeneratorCastRule.
      See Also:
    • cast

      @Nullable public static Object cast(CastRule.Context context, org.apache.flink.table.types.logical.LogicalType inputLogicalType, org.apache.flink.table.types.logical.LogicalType targetLogicalType, Object value)
      Create a CastExecutor and execute the cast on the provided value. Fails with IllegalArgumentException if the rule cannot be resolved, or with an exception from the CastExecutor itself if the rule can fail.