Skip to content

fix: 修复采集数据源时,表字段有sql保留字冲突的名称报错问题#532

Open
wangjie-zzz wants to merge 3 commits into
spring-ai-alibaba:mainfrom
wangjie-zzz:main
Open

fix: 修复采集数据源时,表字段有sql保留字冲突的名称报错问题#532
wangjie-zzz wants to merge 3 commits into
spring-ai-alibaba:mainfrom
wangjie-zzz:main

Conversation

@wangjie-zzz

@wangjie-zzz wangjie-zzz commented Jun 4, 2026

Copy link
Copy Markdown

Describe what this PR does / why we need it

初始化数据源时,当有与sql保留字冲突的字段名称,会初始化失败

Does this pull request fix one issue?

Fixes #525

Describe how you did it

数据源采集在拼接字段时,根据数据源类型使用标识符包裹字段名:mysql+hive使用``标识,其他使用""标识(标准sql)

Describe how to verify it

可以采集一个有与sql保留字冲突字段名的表(例如desc字段)

Special notes for reviews

Copilot AI left a comment

Copy link
Copy Markdown

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 addresses datasource initialization failures when table column names conflict with SQL reserved keywords by quoting identifiers when building SELECT column lists.

Changes:

  • Added SqlUtil.buildColumnsSql(...) to quote column identifiers based on datasource type (MySQL uses backticks, others use double quotes).
  • Updated TableMetadataService to use buildColumnsSql(...) when fetching table sample data.

Reviewed changes

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

File Description
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/util/SqlUtil.java Adds a helper to build a quoted column list for SELECT statements.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/schema/TableMetadataService.java Uses the new helper when constructing sample-data queries.

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

@wangjie-zzz wangjie-zzz left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

已修正

@wangjie-zzz wangjie-zzz left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

review

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.

[BUG] 初始化数据源时,数据字段名和sql保留字冲突时,初始化异常

2 participants