[Feature Request]: Add batch sequence retrieval support to the Add Sequence transform

オープン
#9,587 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java

調査の方向性

Start with the Add Sequence transform and its documentation at the linked manual page. Check how it retrieves sequence values and how its settings and database connections are handled, then look for related transform tests. Done means an optional batch mode supports a configurable size, retrieves actual sequence values, assigns them to rows, and leaves the existing behavior intact when disabled.

索引モデルが issue の本文から書いたものです。

説明

awaiting triage P3 Transforms
What would you like to happen?
Current Behavior

The existing Add Sequence transform supports database sequences, but currently retrieves one sequence value for each input row.

For large pipelines, this results in many individual database queries just to generate sequence IDs.

Problem

When processing thousands or millions of rows, retrieving sequence values one at a time introduces unnecessary database round trips and can significantly affect pipeline performance, especially when database latency is high.

For example, processing 100,000 rows currently requires approximately 100,000 sequence retrieval queries.

It would be more efficient to retrieve multiple sequence values in a single query and use them locally until the batch is exhausted.

Proposed Enhancement

I would like the Add Sequence transform to support an optional batch retrieval mode when using database sequences.

The proposed enhancement would allow users to:

  1. Enable or disable batch sequence retrieval.
  2. Configure the batch size, for example 1,000 values.
  3. Support Hop variables for the batch size.
  4. Retrieve multiple actual sequence values from the database in a single query.
  5. Keep the retrieved values in memory and assign one value to each incoming row.
  6. Automatically retrieve another batch when all reserved values have been used.
  7. Preserve the current behavior when batch retrieval is disabled.

For Oracle, the batch retrieval could use a query similar to:

SELECT SEQ_SERVICO_VIGENCIA.NEXTVAL
FROM DUAL
CONNECT BY LEVEL <= ?

The batch size would be configurable rather than hardcoded.

Each value must come from an actual database sequence evaluation. The implementation should not assume that sequence values are consecutive or generate additional IDs by incrementing the first retrieved value.

Expected Behavior

With a batch size of 1,000:

  1. The first incoming row triggers a query retrieving 1,000 sequence values.
  2. The values are stored in memory.
  3. Each incoming row receives one reserved sequence value.
  4. After consuming all 1,000 values, another batch is retrieved.
  5. Processing continues until all incoming rows are handled.

For example, processing 100,000 rows would require approximately 100 batch retrieval queries instead of 100,000 individual queries.

Unused values from the final batch do not need to be reused.

The implementation should also handle concurrent pipeline executions safely, preserving the uniqueness guarantees of the underlying database sequence.

Use Case

I currently use a JavaScript transform in Apache Hop to implement this behavior with an Oracle database.

The script:

  • Uses an existing Hop database connection.
  • Reads the batch size from a Hop variable, defaulting to 1,000.
  • Retrieves actual Oracle NEXTVAL values in batches.
  • Stores the results in memory.
  • Assigns one value to each incoming row.
  • Retrieves another batch only when needed.
  • Uses BigDecimal to preserve numeric precision.

This approach avoids executing a separate SQL query for every input row.

Having this functionality directly in the Add Sequence transform would eliminate the need for custom JavaScript and make it easier to configure and maintain.

Benefits
  • Fewer database round trips when generating sequence IDs.
  • Better performance in high-volume ETL pipelines.
  • Less dependency on custom JavaScript implementations.
  • Configurable batch sizes for different workloads.
  • Reuse of existing database connection and sequence settings.
  • Backward compatibility with the current Add Sequence behavior.
Reference

Existing Apache Hop Add Sequence documentation:

https://hop.apache.org/manual/latest/pipeline/transforms/addsequence.html

The initial implementation could focus on Oracle, with support for other database types where equivalent batch sequence retrieval is available.

Issue Priority

Priority: 3

Issue Component

Component: Transforms

主要言語
Java
スター
1.6k
フォーク
499
平均マージ
1日 5時間
マージ済み PR(30日)
316

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/hop のほかの issue

apache/hop の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。