Repository navigation
Conversation
| @Marshal(Marshaller.Jackson) | ||
| @RequiresPermission(ReadPermission.class) | ||
| @Action(ActionType.SelectData.class) | ||
| public static class GetColumnFacetsAction extends ReadOnlyApiAction<FilterSuggestionsRequest> |
There was a problem hiding this comment.
This appears to be handing back information for all columns when the client only ever is looking at a single column. Consider adding a "column" or "facetColumn" to the request parameters so that the server only returns information for that column (when specified).
There was a problem hiding this comment.
This is a very appealing idea. I evaluated this but I think I'm gonna hold off on this one. The reason is per column response means each time the user changes a field selection on the filter panel, a different api request is needed. With the current implementation, a single request handles all fields on the filter panel. Changing fields on the filter panel might not be a common scenario, but it still is not clear trade off for smaller payload vs fewer requests.
| private static final String FILTER_REGION = "query"; | ||
| private static final String ALL_COLUMNS = "*"; | ||
| // Matches the row count at which a grid stops counting exactly and shows "100,000+" | ||
| private static final long LARGE_TABLE_ROWS = 100_000; |
There was a problem hiding this comment.
nit: Perhaps we could reuse DataRegionSelection.MAX_QUERY_SELECTION_SIZE instead on introducing another constant.
| try | ||
| { | ||
| // reltuples is a float; cast in SQL because the selector has no getter for Float | ||
| SQLFragment sql = new SQLFragment("SELECT CAST(reltuples AS BIGINT) FROM pg_class WHERE oid = to_regclass(?)") |
There was a problem hiding this comment.
It is recommended that we quote the schema/table parts when passing them to to_regclass().
SQLFragment sql = new SQLFragment(
"SELECT CAST(reltuples AS BIGINT) FROM pg_class " +
"WHERE oid = to_regclass(quote_ident(?) || '.' || quote_ident(?))"
).add(schemaName).add(tableName);| * @param hasBlank some row holds null or blank, which values never includes. Only meaningful with | ||
| * valuesFromData set. | ||
| */ | ||
| public record ColumnFacet( |
There was a problem hiding this comment.
Rather than introducing a new type could we use SuggestionColumn directly and extend it for this use case?
Rationale
Exposes what the column fact cache already knows so the grid filter dialog can list a column's values, or decide not to ask for them, without a
SELECT DISTINCTover the whole table (Kanban 2177). The cache was built to rank grid search suggestions and already holds the distinct count for every column and the values themselves where there are few enough; this adds a read path to it and the few facts the filter dialog needs that it was discarding.Related Pull Requests
Changes