Skip to content

[doc]The deletion operation requires the equivalence condition of the primary key#1201

Merged
luoyuxia merged 2 commits into
apache:mainfrom
ZmmBigdata:pr-branch-4
Jun 26, 2025
Merged

[doc]The deletion operation requires the equivalence condition of the primary key#1201
luoyuxia merged 2 commits into
apache:mainfrom
ZmmBigdata:pr-branch-4

Conversation

@ZmmBigdata
Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #xxx

What is the purpose of the change:
https://alibaba.github.io/fluss-docs/docs/table-design/table-types/pk-table/merge-engines/default/
The deletion operation requires the equivalence condition of the primary key
c28587b09c7e825a6ec07da8c825a00

dd66c7ed632e572c4d375781b5eb077

Brief change log

Please describe the changes:

  1. Before executing the update operation, add a statement to switch to batch mode execution, otherwise an error will be reported: org.apache.flink.table.api.TableException: UPDATE statement is not supported for streaming mode now.
  2. Delete from T WHERE k>2 statement; Change to DELETE FROM T WHERE k=2;
  3. SELECT * FROM T; Change to SELECT * FROM T WHERE k=2;
  4. Change the result output of the query statement

API and Format

Does this change affect API or storage format:


  • 本次修改仅调整了 SQL 查询语句和表结构定义,不影响对外 API 或数据存储格式。

Documentation

Does this change introduce a new feature:


  • 本次修改是对现有功能的修复和优化,无需新增文档。

Copy link
Copy Markdown
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.

@ZmmBigdata Thanks for the pr. Left minor comments. PTAL


-- Update
INSERT INTO T(k, v1, v2) VALUES (2, 2.0, 't2');
-- Switch to batch mode to perform update operation, otherwise an error will be reported: org.apache.flink.table.api.TableException: UPDATE statement is not supported for streaming mode now.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
-- Switch to batch mode to perform update operation, otherwise an error will be reported: org.apache.flink.table.api.TableException: UPDATE statement is not supported for streaming mode now.
-- Switch to batch mode to perform update operation for UPDATE statement is only supported for batch mode currently

-- Delete
DELETE FROM T WHERE k > 2;
SELECT * FROM T;
DELETE FROM T WHERE k = 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why change it? If switch to batch mode, I think DELETE FROM T WHERE k > 2; can be supported then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switch to batch processing mode, Flinksql client also cannot execute. I already verified it last night

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@luoyuxia In the first picture, it has been switched to batch mode, but the delete operation still cannot be performed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for explaination. Haven't been aware of it

DELETE FROM T WHERE k > 2;
SELECT * FROM T;
DELETE FROM T WHERE k = 2;
SELECT * FROM T WHERE k = 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why change it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image
The FlinkSQL client cannot perform this delete operation, so it needs to be changed to the equivalent condition of the primary key

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I means why not keep SELECT * FROM T;?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why change it?

There is another way:
DELETE FROM T WHERE k = 2;
SET execution.runtime-mode = batch;
SELECT * FROM T;
Which one do you think is good

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer not change the origin context if the origin context works:

SELECT * FROM T;
-- Output:
+----+-----+----+
| k  | v1  | v2 |
+----+-----+----+
| 1  | 1.0 | t2 |
+----+-----+----+

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer not change the origin context if the origin context works:

SELECT * FROM T;
-- Output:
+----+-----+----+
| k  | v1  | v2 |
+----+-----+----+
| 1  | 1.0 | t2 |
+----+-----+----+

Need to add another statement to switch back to streaming mode:
SET execution.runtime-mode = streaming;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer not change the origin context if the origin context works:

SELECT * FROM T;
-- Output:
+----+-----+----+
| k  | v1  | v2 |
+----+-----+----+
| 1  | 1.0 | t2 |
+----+-----+----+

DELETE FROM T WHERE k = 2;
【SET execution.runtime-mode = streaming;】
SELECT * FROM T;
Add a statement and switch back to streaming mode to keep the select statement unchanged

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, let's add a statement to switch to streaming mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, let's add a statement to switch to streaming mode.

ok, I'll make changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, let's add a statement to switch to streaming mode.

@luoyuxia I have resubmitted according to the suggestion

Copy link
Copy Markdown
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 @ZmmBigdata +1

@luoyuxia luoyuxia merged commit b0328df into apache:main Jun 26, 2025
3 checks passed
@ZmmBigdata ZmmBigdata deleted the pr-branch-4 branch July 15, 2025 04:59
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.

2 participants