Skip to content

[Fix] Fix DuckDB datasource creation from Web UI - #3009

Merged
Aries-ckt merged 2 commits into
eosphoros-ai:mainfrom
honglei:fix/duckdb-datasource-creation
Apr 2, 2026
Merged

[Fix] Fix DuckDB datasource creation from Web UI#3009
Aries-ckt merged 2 commits into
eosphoros-ai:mainfrom
honglei:fix/duckdb-datasource-creation

Conversation

@honglei

@honglei honglei commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #3008

PR Description / PR 描述

Summary / 摘要

This PR fixes the issue where DuckDB datasources could not be correctly created or initialized from the Web UI. It ensures proper URI formatting and prevents schema-related SQL errors for DuckDB connections.

此 PR 修复了从 Web 界面创建或初始化 DuckDB 数据源失败的问题。主要通过修正 URI 格式化逻辑以及处理 DuckDB 在 SQL 执行中的 Schema 兼容性来解决。

Problem / 问题描述

  1. Incorrect URI Initialization: The DuckDbConnector was using a raw file path instead of a properly formatted DB URL when being created from parameters, leading to connection failures.

  2. Schema Incompatibility: In RDBMSConnector, DuckDB was not treated as a "schema-less" database (like SQLite). Passing a database name as a schema triggered errors during certain SQL operations.

  3. URI 初始化错误: DuckDbConnector 在从参数创建时直接使用了原始文件路径,而非格式化后的 DB URL,导致连接失败。

  4. Schema 不兼容: 在 RDBMSConnector 中,DuckDB 未像 SQLite 一样被视为“无 Schema”数据库。在某些 SQL 操作中传递数据库名作为 Schema 会触发错误。

Solution / 解决方案

  • Update URI Construction: Changed DuckDbConnector.from_parameters to use parameters.db_url() instead of parameters.path, ensuring the URI matches the required format for DuckDB.

  • Adjust Schema Logic: Updated RDBMSConnector to set _schema to None for DuckDB (matching SQLite behavior) to prevent SQL execution errors related to database/schema scoping.

  • 更新 URI 构建: 将 DuckDbConnector.from_parameters 更改为使用 parameters.db_url() 而非 parameters.path,确保生成的 URI 符合 DuckDB 的要求。

  • 调整 Schema 逻辑: 在 RDBMSConnector 中,将 DuckDB 设置为与 SQLite 相同的处理逻辑(即 _schemaNone),以避免与数据库/模式范围相关的 SQL 执行错误。

How Has This Been Tested?

The fix has been verified after adopting the changes from duckdb_engine PR #1393.

Test Environment:

  • OS: Windows 11 x64
  • Python: 3.13
  • DuckDB: 1.5.1
  • SQLAlchemy: 2.0.48

Manual Verification: Successfully created a DuckDB datasource via the Web UI and verified the connection and metadata retrieval.

该修复在采纳了 duckdb_engine PR #1393 的更改后进行了验证。

测试环境:

  • 操作系统: Windows 11 x64
  • Python 版本: 3.13
  • DuckDB 版本: 1.5.1
  • SQLAlchemy 版本: 2.0.48

手动验证: 通过 Web 界面成功创建 DuckDB 数据源,并验证了连接及元数据获取。

Snapshots:

N/A

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@Aries-ckt

Copy link
Copy Markdown
Collaborator

Thank you for your feedback! For version information, please see:- Latest stable version: v0.7.5 (2025-02-11)- View all releases: https://github.com/eosphoros-ai/DB-GPT/releasesWe recommend upgrading to the latest version to get the latest features and fixes.

@chenliang15405 chenliang15405 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for your contribution, LGTM

@Aries-ckt Aries-ckt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Aries-ckt
Aries-ckt merged commit 294dfcc into eosphoros-ai:main Apr 2, 2026
1 check passed
@honglei
honglei deleted the fix/duckdb-datasource-creation branch April 21, 2026 14:23
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] [DataSource] DuckDB datasource creation failure from Web UI

3 participants