Class RowDataUtils

    • Constructor Detail

      • RowDataUtils

        public RowDataUtils()
    • Method Detail

      • convertDataChangeEventToHoodieFlinkInternalRow

        public static org.apache.hudi.client.model.HoodieFlinkInternalRow convertDataChangeEventToHoodieFlinkInternalRow​(DataChangeEvent dataChangeEvent,
                                                                                                                         Schema schema,
                                                                                                                         java.time.ZoneId zoneId,
                                                                                                                         org.apache.hudi.sink.bulk.RowDataKeyGen keyGen,
                                                                                                                         String fileId,
                                                                                                                         String instantTime)
        Convert a DataChangeEvent to a HoodieFlinkInternalRow with automatic record key and partition path extraction using Hudi's RowDataKeyGen. This is the preferred method as it uses Hudi's built-in key generation logic.
        Parameters:
        dataChangeEvent - The DataChangeEvent to convert
        schema - Schema for the table
        zoneId - Time zone for timestamp conversion
        keyGen - Hudi's RowDataKeyGen for extracting record keys and partition paths
        fileId - The file ID for the record
        instantTime - The instant time for the record
        Returns:
        HoodieFlinkInternalRow containing the converted data
      • extractRecordKeyFromDataChangeEvent

        public static String extractRecordKeyFromDataChangeEvent​(DataChangeEvent dataChangeEvent,
                                                                 Schema schema)
        Extract record key from DataChangeEvent based on primary key fields in schema. Public utility method for use by operators that need to calculate record keys.
        Parameters:
        dataChangeEvent - The DataChangeEvent to extract record key from
        schema - The table schema containing primary key definitions
        Returns:
        The record key string in format "field1:value1,field2:value2"
      • extractPartitionPathFromDataChangeEvent

        public static String extractPartitionPathFromDataChangeEvent​(DataChangeEvent dataChangeEvent,
                                                                     Schema schema)
        Extract partition path from DataChangeEvent based on partition key fields in schema. Public utility method for use by operators that need to calculate partition paths.

        If the schema has partition keys defined:

        • Extracts partition field values from the record data
        • Formats them as "field1=value1/field2=value2" (Hive-style partitioning)

        If no partition keys are defined, returns empty string (for unpartitioned tables).

        Parameters:
        dataChangeEvent - The DataChangeEvent to extract partition from
        schema - The table schema containing partition key definitions
        Returns:
        The partition path string (empty string for unpartitioned tables)
      • toRowType

        public static org.apache.flink.table.types.logical.RowType toRowType​(Schema schema)
        Converts a Flink CDC Schema to a Flink Table RowType.
        Parameters:
        schema - The input org.apache.flink.cdc.common.schema.Schema
        Returns:
        The corresponding org.apache.flink.table.types.logical.RowType
      • toLogicalType

        public static org.apache.flink.table.types.logical.LogicalType toLogicalType​(DataType cdcType)
        Maps a Flink CDC DataType to a Flink Table LogicalType. This method covers a wide range of common types.
        Parameters:
        cdcType - The CDC data type
        Returns:
        The corresponding LogicalType
      • createKeyGen

        public static org.apache.hudi.sink.bulk.RowDataKeyGen createKeyGen​(Schema schema)
        Create a RowDataKeyGen for a table based on its schema.
        Parameters:
        schema - The table schema
        Returns:
        RowDataKeyGen configured with record key and partition fields from schema