Skip to content

Settings: add version history for session settings #3686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions scripts/settings/session-settings.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,68 @@
WITH
'Settings.cpp' AS cpp_file,
settings_changes AS
(
SELECT
setting_name AS name,
'[' ||
arrayStringConcat(
arrayMap(
(i, x) -> '{' ||
'"id": "row-' || toString(i) || '",' ||
'"items": [' ||
'{"label": "' || toString(x.1) || '"},' ||
'{"label": "' || toString(x.2) || '"},' ||
'{"label": "' || replaceRegexpAll(x.3, '([\\"])', '\\\\$1') || '"}' ||
']' ||
'}',
arrayEnumerate(groupArray((version, default_value, comment))),
groupArray((version, default_value, comment))
),
', '
) ||
']' AS rows
FROM
(
SELECT
(arrayJoin(changes) AS change).1 AS setting_name,
version,
change.3 AS default_value,
change.4 AS comment
FROM system.settings_changes
WHERE type = 'Session'
ORDER BY setting_name, version DESC
)
GROUP BY setting_name
),
settings_from_cpp AS
(
SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name
FROM file(cpp_file, LineAsString)
WHERE match(line, '^\\s*DECLARE\\(')
SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name
FROM file(cpp_file, LineAsString)
WHERE match(line, '^\\s*DECLARE\\(')
),
settings_with_change_history AS
(
SELECT
a.*,
b.*
FROM
system.settings AS a
INNER JOIN settings_changes as b
ON a.name = b.name
WHERE name IN settings_from_cpp
),
main_content AS
(
SELECT
format('## {}{}{}{}{}{}\n\n',
format('## {}{}{}{}{}{}{}\n\n',
name,
' {#'||name||'} \n\n',
multiIf(tier == 'Experimental', '<ExperimentalBadge/>\n\n', tier == 'Beta', '<BetaBadge/>\n\n', ''),
if(description LIKE '%Only has an effect in ClickHouse Cloud%', '<CloudAvailableBadge/>\n\n', ''),
if(type != '' AND default != '', format('|Type|Default|\n|---|---|\n|`{}`|`{}`|\n\n',type, default), ''),
if(type != '' AND default != '', format('<SettingsInfoBlock type="{}" default_value="{}" />', type, default), ''),
if(rows != '', printf('<VersionHistory rows={%s}/>\n\n', rows), ''),
replaceOne(trim(BOTH '\\n' FROM description), ' and [MaterializedMySQL](../../engines/database-engines/materialized-mysql.md)',''))
FROM system.settings WHERE name IN settings_from_cpp
FROM settings_with_change_history
ORDER BY name
),
'---
Expand All @@ -30,6 +76,8 @@ description: ''Settings which are found in the ``system.settings`` table.''
import ExperimentalBadge from \'@theme/badges/ExperimentalBadge\';
import BetaBadge from \'@theme/badges/BetaBadge\';
import CloudAvailableBadge from \'@theme/badges/CloudAvailableBadge\';
import SettingsInfoBlock from \'@theme/SettingsInfoBlock/SettingsInfoBlock\';
import VersionHistory from \'@theme/VersionHistory/VersionHistory\';

<!-- Autogenerated -->
All below settings are also available in table [system.settings](/docs/operations/system-tables/settings). These settings are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).
Expand Down
14 changes: 14 additions & 0 deletions src/theme/DocRoot/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import DocRoot from '@theme-original/DocRoot';
import {ClickUIProvider} from '@clickhouse/click-ui/bundled';
import {useColorMode} from "@docusaurus/theme-common";
export default function DocRootWrapper(props) {
const { colorMode } = useColorMode();
return (
<>
<ClickUIProvider theme={colorMode}>
<DocRoot {...props} />
</ClickUIProvider>
</>
);
}
36 changes: 36 additions & 0 deletions src/theme/SettingsInfoBlock/SettingsInfoBlock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Accordion, Table, Container } from '@clickhouse/click-ui/bundled'
import styles from './styles.module.css';

const SettingsInfoBlock = ({type, default_value}) => {
return(
<div
className={styles.settingsInfoBlock}
>
<Table
headers={[
{
label: 'Type'
},
{
label: 'Default value'
},
]}
rows={
[
{
id: "row-1",
items: [
{label: `${type}`},
{label: `${default_value}`}
]
}
]
}
size="sm"
className={styles.table}
></Table>
</div>
)
}

export default SettingsInfoBlock
14 changes: 14 additions & 0 deletions src/theme/SettingsInfoBlock/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.settingsInfoBlock {
width: fit-content;
max-width: 100%;
word-wrap: break-word;
overflow-wrap: break-word;
margin-bottom: 15px;
padding: 0;
}

.table {
overflow-x: auto;
display: block;
margin-bottom: 0px;
}
36 changes: 36 additions & 0 deletions src/theme/VersionHistory/VersionHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Accordion, Table} from '@clickhouse/click-ui/bundled'
import styles from './styles.module.css';

const VersionHistoryDropdown = ({rows=[]}) => {
return(
<div
className={styles.versionHistory}
>
<Accordion
color="default"
title="Version history"
size="sm"
gap="md"
>
<Table
headers={[
{
label: 'Version'
},
{
label: 'Default value'
},
{
label: 'Comment'
}
]}
rows={rows}
size="sm"
className={styles.table}
></Table>
</Accordion>
</div>
)
}

export default VersionHistoryDropdown
13 changes: 13 additions & 0 deletions src/theme/VersionHistory/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.versionHistory {
width: fit-content;
max-width: 100%;
word-wrap: break-word;
overflow-wrap: break-word;
margin-bottom: 15px;
}

.table {
overflow-x: auto;
display: block;
margin-bottom: 0px;
}
Loading