Skip to content

fix(column-stats): plugin stats follow-ups (i18n, sql_syntax.extends, sample_size, docs) - #1239

Merged
debba merged 1 commit into
TabularisDB:mainfrom
Asymtode712:feat/column-stats-plugin-followups
Oct 23, 2026
Merged

debba merged 1 commit into
TabularisDB:mainfrom
Asymtode712:feat/column-stats-plugin-followups

Conversation

@Asymtode712

Copy link
Copy Markdown
Contributor

Summary

Follow-ups from the review of #1180 (optional get_column_stats RPC for plugin drivers, #1137). The feature itself is unchanged; this closes four small consistency gaps.

Closes #1232

Changes

Translate the "unavailable" error

When a plugin declares column_stats: true but answers -32601, handleLoadColumnStats threw a hard-coded English string that the popover showed as-is. It now uses dataGrid.columnStats.unavailable, added to every locale under src/i18n/locales/. t is added to the callback's dependency list.

sql_syntax.extends counts as SQL-compatible

speaksGenericSql only read sql_dialect, so a plugin declaring sql_syntax: { extends: "mysql" } without sql_dialect had the "Column statistics" entry hidden, even though #1200 lets plugins declare their syntax that way.

It now reads sql_syntax.extends ?? sql_dialect. extends takes precedence, matching how the syntax preset is resolved. mssql, oracle and generic stay excluded from either field. A sql_syntax without extends falls back to sql_dialect, and declaring neither still doesn't count.

sample_size consistency with Rust

fromPluginColumnStats kept sample_size even when every part was excluded (for example a masked column), while restrict_column_stats in src-tauri/src/models/column_stats.rs drops it. The TS side now drops it when distinct, minMax and topValues are all unsupported.

Documentation

plugins/PLUGIN_GUIDE.md (Column Statistics):

  • get_column_stats receives no sessionId, so session-local state (temp tables, SET search_path) isn't visible to the plugin. The same applies to get_table_query_template.
  • The compatibility table and prose now mention sql_syntax.extends.

Tests

  • tests/utils/driverCapabilities.test.ts: extends accepted for postgres/mysql/sqlite, rejected for mssql/oracle/generic, extends wins over sql_dialect, and a syntax without extends falls back to sql_dialect.
  • tests/utils/columnStats.test.ts: sample_size is dropped when all parts are excluded and kept when any one part is kept.
  • tests/pages/EditorToolbarQuery.test.tsx: updated to expect the new i18n key.

pnpm lint, pnpm typecheck and pnpm test pass. cargo test could not be run locally because of a macOS SDK linker error, and no Rust code is touched.

@kilo-code-bot

kilo-code-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The PR was rebased onto the packages/web-ui layout. The diff is functionally unchanged from the previously reviewed version, and the earlier "no issues" conclusion still holds.

  • speaksGenericSql reads a valid sql_syntax.extends first and falls back to sql_dialect. isDialect is exported from sqlSplitter, so the import resolves.
  • fromPluginColumnStats drops sample_size when every part is excluded, as restrict_column_stats does on the Rust side.
  • The new dataGrid.columnStats.unavailable key is in all 11 locales, and t is in the callback's dependency list.
  • The tests and PLUGIN_GUIDE.md match the new behaviour. I did not run the tests.
Files Reviewed (18 files)
  • packages/web-ui/src/i18n/locales/de.json
  • packages/web-ui/src/i18n/locales/en.json
  • packages/web-ui/src/i18n/locales/es.json
  • packages/web-ui/src/i18n/locales/fr.json
  • packages/web-ui/src/i18n/locales/it.json
  • packages/web-ui/src/i18n/locales/ja.json
  • packages/web-ui/src/i18n/locales/ko.json
  • packages/web-ui/src/i18n/locales/pt-BR.json
  • packages/web-ui/src/i18n/locales/ru.json
  • packages/web-ui/src/i18n/locales/tl.json
  • packages/web-ui/src/i18n/locales/zh.json
  • packages/web-ui/src/pages/Editor.tsx
  • packages/web-ui/src/utils/columnStats.ts
  • packages/web-ui/src/utils/driverCapabilities.ts
  • packages/web-ui/tests/pages/EditorToolbarQuery.test.tsx
  • packages/web-ui/tests/utils/columnStats.test.ts
  • packages/web-ui/tests/utils/driverCapabilities.test.ts
  • plugins/PLUGIN_GUIDE.md
Previous Review Summary (commit 8708332)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8708332)

Status: No Issues Found | Recommendation: Merge

The changes match the PR description. speaksGenericSql now reads sql_syntax.extends ?? sql_dialect, the optional chaining is safe for malformed plugin JSON, and the extends precedence matches resolveSqlSyntax. fromPluginColumnStats now drops sample_size when every part is excluded, as restrict_column_stats does on the Rust side. The new dataGrid.columnStats.unavailable key is added to all 11 locales and t is added to the callback's dependency list. The tests cover the new behaviour. I did not run the tests.

Files Reviewed (18 files)
  • plugins/PLUGIN_GUIDE.md
  • src/i18n/locales/de.json
  • src/i18n/locales/en.json
  • src/i18n/locales/es.json
  • src/i18n/locales/fr.json
  • src/i18n/locales/it.json
  • src/i18n/locales/ja.json
  • src/i18n/locales/ko.json
  • src/i18n/locales/pt-BR.json
  • src/i18n/locales/ru.json
  • src/i18n/locales/tl.json
  • src/i18n/locales/zh.json
  • src/pages/Editor.tsx
  • src/utils/columnStats.ts
  • src/utils/driverCapabilities.ts
  • tests/pages/EditorToolbarQuery.test.tsx
  • tests/utils/columnStats.test.ts
  • tests/utils/driverCapabilities.test.ts

Reviewed by claude-sonnet-5.5 · Input: 256 · Output: 2K · Cached: 329.7K

Review guidance: REVIEW.md from base branch main

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for wrapping up the follow-ups from #1232! The sample_size change matches the Rust side exactly (models/column_stats.rs), and the test checks each part on its own. Having sql_syntax.extends win over sql_dialect is consistent with how sqlSyntax.ts resolves the preset.

It needs a rebase onto main. #676 moved and reformatted Editor.tsx, columnStats.ts, driverCapabilities.ts and the related tests into packages/web-ui/ (4 spaces, single quotes), so git sees them as modify/delete conflicts instead of renames. The logic hasn't changed on main: the hardcoded string is still in packages/web-ui/src/pages/Editor.tsx, and speaksGenericSql is untouched. Re-applying your ~10 lines in the new files and moving the tests under packages/web-ui/tests/ should be enough. The locales and PLUGIN_GUIDE.md merge on their own.

Two nits:

  • You updated the Column Statistics section of PLUGIN_GUIDE.md, but the column_stats row in the capabilities table still says only "plugins whose sql_dialect is ...".
  • speaksGenericSql trusts extends even when it isn't a valid dialect, while sqlSyntax.ts ignores an invalid extends and falls back to sql_dialect. The impact is low, since the backend drops invalid descriptors, but it would be nice to align the two.

@Asymtode712
Asymtode712 force-pushed the feat/column-stats-plugin-followups branch from 8708332 to f683520 Compare October 23, 2026 13:32
@Asymtode712

Copy link
Copy Markdown
Contributor Author

@debba Rebased onto main and re-applied the changes in the new packages/web-ui/ files (Editor.tsx, columnStats.ts, driverCapabilities.ts and their tests, in the new formatting). The locales and PLUGIN_GUIDE.md merged cleanly.

Both nits are addressed:

  • The column_stats row in the PLUGIN_GUIDE capabilities table now mentions sql_syntax.extends as well as sql_dialect. The Column Statistics section also says an extends that isn't a known dialect is ignored.
  • speaksGenericSql now uses extends only when it is a valid dialect (via the same isDialect that sqlSyntax.ts uses) and otherwise falls back to sql_dialect. This brings it in line with the syntax preset. Added tests for a bogus extends with and without a valid sql_dialect.

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for redoing this on top of the new layout! Re-applying everything by hand in packages/web-ui/ with the new formatting isn't fun, and you also added tests for a bogus extends with and without sql_dialect, which is exactly the case I was worried about. Reusing isDialect from the splitter keeps speaksGenericSql in step with how sqlSyntax.ts resolves the preset. I also checked the new note about get_column_stats getting no session, and it's accurate.

I'm approving. Tests, build, lint and CI are all green on my side.

Two small things I noticed, fine as a follow-up:

  • plugins/manifest.schema.json still describes column_stats with only sql_dialect ("plugins with a postgres, mysql or sqlite sql_dialect..."). It's the same wording you fixed in the guide table, and plugin authors see that text in their editor.
  • The JSDoc on getColumnStatsSource in columnStats.ts still mentions only sql_dialect.

I'll run a few manual checks with a test plugin before merging.

@debba
debba merged commit c9dccba into TabularisDB:main Oct 23, 2026
11 checks passed
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.

Column statistics: follow-ups for plugin get_column_stats

2 participants