Skip to content

fix(stream): tolerate existing output table on submit;fix stream out-column timestamp precision checks#35044

Merged
guanshengliang merged 2 commits intomainfrom
fix/main/6931571628
Apr 3, 2026
Merged

fix(stream): tolerate existing output table on submit;fix stream out-column timestamp precision checks#35044
guanshengliang merged 2 commits intomainfrom
fix/main/6931571628

Conversation

@Pengrongkun
Copy link
Copy Markdown
Contributor

…ut-column precision checks

Description

Fixes stream writes to pre-created normal output tables when NODELAY_CREATE_SUBTABLE is used: the vnode can return TSDB_CODE_TDB_TABLE_ALREADY_EXIST for the embedded create step, which must be treated as success on the client. Also adjusts CREATE STREAM validation so timestamp precision is checked against the table time precision, and decimal columns still require matching precision; other types are no longer rejected solely on column-level precision mismatch.

Issue(s)

https://project.feishu.cn/taosdata_td/defect/detail/6931571628

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings April 2, 2026 05:46
@Pengrongkun Pengrongkun requested review from a team and dapan1121 as code owners April 2, 2026 05:46
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes stream creation/insertion behavior when the output table already exists (notably with NODELAY_CREATE_SUBTABLE) and refines CREATE STREAM output-table column validation to handle timestamp/decimal precision more correctly.

Changes:

  • Treat TSDB_CODE_TDB_TABLE_ALREADY_EXIST as a non-fatal result for the embedded output-table create step during stream submit.
  • Adjust CREATE STREAM out-table column validation: timestamp precision is checked against table time precision; decimal columns still require matching precision; other types no longer fail purely on precision mismatch.
  • Extend stream processing tests to cover auto-creating output normal tables and writing into a pre-created normal output table.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/cases/18-StreamProcessing/99-Others/test_auto_create_output_table.py Adds coverage for NODELAY_CREATE_SUBTABLE streams writing into newly-created and pre-created normal output tables.
source/libs/parser/src/parTranslater.c Refines output-column compatibility checks for streams (timestamp precision vs table precision; decimal precision enforcement).
source/libs/executor/src/dataInserter.c Allows “table already exists” responses during embedded create to be treated as success for stream submit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,3 +1,4 @@
import time
from new_test_framework.utils import tdSql, tdLog, tdStream, StreamItem
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

StreamItem is imported from new_test_framework.utils but never used (the test uses the nested self.StreamItem class instead). This also creates a confusing name collision between the imported symbol and the nested class; consider removing the import or renaming the nested helper class to avoid shadowing.

Suggested change
from new_test_framework.utils import tdSql, tdLog, tdStream, StreamItem
from new_test_framework.utils import tdSql, tdLog, tdStream

Copilot uses AI. Check for mistakes.
Comment on lines +278 to +280
tdSql.execute("insert into tb1 values ('2025-01-01 00:00:02', 10003);")
time.sleep(5)

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The explicit time.sleep(5) makes the test slower and can still be flaky. Since tdSql.checkResultsByFunc already retries/polls (up to 300s by default), it should be sufficient to rely on that retry loop (or pass its delay/retry params) instead of a fixed sleep.

Copilot uses AI. Check for mistakes.
@Pengrongkun Pengrongkun requested a review from zitsen as a code owner April 2, 2026 06:12

tdSql.execute("insert into tb1 values ('2025-01-01 00:00:02', 10003);")
time.sleep(5)

Copy link
Copy Markdown
Contributor

@JinqingKuang JinqingKuang Apr 3, 2026

Choose a reason for hiding this comment

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

tdSql.checkResultsByFunc() 已经会轮询重试最多 300 次,所以这里再写死一个 time.sleep(5) 只会增加测试耗时,不会让断言更可靠。更干净的做法是删掉这个 sleep,直接依赖现有轮询;如果确实要调等待行为,就显式传 delay/retrycheckResultsByFunc()

@JinqingKuang
Copy link
Copy Markdown
Contributor

JinqingKuang commented Apr 3, 2026

代码审查更正:

当前仍然成立的问题只有 1 个:

  1. 新测试在结果校验前加了固定的 time.sleep(5)。但 tdSql.checkResultsByFunc() 本身已经带轮询重试,这个 sleep 只会增加测试耗时,不会提升正确性。

@guanshengliang guanshengliang merged commit 3cd981d into main Apr 3, 2026
15 of 16 checks passed
jiajingbin pushed a commit that referenced this pull request Apr 8, 2026
wangmm0220 pushed a commit that referenced this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants