test: add sql about time data type precision lost#4284
test: add sql about time data type precision lost#4284
Conversation
Summary of ChangesHello @wk989898, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new integration test case to validate the correct handling of Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds test data reproducing a TIME primary-key scenario and adjusts CSV/open decoders to use tiTypes.MaxFsp for parsing date/time/duration values; also removes special-case decimal handling for duration in the open decoder. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds a new integration test for an issue where using a time type with precision loss as a primary key could cause the downstream sink to panic. The added test case creates a table with a time(3) primary key and inserts a value with higher precision, which gets rounded. However, the test doesn't perform any subsequent UPDATE or DELETE operations on this specific row, which seems to be the core of the issue described in #4283. I've suggested an improvement to the test to make it more effective at catching the described bug.
|
|
||
| CREATE TABLE time_is_pk | ||
| ( | ||
| id time(3) NOT NULL, | ||
| t datetime DEFAULT CURRENT_TIMESTAMP, | ||
| PRIMARY KEY (id) | ||
| ); | ||
|
|
||
| INSERT INTO `time_is_pk`(id) VALUES ('517:51:04.777'),('-733:00:00.0011'); | ||
| DELETE FROM `time_is_pk` WHERE id = '517:51:04.777'; |
There was a problem hiding this comment.
The added test case is a good start, but it may not fully cover the scenario described in issue #4283. The issue mentions that a panic can occur during DELETE or UPDATE operations on a row where the time primary key has lost precision. This test only inserts a row with a value that will be rounded (-733:00:00.0011) and then deletes a different, unrelated row.
To make the test more robust and ensure it covers the problematic case, it should perform UPDATE and DELETE operations on the row with the rounded key. This will better simulate the conditions that could lead to the panic.
CREATE TABLE time_is_pk
(
id time(3) NOT NULL,
t int,
PRIMARY KEY (id)
);
INSERT INTO `time_is_pk`(id, t) VALUES ('-733:00:00.0011', 1);
UPDATE `time_is_pk` SET t = 2 WHERE id = '-733:00:00.0011';
DELETE FROM `time_is_pk` WHERE id = '-733:00:00.0011';There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/integration_tests/common_1/data/test.sql (1)
178-187: Add a comment to explain the purpose of this test.Other test sections in this file include descriptive comments (e.g.,
-- column null test,-- bit column,-- recover test). Consider adding a similar comment here to document the test purpose and reference the linked issue for future maintainability.📝 Suggested comment addition
UPDATE `column_is_null` SET t = NULL WHERE id = 1; +-- time as primary key precision test +-- Test issue: https://github.com/pingcap/tiflow/issues/4283 CREATE TABLE time_is_pk ( id time(3) NOT NULL, t datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) ); INSERT INTO `time_is_pk`(id) VALUES ('517:51:04.777'),('-733:00:00.0011'); DELETE FROM `time_is_pk` WHERE id = '517:51:04.777';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration_tests/common_1/data/test.sql` around lines 178 - 187, Add a descriptive SQL comment above the block that explains this test creates table time_is_pk (with a time(3) primary key and a datetime default), inserts boundary/negative time values and then deletes one row; mention the purpose (verifying time type as primary key, handling of negative/overflow time literals) and include the related issue reference/ID for future maintainability so readers understand why values like '517:51:04.777' and '-733:00:00.0011' are used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/integration_tests/common_1/data/test.sql`:
- Around line 178-187: Add a descriptive SQL comment above the block that
explains this test creates table time_is_pk (with a time(3) primary key and a
datetime default), inserts boundary/negative time values and then deletes one
row; mention the purpose (verifying time type as primary key, handling of
negative/overflow time literals) and include the related issue reference/ID for
future maintainability so readers understand why values like '517:51:04.777' and
'-733:00:00.0011' are used.
|
/test mysql |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hongyunyan, lidezhu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
2 similar comments
|
/retest |
|
/retest |
|
@wk989898: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: close #4283
What is changed and how it works?
Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit