Skip to content

fix(db): don't abort ClickHouse table listing on an unparsable version - #1546

Open
borealisalastor-byte wants to merge 1 commit into
dataease:mainfrom
borealisalastor-byte:fix/ck-version-fallback
Open

borealisalastor-byte wants to merge 1 commit into
dataease:mainfrom
borealisalastor-byte:fix/ck-version-fallback

Conversation

@borealisalastor-byte

Copy link
Copy Markdown
Contributor

What breaks

get_table_sql() for a ClickHouse datasource does int(db_version.split('.')[0]) to decide whether system.tables has a comment column. get_version() returns '' whenever the version query fails — limited permissions, a timeout, a pool error — and the ClickHouse version string may also arrive with a non-numeric prefix. In both cases table listing raised ValueError before any SQL was built, so datasource table sync / embedding failed instead of degrading.

Reproduced against 287935a6 by loading the function in isolation:

''        -> ValueError : invalid literal for int() with base 10: ''
'v23.8'   -> ValueError : invalid literal for int() with base 10: 'v23'
'unknown' -> ValueError : invalid literal for int() with base 10: 'unknown'
'23.8.1.2993' -> ok

Change

  • leading_version() parses the leading number and returns 0 when there is none.
  • An unknown version now takes the pre-22 query, whose '' as comment projection is valid on every ClickHouse release; the branch that needs the real comment column only runs when a version is actually known.
  • backend/tests/test_ck_table_sql_version.py covers '', None, 'v23.8', 'unknown' and blank strings, keeps 22+/21- selection intact, and pins leading_version(). It loads only get_table_sql/leading_version via AST, like the existing isolated tests, so no driver stack is needed.

Verification

  • python -m pytest tests/test_ck_table_sql_version.py -q: 10 passed (local, Python 3.13).
  • The same 10 cases fail on 287935a6 for the unparsable inputs (ValueError shown above).
  • No dependency change; ClickHouse only, no other datasource branch touched.

get_version() returns '' whenever the version query fails (limited
permissions, timeout, pool error), and the ClickHouse branch called
int(db_version.split('.')[0]) on it, so table listing raised ValueError
before any SQL was built. A non-numeric prefix behaved the same way.

Parse the leading number and fall back to the pre-22 query when there is
none; '"" as comment' is valid on every ClickHouse version, and the
branch that needs the real comment column only runs when a version is
actually known.

This branch has not been deployed

No deployments
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.

1 participant