You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Text processing
MD5 hash calculation
Copy page
Download PDF
MD5 hash calculation

Operator introduction

Description

MD5 hash value calculator – compute the MD5 digest of text

Key features

  • Generate the corresponding MD5 hash value for each text data entry
  • Output a fixed-length (32-character lowercase hexadecimal) digest
  • Supports batch processing

Application scenarios

  • Generate a unique identifier for text
  • Duplicate detection and data deduplication
  • Data consistency verification

Using Daft

Operator parameters

Input

Input column name

Description

texts

The text column to be processed; element type must be string

Output

MD5 hash value column, with element type string

Examples

The following code demonstrates how to use Daft to run the operator and compute the MD5 hash value of text.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.text.md5_calculator import Md5Calculator
from daft.las.functions.udf import las_udf

if __name__ == "__main__":

    if os.getenv("DAFT_RUNNER", "native") == "ray":
        import logging

        import ray

        def configure_logging():
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                datefmt="%Y-%m-%d %H:%M:%S.%s".format(),
            )
            logging.getLogger("tracing.span").setLevel(logging.WARNING)
            logging.getLogger("daft_io.stats").setLevel(logging.WARNING)
            logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING)

        ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging})
        daft.set_runner_ray()
    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)

    samples = {
        "text": [
            '',
            "",
            '',
        ]
    }

    ds = daft.from_pydict(samples)
    ds = ds.with_column(
        "md5_hash",
        las_udf(Md5Calculator)(col("text")),
    )

    ds.show()
    # ╭─────────────────────────────────────────────────────────┬────────────────────────────────╮
    # │ text                                                    ┆ md5_hash                       │
    # │ ---                                                     ┆ ---                            │
    # │ String                                                  ┆ String                         │
    # ╞═════════════════════════════════════════════════════════╪════════════════════════════════╡
    # │ 2023年,中国乘用车市场零售总量恢复至疫情前的水平,显示…          ┆ 5430020e506a5700f52a1817ff6ca… │
    # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
    # │ 与此同时,经过多年的快速发展和普及,2023年我国新车金融…          ┆ ea93a7088974310f970f85e3b4d52… │
    # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
    # │ 2023年,中国乘用车市场零售总量恢复至疫情前的水平,显示…          ┆ 5430020e506a5700f52a1817ff6ca… │
    # ╰─────────────────────────────────────────────────────────┴────────────────────────────────╯
Last updated: 2026.05.12 19:06:38