Skip to content

Conversation

@sunxiaojian
Copy link
Contributor

@sunxiaojian sunxiaojian commented Mar 4, 2025

Purpose

Linked issue: close #459

Tests

N/A

API and Format

N/A

Documentation

N/A

@sunxiaojian sunxiaojian changed the title Add document about versioned merge engine #459 Add document about versioned merge engine Mar 4, 2025
@sunxiaojian
Copy link
Contributor Author

@wuchong @luoyuxia PTAL, thanks

-- | 1 | v2 | 2000 |

-- insert data with ts = null, no update will be made
nsert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: nsert -> insert.

-- | a | b | ts |
-- +---+-----+------+
-- | 1 | v2 | 2000 |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add -- +---+-----+------+ in table end.

-- | a | b | ts |
-- +---+-----+------+
-- | 1 | v2 | 2000 |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunxiaojian Thanks for the pr. PTAL

:::

example:
```sql title="versioned"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```sql title="versioned"
```sql title="Flink SQL"

'table.merge-engine' = 'versioned',
'table.merge-engine.versioned.ver-column' = 'ts'
);
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v1', 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v1', 1000);
insert into merge_engine_with_version (a, b, ts ) VALUES (1, 'v1', 1000);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luoyuxia Whether to remove the space after ts?
(a, b, ts ) -> (a, b, ts)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't noticed that

insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v1', 1000);

-- insert data with ts < 1000, no update will be made
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', 999);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', 999);
insert into merge_engine_with_version (a, b, ts ) VALUES (1, 'v2', 999);



-- insert data with ts > 1000, update will be made
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', 2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', 2000);
insert into merge_engine_with_version (a, b, ts ) VALUES (1, 'v2', 2000);

-- | a | b | ts |
-- +---+-----+------+
-- | 1 | v2 | 2000 |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add the bottom line to align with the style of above content

-- +---+-----+------+
-- | a | b   | ts   |
-- +---+-----+------+
-- | 1 | v2  | 2000 |
-- +---+-----+------+

When using `versioned` merge engine, there are the following limits:
- `UPDATE` and `DELETE` statements are not supported
- Partial update is not supported
:::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:::
:::

:::note
When using `versioned` merge engine, there are the following limits:
- `UPDATE` and `DELETE` statements are not supported
- Partial update is not supported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one more note just like first-row merge engine:

`UPDATE_BEFORE` and `DELETE` changelog events are ignored automatically

# Versioned Merge Engine

TODO: Fill me #459
By specifying `'table.merge-engine' = 'versioned'`, users can update data based on the configured version column. Updates will be carried out when the latest value of the specified field is greater than the stored value. If it is less than or empty, no update will be made.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
By specifying `'table.merge-engine' = 'versioned'`, users can update data based on the configured version column. Updates will be carried out when the latest value of the specified field is greater than the stored value. If it is less than or empty, no update will be made.
By setting `'table.merge-engine' = 'versioned'`, users can update data based on the configured version column. Updates will be carried out when the latest value of the specified field is greater than or equal to the stored value. If it is less than or null, no update will be made.


TODO: Fill me #459
By specifying `'table.merge-engine' = 'versioned'`, users can update data based on the configured version column. Updates will be carried out when the latest value of the specified field is greater than the stored value. If it is less than or empty, no update will be made.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest to add a statement to explain how the feature is useful just like first-row merge page does, maybe something like:

This feature is particularly valuable for replacing [Deduplication](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/table/sql/queries/deduplication/) transformations in streaming computations, reducing complexity and improving overall efficiency.

example:
```sql title="versioned"

create table merge_engine_with_version (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change SQL keyword to uppercase to align the style of first-row merge engine page?

@sunxiaojian
Copy link
Contributor Author

@luoyuxia fixed

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sunxiaojian LGTM. @wuchong Could you please help review agian?

@wuchong wuchong merged commit cc6b9af into apache:main Mar 5, 2025
2 checks passed
ZmmBigdata pushed a commit to ZmmBigdata/fluss that referenced this pull request Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add document about versioned merge engine

4 participants