Skip to content

Fix Postgres column stats UnboundLocalError on errors#12253

Merged
ea-rus merged 1 commit into
mindsdb:releases/26.1.0from
ianu82:codex/fix-postgres-column-stats-unbound-df
Mar 20, 2026
Merged

Fix Postgres column stats UnboundLocalError on errors#12253
ea-rus merged 1 commit into
mindsdb:releases/26.1.0from
ianu82:codex/fix-postgres-column-stats-unbound-df

Conversation

@ianu82

@ianu82 ianu82 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • return early from meta_get_column_statistics when native_query does not return a table response
  • only run dataframe post-processing when a table dataframe is present
  • add a regression unit test that verifies non-table responses are returned unchanged

Why

The previous implementation always referenced df after the conditional transformation block, causing an UnboundLocalError when native_query returned an error/non-table response.

Validation

  • python3 -m py_compile mindsdb/integrations/handlers/postgres_handler/postgres_handler.py tests/unit/handlers/test_postgres.py
  • pytest -q tests/unit/handlers/test_postgres.py -k meta_get_column_statistics_returns_non_table_response (fails in this environment due to missing optional dependency psycopg)

@github-actions

github-actions Bot commented Feb 27, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ianu82

ianu82 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor Author

recheck

@ea-rus ea-rus changed the base branch from main to releases/26.1.0 March 20, 2026 11:32
@ea-rus ea-rus merged commit abaf3ed into mindsdb:releases/26.1.0 Mar 20, 2026
40 of 48 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 20, 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.

2 participants