Class TypeWideningChecker

Object
io.delta.kernel.internal.types.TypeWideningChecker

public class TypeWideningChecker extends Object
Utility class for checking type widening compatibility according to the Delta protocol.

The Type Widening feature enables changing the type of a column or field in an existing Delta table to a wider type. This class implements the checks required by the protocol to ensure that only supported type changes are allowed.

Supported type changes as per protocol:

  • Integer widening: Byte -> Short -> Int -> Long
  • Floating-point widening: Float -> Double
  • Floating-point widening: Byte, Short or Int -> Double
  • Date widening: Date -> Timestamp without timezone
  • Decimal widening: Decimal(p, s) -> Decimal(p + k1, s + k2) where k1 >= k2 >= 0
  • Decimal widening: Byte, Short or Int -> Decimal(10 + k1, k2) where k1 >= k2 >= 0
  • Decimal widening: Long -> Decimal(20 + k1, k2) where k1 >= k2 >= 0
  • Method Details

    • isWideningSupported

      public static boolean isWideningSupported(DataType sourceType, DataType targetType)
      Checks if a type change from sourceType to targetType is a supported widening operation.
      Parameters:
      sourceType - The original data type
      targetType - The target data type to widen to
      Returns:
      true if the type change is a supported widening operation (or the types are equal), false otherwise
    • isIcebergV2Compatible

      public static boolean isIcebergV2Compatible(DataType sourceType, DataType targetType)
      Checks if the type change is supported by Iceberg V2 schema evolution. This is required when Iceberg compatibility is enabled.
      Parameters:
      sourceType - The original data type
      targetType - The target data type to widen to
      Returns:
      true if the type change is supported by Iceberg V2 (sourceType == targetType returns true), false otherwise