Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…ctors (upstream issue 408)
9a87bb0 to
64f7422
Compare
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…ctors (upstream issue 408)
9a87bb0 to
64f7422
Compare
Reviewer guide
What: queries returning two columns with the same name (
SELECT c.id, o.id …,SELECT *over a join) gave silently wrong values on Postgres, MySQL and SQLite, so text-to-SQL answered from them. Frames are now built from row tuples andcursor.description.Risk: low. Frames can now contain repeated column names; every consumer of agent-SQL results was checked (see below).
Look at:
_fetch_frameinpostgres.py, the MySQL cursor, and SQLite row building. Each is a few lines.Verified: the new tests fail on the old code. The opt-in live MySQL suite passed against MySQL 8.4.
Est. review: ~10 min.
Summary
When a query returns two columns with the same name (
SELECT c.id, o.id, c.name, o.name …, orSELECT *over a join), the Postgres, MySQL and SQLite connectors returned wrong data with no error. Each row was built as a dict keyed by column name, so one value overwrote the other before the DataFrame existed:id, name, row100, first orderid, id, name, name/1, 100, Ada, first order100, 100, first order, first order1, 100, Ada, first order1, 1, Ada, Ada1, 100, Ada, first orderText-to-SQL then answered from the wrong values without retrying. The fix builds frames from row tuples plus
cursor.description. DuckDB was already correct.Is it safe for downstream readers?
Frames from arbitrary agent SQL can now contain repeated column names, so I checked every reader of
execute_chat_sql/_run_sqloutput:sql_execution._run_sqlalready de-duplicates names (id,id__2) before serializing.numeric_column_kindsandresult_values_digestread by position.db_probeto_dict(orient="records")still collapses duplicates, as it did before, inside atry.Catalog metadata queries have unique column names, so they're unaffected.
Provenance
This re-lands an external contribution: upstream PR 422, authored by HUSEIN. Commit authorship is preserved. The code is identical, rebased onto current
main. Only the commit title's issue reference was reworded, so pushing doesn't post to the public issue before review.Verification
AUTO_ONTOLOGY_LIVE_MYSQL=1suite, which CI doesn't run): 6 of 6 pass. A duplicate-name join returns['id','id','name','name'] [[1, 100, 'Ada', 'first order']].kumoextra (they run in CI).Merge checklist
Summary by CodeRabbit