Flink Udf

作者 confluentinc914d95eff7ff無授權條款58 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫2 天前更新

Build and deploy Apache Flink user-defined functions (UDFs) in Java for stream processing over Kafka. Use this skill when users want to create scalar UDFs, user-defined table functions (UDTFs), or process table functions (PTFs) in Java, deploy them to Confluent Cloud or local Docker environments, and invoke them from Flink SQL or the Table API. Trigger on: Flink UDF, custom Flink function, process table function, PTF, UDTF, Flink user defined, extend Flink SQL, stateful stream processing with Flink. Do NOT trigger for: Kafka Streams UDFs (use kafka-streams-programming skill), general Flink job development without custom functions, CDC streaming data piplines that include Flink (prefer the confluent-cloud-cdc-tableflow skill), Flink connector setup, or Kafka producer/consumer code.

AI 產生的概覽

指導以 Java 建置並部署 Apache Flink 使用者自訂函式(UDF、UDTF、PTF)至 Confluent Cloud 或本機 Docker。

功能
此技能引導使用者為 Apache Flink 建立自訂 Java 函式:純量 UDF、使用者自訂資料表函式(UDTF)與程序資料表函式(PTF)。它會詢問部署目標、使用現有或新建基礎設施,以及呼叫方式,再指向 Confluent Cloud 或本機 Docker 的參考指南。內容涵蓋產生樣板程式碼、實作業務邏輯、封裝 JAR、部署成品、在 Flink 中註冊函式,並以範例資料測試。它也要求在執行會變更資源的指令前先提出部署計畫並取得使用者明確同意。
適用情境
當使用者想以 Java 撰寫或部署自訂 Flink 函式(例如純量 UDF、UDTF 或 PTF),並從 Flink SQL 或 Table API 呼叫時使用。適用於 Confluent Cloud 或本機 Docker 部署,包括需要先架設 Kafka 與 Flink 基礎設施的情況。不適用於 Kafka Streams UDF、不含自訂函式的一般 Flink 作業開發、CDC 管線、連接器設定或 Kafka 生產者/消費者程式碼。
執行需求
需要能讀取隨附參考 Markdown 檔案的代理;未包含指令碼。部署路徑假定具備用於封裝 JAR 的 Java 建置工具、含 confluent CLI 的 Confluent Cloud 環境與運算集區,或包含 Kafka 與 Flink 容器的本機 Docker 環境,並需要連線至這些服務的網路。

Flink User-Defined Functions (UDFs)

Build and deploy custom functions in Java for Apache Flink to extend SQL and Table API capabilities with custom logic.

Function Types

Before proceeding, identify which type of function the user needs:

  • Scalar UDF: Maps input values to a single output value (e.g., custom hash, string manipulation, calculations)
  • User-Defined Table Function (UDTF): Maps input to multiple output rows (e.g., split strings, explode arrays)
  • Process Table Function (PTF): Advanced stateful processing with N-to-M semantics, managed state, and timers (e.g., windowing, deduplication, state machines)

Gather Requirements

Ask the user these questions to determine the implementation path (if not already clear from context):

  1. Deployment target: Confluent Cloud or local Docker?
  2. Infrastructure: Deploy new infrastructure (Kafka + Flink) or use existing?
  3. Invocation method: Flink SQL or Table API?

Route to Implementation Guide

Based on the answers above, read the appropriate reference file:

Confluent Cloud Deployment

  • Scalar UDF or UDTF → Read references/udf-udtf-java-confluent-cloud.md
  • Process Table Function (PTF) → Read references/ptf-java-confluent-cloud.md

If infrastructure setup is needed, also read references/confluent-cloud-setup.md first.

Local Docker Deployment

  • Scalar UDF or UDTF → Read references/udf-udtf-java-local.md
  • Process Table Function (PTF) → Read references/ptf-java-local.md

If infrastructure setup is needed, also read references/local-docker-setup.md first.

Implementation Workflow

After reading the appropriate reference:

  1. Set up infrastructure (if needed)
  2. Generate boilerplate code for the function
  3. Implement the business logic
  4. Build and package the JAR
  5. Confirm the deployment plan with the user. Before any resource-modifying call (confluent flink artifact create, docker cp into a running container, CREATE FUNCTION, etc.), present the plan and wait for explicit approval. Show:
    • Artifact name and JAR path
    • Function name to register
    • Target environment (Confluent Cloud env + compute pool ID, or local Docker container name)
    • The exact commands and SQL that will run Do not proceed to steps 6–7 until the user confirms.
  6. Deploy the artifact
  7. Register the function in Flink
  8. Test the function with sample data
  9. Provide usage examples (SQL or Table API)

Keep code scaffolding concise and focused on the user's specific requirements. Avoid over-engineering.

來源與署名

來源:confluentinc/agent-skills位於skills/flink-udf提交914d95e

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架