Closes HDX-3154
This PR adds a feature that allows the user to add settings to a source. These settings are then added to the end of every query that is rendered through the `renderChartConfig` function, along with any other chart specific settings.
See: https://clickhouse.com/docs/sql-reference/statements/select#settings-in-select-query
Most of the work was to pass the `source` or `source.querySettings` value through the code to the `renderChartConfig` calls and to update the related tests. There are also some UI changes in the `SourceForm` components.
`SQLParser.Parser` from the `node-sql-parser` throws an error when it encounters a SETTINGS clause in a sql string, so a function was added to remove that clause from any sql that is passed to the parser. It assumes that the SETTINGS clause will always be at the end of the sql string, it removes any part of the string including and after the SETTINGS clause.
https://github.com/user-attachments/assets/7ac3b852-2c86-4431-88bc-106f982343bb
Closes HDX-3066
# Summary
This PR improves the performance of Search and Dashboard filters by querying available filter values from materialized views, when possible. The existing `useMultipleGetKeyValues` has been updated to make use of `getKeyValuesWithMVs`, which works as follows:
1. Identify which materialized views support each of the requested keys. Keys must be `dimensionColumns` in the materialized view, the materialized view must support the provided date range, and the materialized view must support the provided filters (determined by running an EXPLAIN query).
2. Split the keys into groups based on which Materialized view can provide their values. Query values for each group using the existing `getKeyValues` function. Sampling is disabled because it is assumed that MVs are small enough to be queried without sampling.
3. Query any keys which are not supported by any materialized view from the base table.
To reduce the number of EXPLAIN queries required to support this, and to generally decrease the number of concurrent requests for filters, Dashboard filter value queries are now batched by source. Values for each batch are then queried using `getKeyValuesWithMVs` (described above).
Other fixes:
1. I've also updated the various filter functions and hooks to support abort signals, so that filter queries are canceled when a query value is no longer needed.
2. The getKeyValues cache key now includes `where` and `filters`, so that the filter values correctly update when new filters or where conditions are added on the search page.
moves them into a core folder, this allows us to easily track when core files are modified via path
no changeset because no version bump required
fixes HDX-2589
# Summary
Closes HDX-1960
This PR adds a button to our search filters component which can be used to show the _approximate_ percentage of rows which have each filter value.
https://github.com/user-attachments/assets/2dba1b28-d2b9-4414-986c-0c515d252c89
Notes:
- The percentages are based on a sample of 100k rows. The sampling is done similarly to how EE version samples logs for patterns.
- We only fetch the most common 100 values in the sample. All other values are assumed to represent <1% of the data.
- The percentages represent the distribution within the dataset after it has been filtered by the selected filters and the where clause.
- This is a potentially expensive query, even with sampling, so the percentages are only queried if they're toggled on for a particular filter, and do not refresh in live mode. They do refresh if the search or date ranges changes (outside of live mode).
Optimize the query performance of the getMapKeys method to prevent excessive resource usage in ClickHouse, even when max_rows_to_read is specified.
Ref: HDX-2411
Ref: HDX-2431
1. Merge all clickhouse client setting related endpoints into one `/clickhouse-settings` plus controllers
2. Add tooltips to the setting UIs
3. Introduce `metadataMaxRowsToRead` setting for tweaking metadata query perf
Ref: HDX-2075
Related: HDX-2023
<img width="871" height="374" alt="image" src="https://github.com/user-attachments/assets/1824452f-8045-430d-9e26-5d31bcf38dcf" />
After #713 was merged, a bug was introduced which manifests when a user clicks an existing connection while editing a source.
The issue is that a helper function (`isSingleTableConnection`) was introduced to check to see if a single connection was passed or an array of connections was passed. In this function, it also checks the schema if a single object is passed, which can cause the function to return `false` if the schema isn't exact. This poses a problem because the downstream code will think that it is an array of connections and error out.
In this particular scenario, there was another bug where if a user clicks on a selected value in the source dropdown, it unselects that value and returns null, which is what triggered this error to begin with.
Therefore there are two fixes here:
1) Add an option to disable un-selection of dropdowns and set that to true for the source dropdown.
2) Remove the helper code `isSingleTableConnection` as its behavior is confusing to downstream consumers.
Ref: HDX-1557
The default max_rows_to_read clickhouse query setting was too low for the metrics table. Therefore, not enough rows were being scanned in order to fetch all possible metric names.
Ref: HDX-1451
We now use the `partition_key` in helping narrow down a given row that's selected in the UI, which is necessary for large datasets where the `partition_key` is not already part of the `primary_key`
Fixes HDX-1281