Skip to content

added motherduck support in duckDB#10385

Merged
ea-rus merged 10 commits into
mindsdb:releases/26.1.0from
parthiv11:main
Mar 13, 2026
Merged

added motherduck support in duckDB#10385
ea-rus merged 10 commits into
mindsdb:releases/26.1.0from
parthiv11:main

Conversation

@parthiv11
Copy link
Copy Markdown
Contributor

Description

Please include a summary of the change and the issue it solves.

Fixes #10378

Type of change

(Please delete options that are not relevant)

  • ⚡ New feature (non-breaking change which adds functionality)
  • 📄 This change requires a documentation update

Verification Process

To ensure the changes are working as expected:

  • Test Location: Specify the URL or path for testing.
  • Verification Steps: Outline the steps or queries needed to validate the change. Include any data, configurations, or actions required to reproduce or see the new functionality.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

ZoranPandovski
ZoranPandovski previously approved these changes Jan 22, 2025
@martyna-mindsdb
Copy link
Copy Markdown
Contributor

@parthiv11
Please resolve the conflicts so we can merge this.

@parthiv11
Copy link
Copy Markdown
Contributor Author

parthiv11 commented Jun 26, 2025 via email

@parthiv11
Copy link
Copy Markdown
Contributor Author

done @martyna-mindsdb

@martyna-mindsdb
Copy link
Copy Markdown
Contributor

@parthiv11
Please address the issues in Tests on Push -- https://github.com/mindsdb/mindsdb/actions/runs/15928294634/job/44930902729?pr=10385
Thanks!

@martyna-mindsdb
Copy link
Copy Markdown
Contributor

martyna-mindsdb commented Jun 27, 2025

@martyna-mindsdb
Copy link
Copy Markdown
Contributor

@hamishfagg
Can you please approve this PR? It requires a manual approval.

sejubar and others added 6 commits November 11, 2025 17:52
Co-authored-by: andrew <elkin.andr@gmail.com>
Co-authored-by: martyna-mindsdb <109554435+martyna-mindsdb@users.noreply.github.com>
# Conflicts:
#	docs/setup/environment-vars.mdx
#	mindsdb/integrations/handlers/hubspot_handler/hubspot_tables.py
@parthiv11 parthiv11 changed the base branch from main to develop January 12, 2026 06:04
@parthiv11 parthiv11 requested a review from a team as a code owner January 12, 2026 06:04
@parthiv11 parthiv11 changed the base branch from develop to main January 12, 2026 06:14
@parthiv11 parthiv11 changed the base branch from main to develop January 12, 2026 06:18
@parthiv11 parthiv11 changed the base branch from develop to main January 12, 2026 06:21
@parthiv11 parthiv11 changed the base branch from main to develop January 12, 2026 06:41
@parthiv11
Copy link
Copy Markdown
Contributor Author

@ea-rus ea-rus changed the base branch from develop to develop2 March 10, 2026 16:24
@ea-rus ea-rus changed the base branch from develop2 to main March 10, 2026 16:24
ea-rus
ea-rus previously approved these changes Mar 10, 2026
Comment on lines 85 to 91
self.connect()
response.success = True
except Exception as e:
logger.error(
f'Error connecting to DuckDB {self.connection_data["database"]}, {e}!'
)
logger.error(f"Error connecting to DuckDB {self.connection_data['database']}, {e}!")
response.error_message = str(e)
finally:
if response.success is True and need_to_close:
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.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 93%)

This function check_connection duplicates existing code.

📍 Original Location:

mindsdb/integrations/handlers/databend_handler/databend_handler.py:85-107

Function: check_connection

💡 Recommendation:
Implement a default check_connection() on the DatabaseHandler base class that follows this exact try/except/finally template, calling the subclass's connect(). Subclasses that need extra checks (e.g., SQLiteHandler's file existence guard) can override or call super().check_connection() and add pre-conditions. This would eliminate the boilerplate from every SQL handler.

Consider importing and reusing the existing function instead of duplicating the logic.

Comment on lines 167 to +170
Response: Details of the table.
"""

query = f'DESCRIBE {table_name};'
return self.native_query(query)
query = f"DESCRIBE {table_name};"
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.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 95%)

This function get_columns duplicates existing code.

📍 Original Location:

mindsdb/integrations/handlers/clickhouse_handler/clickhouse_handler.py:161-167

Function: get_columns

💡 Recommendation:
Consider a base-class or mixin get_columns() that issues a configurable describe query (e.g., a per-dialect template). For DuckDB and ClickHouse, the template is DESCRIBE {table_name}. Handlers that need extra column renaming (e.g., DatabendHandler renames Field→column_name) can override with a super() call followed by a rename step.

Consider importing and reusing the existing function instead of duplicating the logic.

@ea-rus
Copy link
Copy Markdown
Collaborator

ea-rus commented Mar 11, 2026

@parthiv11, can you solve static code checks errors? Can you see a content of this error?

@parthiv11
Copy link
Copy Markdown
Contributor Author

done @ea-rus

Comment on lines +47 to +50
motherduck_token = self.connection_data.get("motherduck_token")
if motherduck_token:
database = (
f"md:{self.connection_data.get('database')}?motherduck_token={motherduck_token}&attach_mode=single"
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.

Correctness: The motherduck_token is embedded directly in the database connection string as a URL query parameter (?motherduck_token=...), which means it will appear in plaintext in logs, error messages (e.g., the check_connection error log includes the database string), and any tracing/debugging output. This leaks a sensitive credential.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In mindsdb/integrations/handlers/duckdb_handler/duckdb_handler.py, lines 47-50, the motherduck_token is embedded in the database connection string URL. This causes the token to appear in log output (e.g., check_connection logs `self.connection_data['database']` on error, and native_query logs it too). Consider passing the token via the duckdb `config` parameter (e.g., `duckdb.connect(database='md:dbname', config={'motherduck_token': token})`) instead of embedding it in the URL, to avoid credential exposure in logs and error messages.

@ea-rus ea-rus changed the base branch from main to releases/26.1.0 March 13, 2026 11:50
@ea-rus ea-rus merged commit e3daacc into mindsdb:releases/26.1.0 Mar 13, 2026
16 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a MotherDuck Integration

9 participants