Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-24403 Improve behaviour of CAST
  3. FLINK-25930

Remove identity casting from ScalarOperatorGens

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Following: https://github.com/apache/flink/pull/18582

      we could remove the following code from ScalarOperatorGens:

       

       

      case (_, _) if isInteroperable(operand.resultType, targetType) =>
      operand.copy(resultType = targetType)
       
      

      and use our IdentityCastRule instead but there is an issue.

       

      Currently the isInteroperable allows casting between types with different nullability whereas the IdentityCastRule uses the LogicalTypeCasts#supportsAvoidingCast which in turn uses the CastAvoidanceChecker which doesn't allow to cast from a nullable type to the same but non-nullable type, i.e. INT -> INT NOT NULL

      if (sourceType.isNullable() && !targetType.isNullable()
              || sourceType.getClass() != targetType.getClass()
              || // TODO drop this line once we remove legacy types
              sourceType.getTypeRoot() != targetType.getTypeRoot()) {
          return false;
      }

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            matriv Marios Trivyzas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: