Repository navigation
Add system.table_settings - #124001
Add system.table_settings#124001buggins wants to merge 63 commits into
system.table_settings#124001Conversation
Add a new system table that exposes settings for all table engines, not just MergeTree. Introduces FillEngineSettingsFn in StorageFactory and the StorageSystemEngineSettings class. Engines with no registered fill function are skipped, so the table is empty until engines wire in.
Register fillEngineSettingsColumns for 18 engine settings classes (MergeTree, Memory, Distributed, Kafka, RabbitMQ, NATS, MySQL, PostgreSQL, RocksDB, ObjectStorage, etc.) so they appear in system.engine_settings.
Basic stateless test verifying the table exists, has the engine_name column, and returns settings for known engines. Also wire DataLakeStorageSettings which was missed in the previous commit.
…aster Master added a `show_secrets` argument to `getValueString` and `getDefaultValueString`; pass `true`, as `system.merge_tree_settings` and `system.server_settings` do - the flag matters only for custom settings, which no engine settings struct has. `DatabaseDataLakeCatalogType::NONE`, the default of the data lake engines' `storage_catalog_type`, had no name, so reading `system.engine_settings` threw `Unexpected value of DatabaseDataLakeCatalogType:0`; it is now `none`. The test's reference had two lines that never matched a real run - the `tier` enum type and a `Bool` default printed as `false` - and is now recorded from one. Not needed to pass the test: the column definitions are re-synced with `system.merge_tree_settings`, whose `tier` description gained a `PRIVATE PREVIEW` line after they were copied; they are now identical. Related: ClickHouse#59913 Related: ClickHouse#113269 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`fill_engine_settings_fn(MutableColumns &)` becomes `enumerate_engine_settings_fn`, which returns `SettingDescriptions`; `system.engine_settings` writes its rows from them. Settings structs no longer need to know the system table's column layout, and `fillData` no longer fills temporary columns to copy them row by row. Every settings struct gets `enumerateSettings`, defined with `IMPLEMENT_SETTINGS_ENUMERATION`, and registers `enumerateCompiledDefaults<XSettings>`. The output of `system.engine_settings` is unchanged: a full dump (`ORDER BY engine_name, name`) and its column list are byte-identical to the previous commit's. Related: ClickHouse#59913 Related: ClickHouse#113269 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A new `MergeTree` table starts from the server's instance of `MergeTreeSettings`, not from the compiled defaults: `compatibility` from the default profile and the `<merge_tree>` config section are applied to it, and `<replicated_merge_tree>` on top for the replicated engines. `system.engine_settings` now reports that instance for every engine of the two families, with the current user's constraints and `isReadonlySetting`, as `system.merge_tree_settings` and `system.replicated_merge_tree_settings` do. The constraint handling moves out of `dumpToSystemMergeTreeSettingsColumns` into `MergeTreeSettings::enumerateSettingsWithConstraints`, which both tables now use. The output of `system.merge_tree_settings` and `system.replicated_merge_tree_settings` is unchanged (full dumps compared byte-for-byte). `enumerate_engine_settings_fn` now takes the query context, and `SettingDescription` gets the constraint fields (`min_value`, `max_value`, `disallowed_values`, `readonly`); the other engines still report compiled defaults. The new test checks that every engine of each family reports exactly the rows of the matching table, both ways. In `04695`, `index_granularity` is now `readonly`. Related: ClickHouse#59913 Related: ClickHouse#113269 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A new `Distributed`, `Remote` or `RemoteSecure` table starts from the server's `DistributedSettings` (the `<distributed>` config section) and fills the `background_insert_*` settings its definition leaves out from the global context's `distributed_background_insert_*` settings. `system.engine_settings` now reports the same for these engines, instead of the compiled defaults; a `SET` in the session does not change the rows. The fill-in moves from `finalizeDistributedSettings` into `DistributedSettings::applyBackgroundInsertDefaults`, which both the engines' creators and `DistributedSettings::enumerateEngineSettings` call; table creation is unchanged. `default` stays the compiled default. `changed` is what a new table gets: the two `Milliseconds` settings take the `changed` flag of the core setting along with its value, so they show `changed = 0` with a value of 100 / 30000, while the other two show `changed = 1`. The new test therefore checks each of the four as `changed` or different from `default`. Related: ClickHouse#59913 Related: ClickHouse#113269 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Replaces the one-line description with a `DOCS_MD` block like the other system tables have: what `value` means for each group of engines (compiled defaults, the server-level `MergeTree` instances, the `Distributed` fill-in), what the constraint columns mean, examples, and links to the related tables. It also says that for the `MergeTree` family and `Distributed`, `Remote` and `RemoteSecure` the table shows the server's configuration, so `SELECT` on it should be granted as on `system.merge_tree_settings`. The page under `docs/reference/system-tables/` is generated from this by the documentation pipeline. Related: ClickHouse#59913 Related: ClickHouse#113269 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`Hudi` was listed with all the data lake settings although it rejects a `SETTINGS` clause (`supports_settings = false`). `YTsaurus` and `GenerateRandom` declare their settings in settings classes but were not listed. `04695` now checks that every listed engine accepts `SETTINGS`; it runs in fast test too, as none of its queries needs an optional library. The documentation no longer claims to cover every engine and names the ones not listed yet: `Join` and the `Log` family. Related: ClickHouse#59913 Related: ClickHouse#113269 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The class comment of `StorageSystemEngineSettings` still said the table shows all settings of all table engines, which is no longer true since `Join` and the `Log` family are not listed. The comment on the constraint fields of `SettingDescription` did not mention that `readonly` is also set by `MergeTreeSettings::isReadonlySetting`. Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`enumerate_engine_settings_fn` and `enumerateSettings` take a `SettingsChanges` argument: the settings object an engine starts a new table from is copied, the changes whose names it declares are applied, and the copy is enumerated. This is what `system.table_settings` needs to describe a table from its stored `SETTINGS` clause, with values in the same form as `system.engine_settings`, aliases resolved and `changed` set as the settings class sets it. `system.engine_settings` and `system.merge_tree_settings` pass no changes, and their output is unchanged (full dumps compared byte-for-byte). For `Distributed` the changes are applied after the `background_insert_*` fill-in; the fill-in only sets unset values, so a stated value wins, as when the table is created. Related: ClickHouse#116543 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
One row per table and setting: the engine's row in `system.engine_settings` with the table's own `SETTINGS` clause applied, as it is stored in the table's definition, so values changed by `ALTER ... MODIFY SETTING` are shown too. The columns are those of `system.engine_settings` with `database` and `table` in front. - Access: the `SELECT` grant on the table, and `SHOW TABLES` for each table shown. The query's condition on `database` and `table` is applied to the names first, only to names the user may see, so reading one table's settings does not read every table's definition. - Secrets: hidden as in `SHOW CREATE TABLE`. The list of engine settings that hold secrets moves from `ASTSetQuery.cpp` to `Parsers/engineSettingsToHide.h`, so both use one list. An expression value such as `disk = disk(...)` is shown as written, with its secrets hidden, instead of being created again. - `S3Queue` and `AzureQueue` accept their settings with an `s3queue_` prefix, which their loader strips outside the settings class; their enumeration now does the same. - Not shown: engines `system.engine_settings` does not list (`Join`, the `Log` family), views, dictionaries, tables created from a table function, data lake catalogs, and values that are not in the definition (named collections, `S3Queue` state in Keeper). Related: ClickHouse#116543 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A table of `Kafka`, `NATS`, `RabbitMQ`, `MySQL`, `PostgreSQL` or `YTsaurus` can take its settings from a named collection named by its first engine argument. The table's rows now apply it as the engine's creator does: the collection's keys spelled as a setting's name, then the overrides in the engine arguments, then the `SETTINGS` clause. Before, those rows showed the engine's defaults. A value the collection supplies is shown as `system.named_collections` shows it: only to a user with `SHOW NAMED COLLECTIONS` on the collection and `SHOW NAMED COLLECTIONS SECRETS`, where secrets may be displayed; otherwise it is `[HIDDEN]`. Such rows are found by enumerating the settings with and without the collection, so aliases need no handling here. An override in the engine arguments is shown if it is a literal; nothing is evaluated. A collection can be changed after the table was created, to a value the setting cannot take. The error then names the collection and the table, not the value. `05296` becomes a shell test, for a collection name unique to the run, and is marked `no-replicated-database`, as every test that builds a table on a named collection is. Related: ClickHouse#116543 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The `DeltaLakeLocal` creator reads its `SETTINGS` clause as `DataLakeStorageSettings` (`disk` picks the local disk), but the engine was registered with `StorageObjectStorageSettings::hasBuiltin`, and `system.engine_settings` copied that class. So the table listed 325 settings where `DeltaLake` lists 365: the 40 data lake settings, `disk` included, were missing. It is now registered with `DataLakeStorageSettings` for both, as `DeltaLake`, `DeltaLakeS3` and `DeltaLakeAzure` are. `04695` checks that `DeltaLakeLocal` and `DeltaLake` list the same settings. The registration also decides which names of a `CREATE` query's `SETTINGS` clause are query settings. For `DeltaLakeLocal`, a name that is both a data lake setting and a query setting now stays with the table, as for `DeltaLake`, instead of being applied to the `CREATE` query. These are the `iceberg_*` compaction settings, which `DeltaLakeLocal` ignores, and `allow_experimental_delta_kernel_rs`, which is obsolete as a table setting; to disable the Delta kernel for the query, `allow_delta_kernel_rs` is still applied to it. Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Two spaces after the comma in the `engine_name` column definition, not aligned with the lines below, fail the `whitespace_check` of the style check. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123041&sha=17a23d924391ce05bdd545ce0db7405ac31cab24&name_0=PR&name_1=Style%20check Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…figuration only For `Distributed`, `Remote` and `RemoteSecure`, `system.engine_settings` reported `changed` of the instance after the `background_insert_*` fill-in, so it showed how the fill-in assigns a value rather than whether anyone configured the setting: `background_insert_batch` and `background_insert_split_batch_on_failure` were `changed = 1` on a server that sets nothing, the two `Milliseconds` settings `0`. `changed` now comes from the instance the `distributed` section of the server configuration loads, and only the values from the filled-in copy. `05294` checks that the values are the server's `distributed_background_insert_*` settings and `changed` is `0`; the documentation example is updated. Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The documentation named only `Join` and the `Log` family. `File` and `URL` also accept a `SETTINGS` clause without a settings class of their own, so they are not listed either; `StripeLog` and `TinyLog` are named with `Log`. Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`DatabaseDataLakeCatalogType::NONE` got the name `none` so that `system.engine_settings` can show the default of `storage_catalog_type`. As a result `catalog_type = 'none'` is no longer rejected as an unknown value: it behaves as leaving the setting out, failing with `Unspecified catalog type`. `05317` checks both. Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # src/Storages/Distributed/DistributedSettings.cpp # src/Storages/Distributed/DistributedSettings.h
The `engine_name` column definition, copied from `system.engine_settings`, has two spaces after the comma that are not aligned with the lines below, which fails the `whitespace_check` of the style check, as it did there. Related: ClickHouse#124001 Related: ClickHouse#116543 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…uery setting `DeltaLakeLocal` is registered with `DataLakeStorageSettings` since 17a23d9, so `CREATE` keeps a name that is both a data lake setting and a query setting with the table, as for the other `DeltaLake` engines, instead of applying it to the query and dropping it from the definition. `05318` creates a table with `SETTINGS iceberg_compaction_commit_batch_size = 7` and checks that `SHOW CREATE TABLE` keeps it; on master the setting is missing from the definition. Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… elsewhere Some settings have no value of their own for a new table: unless the definition states them, a table takes them from the query or server settings, or from the server configuration. `system.engine_settings` listed them with the compiled default, which a table does not necessarily use: - the format settings, which every engine accepting them takes from the query settings of the session creating the table (`S3` and the other object storage and data lake engines), of the server (`S3Queue`, `AzureQueue`, `FileLog`), or of the context reading it (`Kafka`, `NATS`, `RabbitMQ`, `Hive`); `Set` does not use them; - the connection pool settings of `PostgreSQL` and `mysql_datatypes_support_level` of `MySQL`, from the session creating the table; - the credentials of `NATS` and `RabbitMQ`, from the server configuration. They are left out now: `StorageFactory::isInheritedSetting` treats every format setting so (`isFormatFactorySetting`) and asks the engine about the others (`is_inherited_setting_fn`). `S3`, `AzureBlobStorage`, `HDFS`, `COSN`, `OSS`, `GCS` and `PostgreSQL` have no other settings and are no longer listed, like `File` and `URL`; the table goes from about 15,900 rows to about 6,800. The documentation states what `value` and `changed` mean and names the two values that are still not what a new table uses in every configuration (`ExecutablePool`'s cap by `max_execution_time` and `RabbitMQ`'s `vhost` from the server configuration). `04695` checks that no such setting is listed. Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… settings an engine does not use `b340f48eccc` said that the compaction settings of `DataLakeStorageSettings` are used only by the `Iceberg` engines. No data lake table reads them: `IcebergMetadata` reads the query-level settings of the same names, and only `allow_experimental_iceberg_compaction` is read from the table, for the tables of a `DataLakeCatalog` database. Several of them also start with `iceberg_`, so "the `iceberg_*` settings" overclaimed too. The documentation now names only what holds: the data lake engines list the settings of every table format, such as the `paimon_*` settings, which only the `Paimon` engines use, and settings that none of them reads, such as `object_storage_endpoint` and the `storage_*` catalog settings that are not deprecated. It also said that engines sharing a settings class list all of its settings, and the comment on `enumerateCompiledDefaultsExcept` that an engine lists every setting it accepts. Neither holds for the settings a table takes from elsewhere, nor for `Set`, which leaves out the format settings of its class. Both now say only that a setting the engine accepts but does not use is not left out for that reason. So does the paragraph that `b340f48eccc` added, whose first sentence, like that commit's title, said such a setting is always listed: `Set` does not list the format settings it accepts but does not use, since they are left out for another reason. Related: ClickHouse#123041 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Brings `b340f48eccc` and `dc0b87a6836`, which document that a setting an engine accepts but does not use is not left out of `system.engine_settings` for that reason, and narrow the comment on `enumerateCompiledDefaultsExcept` to the settings the engine rejects or replaces. The comment conflicted with the one this branch made say "a table" and that such settings are left out even where a definition states them; the resolution keeps both. Related: ClickHouse#124001 Related: ClickHouse#116543 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tings-59913 Conflict in `TimeSeriesSettings.cpp`: master moved `TimeSeriesVersion.h` (now included via `checkTimeSeriesVersion.h`) and added methods next to `IMPLEMENT_SETTINGS_ENUMERATION`; both sides kept. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ings` `system.engine_settings` left out every setting that a table takes from the query or server settings, the server configuration or the creating session when its definition does not state it. That hid the format settings, 31 engine settings such as `kafka_max_block_size` and the `PostgreSQL` pool settings, and whole engines (`S3`, `AzureBlobStorage`, `HDFS`, `COSN`, `OSS`, `GCS`, `PostgreSQL`), although their settings control the engine. They are listed again, with a new column `inherited` = 1; `value` is the engine's own value. The format settings an engine sets itself are listed with the engine's value and `inherited` = 0: `Kafka`'s defaults for `input_format_skip_unknown_fields`, `input_format_allow_errors_ratio` and `input_format_allow_errors_num` (from `createSettingsAdjustments`), and the header detection that `Kafka`, `FileLog`, `NATS` and `RabbitMQ` always disable, shown as `0` with `readonly` = 1. Only settings without effect stay hidden: those a table rejects, and the format settings that `Set` and `Hive` accept but never read. The `MergeTree` rows are unchanged, with `inherited` = 0. Also: `PostgreSQLSettings::isLoadedFromQueryContext` is `hasBuiltin`, since every setting of the class is a pool setting. Related: ClickHouse#59913 Related: ClickHouse#123041 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tings-59913 Takes c14207b, which fixes the build of `gtest_functions_stress.cpp` that broke `Build (arm_tidy, 3/4)` of the previous run. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…usable `YTsaurus` and `FileLog` rows `system.engine_settings`: - `NATS` and `RabbitMQ`, as `Kafka`, set `input_format_skip_unknown_fields`, `input_format_allow_errors_ratio` and `input_format_allow_errors_num` themselves when a table does not state them (`addSettings`); these rows now show the values the engine uses, with `inherited` = 0. - `YTsaurus` no longer lists `lookup_throttler_max_requests_per_second` and `lookup_max_rows_per_query`, which only the YTsaurus dictionary sources take and the table engine rejects (`YTsaurusSettings::isDictionaryOnlySetting`). - `FileLog` no longer lists the format settings it never applies, except the header detection it always disables. Related: ClickHouse#59913 Related: ClickHouse#124738 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n `system.engine_settings` - `S3Queue` and `AzureQueue`: `min_insert_block_size_rows_for_materialized_views` and `min_insert_block_size_bytes_for_materialized_views`, since `streamToViews` overrides the query settings of the same names only for a nonzero table value. The predicate moves out of `#if USE_AWS_S3`, as `AzureQueue` uses it too. - `ExecutablePool`: `max_command_execution_time`, which a table that does not state it caps by the creating session's `max_execution_time`. `Executable` does not, so it gets no predicate. - `RabbitMQ`: `rabbitmq_vhost`, which the `rabbitmq.vhost` of the server configuration replaces. - The `Iceberg` engines: the ten compaction settings whose descriptions say they fall back to the query-level setting of the same name when not stated. The code that reads them is not in the open-source tree, so this follows their documented contract. The documentation lists the inherited settings as a list, one engine group per line. Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Brings the `inherited` column, the engine-set settings, the hidden no-effect settings and the inherited fixes of `system.engine_settings`, and current master. Conflicts: `SettingDescription.h` (comment of `enumerateCompiledDefaultsExcept`), `StorageKafkaUtils.cpp` (both `kafkaSettingsFromEngineArguments` and `enumerateKafkaSettings` kept), `YTsaurusSettings.h` (both `isDictionaryOnlySetting` and `enumerateSettings(const SettingsChanges &)` kept). Adapted to the table's `SETTINGS` (`changes`): the enumerators of `Kafka`, `NATS`, `RabbitMQ` and `FileLog` and `enumerateStreamingEngineDefaults` take the changes; the format settings the streaming engines set themselves keep a value the table states, and `input_format_allow_errors_num` follows the table's `*_skip_broken_messages` and `*_handle_error_mode`. A setting with no effect on a table (`Set`, `Hive`, `FileLog` format settings) is still shown where the table states it, in `enumerateCompiledDefaultsExcept` and in `FileLog`'s filter. The documentation of `system.table_settings` says `system.engine_settings` now lists the inherited settings with `inherited` = 1. `05295` and `05347` compare with the columns and rows `system.table_settings` shares with `system.engine_settings`. Related: ClickHouse#116543 Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ttings`, with `inherited` A setting a table takes from elsewhere unless its definition states it is no longer left out of the table's rows: it is listed with the new column `inherited` = 1 and the engine's own value, as `system.engine_settings` lists it, and with `inherited` = 0 and the stated value once the definition, its engine arguments or its named collection state it. So a table has the rows `system.engine_settings` has for its engine, plus the no-effect settings its definition states, and `WHERE NOT inherited` leaves the settings whose value the table uses. Secrets show only the engine's compiled default, never the server configuration's value. Tests: `05295` and `05347` compare all shared columns and names with `system.engine_settings` again; `05296` lists the unstated `kafka_sasl_password` with its empty default; new `05407_table_settings_inherited` checks a `Kafka` table with and without the settings stated. Related: ClickHouse#116543 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tings-59913 Conflicts resolved: `StorageFactory::StorageFeatures` keeps `enumerate_engine_settings_fn` and `is_inherited_setting_fn` before master's `get_export_access_fn`; `S3Queue` and `AzureQueue` set all three; `DataLakeStorageSettings` and `PostgreSQLSettings` keep both sides' declarations, and `isLoadedFromQueryContext` follows master's `loadFromQueryContext`. Master's new `Elasticsearch` engine enumerates its settings in `system.engine_settings`. Master renamed `allow_experimental_cleanup_old_data_files_compaction` to `enable_cleanup_old_data_files_compaction`, keeping the old name as an alias, so the Iceberg settings taken from the query and `05404_engine_settings_inherited` use the new name. Related: ClickHouse#59913 Related: ClickHouse#123041 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in master at `3e3cf06186a` through ClickHouse#123041. Conflicts resolved: `StorageFactory::StorageFeatures` keeps `settings_from_engine_arguments_fn` of this branch and `get_export_access_fn` of master, in that order; `DataLakeStorageSettings` keeps `enumerateSettings(const SettingsChanges &)` of this branch and `resolveName` of master. Master's new `Elasticsearch` engine declares `enumerateSettings` with the changes to apply, as the other settings classes do here. Related: ClickHouse#116543 Related: ClickHouse#124001 Related: ClickHouse#123041 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [be4624a] Summary: ❌
|
| const auto key = tryGetIdentifierName(function->arguments->children[0]); | ||
| const auto * literal = function->arguments->children[1]->as<ASTLiteral>(); | ||
| if (key && literal) | ||
| result.overrides.emplace_back(*key, literal->value); |
There was a problem hiding this comment.
[P2] Preserve the supported forms of named collection overrides
The engine's tryGetNamedCollectionWithOverrides accepts literal or computed keys and identifier-valued constants, and preserves identifier values in the stored definition. This narrower parser silently drops those overrides. For example, if a collection supplies the broker, topic and group but no format, ENGINE = Kafka(nc, kafka_format = CSV) creates a table using CSV, but this code ignores the ASTIdentifier value and reports kafka_format as the empty default with changed = 0. A literal key such as 'kafka_format' = 'CSV' is discarded by tryGetIdentifierName too. The same helper serves all six supported collection-backed engines.
Please share the creator's normalization, freezing resolved keys and values in the stored definition where necessary, and cover identifier values and literal keys in a focused stateless test.
There was a problem hiding this comment.
Fixed in be4624a. system.table_settings now reads the overrides as tryGetNamedCollectionWithOverrides does: an identifier stands for its name, and a literal (key or value) is taken as the text the creator puts into the collection, so a non-string literal value such as kafka_client_id = 123 is read as '123' too (before, it made the whole query fail with BAD_GET). The creator now also freezes a computed key in the stored definition as the literal of its value, as it already did for computed values, so the reader never evaluates anything. A definition written before keys were frozen can still have a computed key; that override is left out.
The new test 05816_table_settings_named_collection_override_forms covers an identifier value (kafka_format = CSV), a literal key ('kafka_format' = 'TSV'), a computed key (concat('kafka_', 'format') = 'JSONEachRow', checking the frozen key in the stored definition as well) and a numeric literal for a string setting.
| if (create->storage->settings) | ||
| for (const auto & change : withExpressionsAsText(create->storage->settings->changes, show_secrets)) | ||
| changes.push_back(change); | ||
|
|
||
| const auto & enumerate = engine->second.features.enumerate_engine_settings_fn; | ||
| auto settings = enumerate(context, changes); |
There was a problem hiding this comment.
[P2] Apply the metadata normalization used when attaching an existing table
For an existing TimeSeries table whose metadata predates versioning, StorageTimeSeries::makeNormalizedCreateQuery normalizes a clone at attachment: a missing version becomes 0, and a missing recent_samples_ttl_seconds becomes 0 when there is no recent-samples target. tryGetCreateTableQuery here reads the original metadata file, so neither adjustment is present in changes. Enumerating a fresh TimeSeriesSettings therefore reports version = 11 and recent_samples_ttl_seconds = 345600, both with inherited = 0, for a table that actually uses version 0 and has no recent-samples target. These incorrect values also survive the documented WHERE NOT inherited filter.
Please enumerate the normalized settings of the existing definition, or the table's normalized settings snapshot, and add a regression case using supported legacy metadata.
There was a problem hiding this comment.
Fixed in be4624a. An engine can now give StorageFactory::StorageFeatures::normalize_stored_definition_fn, which normalizes the stored definition the way the creator does on ATTACH, without reading anything outside the definition. TimeSeries gives it: it calls normalizeTimeSeriesDefinition with LoadingStrictnessLevel::ATTACH on a clone when the version is supported. system.table_settings applies it before collecting the changes, so a legacy definition reports version = 0 and recent_samples_ttl_seconds = 0, both changed = 1 and inherited = 0.
The regression test 05817_table_settings_time_series_legacy_definition attaches a definition without either setting (a full ATTACH TABLE keeps it as given), checks that the stored definition indeed has neither, and checks both rows.
…tings-59913 # Conflicts: # src/Storages/MergeTree/registerStorageMergeTree.cpp # src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp # src/Storages/StorageMemory.cpp # src/Storages/StorageSet.cpp
Master moved the disk settings code of `MergeTreeSettings.cpp` to `MergeTreeSettingsDisks.cpp` together with the include of `Interpreters/Context.h`, which `MergeTreeSettings::enumerateEngineSettings` and `MergeTreeSettings::enumerateReplicatedEngineSettings` still use. Related: ClickHouse#59913 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tings-59913 # Conflicts: # src/Storages/StorageFactory.h
`modernize-use-nodiscard` of clang-tidy is enabled on master since 2026-11-15, and the new `enumerateSettings` and `enumerateSettingsWithConstraints` const methods of the engine settings failed the tidy build without the attribute. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123041&sha=cd63e43cc1f37c1d7ee95901c404cc54aace9c1b&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 Related: ClickHouse#123041 Related: ClickHouse#126158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s-116543 # Conflicts: # src/Storages/Distributed/DistributedSettings.h # src/Storages/Elasticsearch/ElasticsearchSettings.h # src/Storages/ExecutableSettings.h # src/Storages/FileLog/FileLogSettings.h # src/Storages/GenerateRandomSettings.h # src/Storages/Hive/HiveSettings.h # src/Storages/Kafka/KafkaSettings.h # src/Storages/MemorySettings.h # src/Storages/MergeTree/MergeTreeSettings.h # src/Storages/MySQL/MySQLSettings.h # src/Storages/NATS/NATSSettings.h # src/Storages/ObjectStorage/DataLakes/DataLakeStorageSettings.h # src/Storages/ObjectStorage/StorageObjectStorageSettings.h # src/Storages/ObjectStorageQueue/ObjectStorageQueueSettings.h # src/Storages/PostgreSQL/MaterializedPostgreSQLSettings.h # src/Storages/PostgreSQL/PostgreSQLSettings.h # src/Storages/QueryRunnerSettings.h # src/Storages/RabbitMQ/RabbitMQSettings.h # src/Storages/RocksDB/RocksDBSettings.h # src/Storages/SetSettings.h # src/Storages/TimeSeries/TimeSeriesSettings.h # src/Storages/YTsaurus/YTsaurusSettings.h
…system.table_settings` as the engine does `system.table_settings` read only the overrides of a named collection written as `identifier = literal`, so an override whose value is an identifier (`kafka_format = CSV`) or whose key is a literal or an expression was left out, and a literal value that is not a string (`kafka_client_id = 123`) made the query fail with `BAD_GET`, while the engine takes every value as text. The overrides are now read as the engine's creator reads them: an identifier stands for its name and a literal for its value as text. The stored definition of a table now keeps the key of an override that is an expression as the literal of its value, as it already did for the value, when the key is spelled as a plain name. A `TimeSeries` table whose stored definition predates the `version` setting is converted when it is attached (`version = 0`, and `recent_samples_ttl_seconds = 0` without a recent samples target), but `system.table_settings` showed the defaults for a new table. An engine can now give `normalize_stored_definition_fn`, which normalizes the stored definition as the creator does on `ATTACH`, without reading anything outside it; `TimeSeries` gives it. The expected output of `05315_mongodb_connection_options_secrets` changes for an `options` override written with an expression key: the stored key is now readable, so only the secret part of the value is hidden. ClickHouse#124001 (comment) ClickHouse#124001 (comment) Related: ClickHouse#116543 Related: ClickHouse#124001 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Depends on #123041, which adds
system.engine_settings; until it is merged, this diff also shows its commits. The change of this PR can be seen on its own here: buggins/ClickHouse@system-engine-settings-59913...system-table-settings-116543Closes: #65817
Related: #116543
Related: #123041
Related: #118544
Adds
system.table_settings: the engine-specific settings of each table, one row per table and setting, with the columns ofsystem.engine_settingsplusdatabaseandtable. A table has exactly the rowssystem.engine_settingshas for its engine, each with the table's storedSETTINGSclause applied, so values changed byALTER TABLE ... MODIFY SETTINGare shown as well. A setting the table takes from elsewhere (the format settings, thePostgreSQLconnection pool settings, the block size and poll settings of the streaming engines, and others) hasinherited= 1 and the engine's own value, as insystem.engine_settings, until the definition, its engine arguments or its named collection state it; theninheritedis 0 andvalueis the stated value.WHERE NOT inheritedleaves the settings whose value the table uses.Values come from the stored definition, not from the storage object, in the order the engine's creator applies them: the engine's row (the compiled default, or the server-level settings for the
MergeTreefamily andDistributed/Remote/RemoteSecure), then the named collection the engine arguments start with and its overrides (Kafka,NATS,RabbitMQ,MySQL,PostgreSQL,YTsaurus), or else the settings the engine arguments give (the positional arguments ofKafka, through a newStorageFeatureshook whose list theKafkacreator shares), then theSETTINGSclause. For this the engine settings hook from #123041 takes the table's changes as one more parameter; each settings class applies only the names it declares, so an alias such asmonitor_batch_insertsand thes3queue_prefix ofS3Queueresolve as when the table is created, and a stateddiskresetsstorage_policyas theMergeTreecreator does. The overrides are read as the creator reads them: an identifier value stands for its name, and a literal key or value is taken as the text the creator puts into the collection; the creator keeps a computed key or value in the stored definition as the literal it evaluated to, so nothing is evaluated here. A value written as an expression, such asdisk = disk(...), is shown as written. A definition the engine converts when the table is attached is read as converted, through anotherStorageFeatureshook that normalizes it without reading anything outside it: aTimeSeriesdefinition that predates theversionsetting showsversion= 0, as the table uses, not the default for a new table.05816_table_settings_named_collection_override_formsand05817_table_settings_time_series_legacy_definitioncheck both.Access. Reading the table needs
SELECTon it, and a table is shown only to a user who may see it throughSHOW TABLES, and its database throughSHOW DATABASES, as insystem.tables. A condition ondatabaseandtableis applied to the visible names before any definition is read, so it cannot probe hidden ones (athrowIfinWHERE), and reading one table does not read them all: 0.003 s for one table against 0.18 s for a full scan of a server with about 470 tables (290 of them with engine settings), on a debug build.Size of the output. A table of an engine that accepts format settings (
Kafka,S3,NATS, the data lake engines, ...) has several hundred rows, as its engine insystem.engine_settings; listing them costs nothing beyond building them, and a condition ondatabaseandtablestill narrows what is built.Secrets are hidden by the rules
SHOW CREATE TABLEuses (renderSecretChangeValue) and shown as[HIDDEN]; a value only partly secret, such as a connection string with an account key, is hidden as a whole, and a secret left at its empty default is not reported as hidden. An inherited secret, such as an unstatedkafka_sasl_password, shows the engine's compiled default, never the server configuration's value. A value a named collection supplies is shown assystem.named_collectionsshows it: only withSHOW NAMED COLLECTIONSon that collection,SHOW NAMED COLLECTIONS SECRETSand secrets display allowed, otherwise as[HIDDEN], which still tells that the collection supplies the setting. With the server'sdisplay_secrets_in_show_and_selectoff, the default, such values are always hidden. A collection changed after the table was created to a value the setting cannot take gives an error naming the collection and the table, not the value.Scope. The issue settled on
system.table_settingswithSHOW TABLE SETTINGSas thin sugar over it, and bothsourceandchanged. This PR haschanged, and:sourcecolumn. In Addsystem.table_settings,system.engine_settingsandSHOW TABLE SETTINGS#118544, recording where each value came from took about 700 changedsrclines (theBaseSettingschanges,SettingOrigin, most ofTableSettingsHelpers, and about 120 lines across the engines), about as many as this whole PR (about 800: 673 added, 128 removed). If it is wanted, it can come as a separate PR under a separate issue.SHOW TABLE SETTINGSyet: it is still to be decided whether it joins this PR, comes as a separate PR, or is dropped. It would be a rewrite into aSELECTover this table, as in Addsystem.table_settings,system.engine_settingsandSHOW TABLE SETTINGS#118544. HenceRelated:, notCloses:, for SHOW TABLE SETTINGS #116543.system.engine_settings#123041.Not covered. Tables of engines without a settings class of their own (
File,URL,Join, theLogfamily), views, dictionaries and tables created from a table function. Tables in data lake catalogs, and inMySQL/PostgreSQLdatabases unlessshow_remote_databases_in_system_tablesis on, as insystem.tables. Settings an engine accepts but never reads, whichsystem.engine_settingsleaves out (the format settings ofSetandHive, and those ofFileLogother than the header detection), are shown only where the definition states them. Settings a table of the engine cannot use, whichsystem.engine_settingsleaves out too, are not shown even where a definition states them:materialized_postgresql_use_extended_date_and_time_types,materialized_postgresql_schema_listandmaterialized_postgresql_tables_listofMaterializedPostgreSQL, which a table rejects or overwrites, and the deprecated catalog settings of the data lake engines, which a table rejects; a stated value of these is not what the table uses.05347_table_settings_data_lake_tablechecks a data lake table, and05407_table_settings_inheritedaKafkatable with and without inherited settings stated. Settings that the deprecatedMergeTreesyntax gives as engine arguments, such asindex_granularityinMergeTree(date, key, 8192), are not applied; the documentation says so. WhatS3QueueandAzureQueuekeep in Keeper is not shown (seesystem.s3_queue_settings). Macros are shown as written. The column definitions are copied fromsystem.engine_settings, as that table copiessystem.merge_tree_settings; sharing them can follow once #123041 is settled.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the
system.table_settingssystem table, which shows the engine-specific settings of each table: the engine's defaults with the table'sSETTINGSclause,ALTER TABLE ... MODIFY SETTINGchanges and named collection values applied. Secrets are hidden as inSHOW CREATE TABLE.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/124001]