Skip to content

Add BaseTableName support to GetSchemaTable()#319

Draft
Copilot wants to merge 4 commits intodevelopfrom
copilot/fix-duckdbreader-table-name
Draft

Add BaseTableName support to GetSchemaTable()#319
Copilot wants to merge 4 commits intodevelopfrom
copilot/fix-duckdbreader-table-name

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Populates BaseTableName, BaseSchemaName, and BaseColumnName in GetSchemaTable() to enable table name introspection from query results.

Implementation

  • C API bindings: Added duckdb_get_table_names, duckdb_get_list_size, duckdb_get_list_child
  • Schema table enhancement: Added three columns and helper method GetTableNamesFromQuery()
  • Robust parsing: Uses qualified names with last-dot separator for schema/table splitting
  • Graceful degradation: Returns DBNull if API calls fail or feature unavailable

Usage

using var connection = new DuckDBConnection("DataSource=:memory:");
connection.Open();

var command = connection.CreateCommand();
command.CommandText = "SELECT id, name FROM users";
using var reader = command.ExecuteReader();

var schemaTable = reader.GetSchemaTable();
Console.WriteLine(schemaTable.Rows[0]["BaseTableName"]); // "users"

Limitation

DuckDB's C API returns unique table names per query, not per-column mappings. BaseTableName is populated for single-table queries only; multi-table queries (joins) return DBNull.Value.

This is an upstream API constraint. Per-column table resolution would require SQL parsing or a future DuckDB API enhancement.

Original prompt

This section details on the original issue you should resolve

<issue_title>Not able to get the table name from the DuckDBReader. </issue_title>
<issue_description>I am trying to get the table names involved in the query.

In sqlite db, in the reader I have the getschematable method which has the "BaseTableName" property set with the correct table name.
But in the duck db reader this parameter is not set. the getschematable.table is also empty.

Is there any other way to read the table name from the DuckDBReader? </issue_description>

Comments on the Issue (you are @copilot in this section)

@Giorgi This is not implemented yet. @Giorgi This can probably be achieved with [duckdb_get_table_names](https://duckdb.org/docs/stable/clients/c/api.html#duckdb_get_table_names)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 12, 2026 21:44
…ame in GetSchemaTable

Co-authored-by: Giorgi <580749+Giorgi@users.noreply.github.com>
Co-authored-by: Giorgi <580749+Giorgi@users.noreply.github.com>
…able parsing

Co-authored-by: Giorgi <580749+Giorgi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix DuckDBReader to retrieve table names Add BaseTableName support to GetSchemaTable() Feb 12, 2026
Copilot AI requested a review from Giorgi February 12, 2026 21:56
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 70.73171% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.40%. Comparing base (87f04e7) to head (44976b3).

Files with missing lines Patch % Lines
DuckDB.NET.Data/DuckDBDataReader.cs 70.73% 7 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #319      +/-   ##
===========================================
- Coverage    87.67%   87.40%   -0.28%     
===========================================
  Files           69       69              
  Lines         2605     2643      +38     
  Branches       378      387       +9     
===========================================
+ Hits          2284     2310      +26     
- Misses         230      237       +7     
- Partials        91       96       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Not able to get the table name from the DuckDBReader.

2 participants