Skip to content

Commit 14e7ee5

Browse files
authored
Merge pull request #3686 from ClickHouse/enhance_settings_generation
Settings: add version history for session settings
2 parents c0a0ab5 + f7bab53 commit 14e7ee5

File tree

6 files changed

+167
-6
lines changed

6 files changed

+167
-6
lines changed

scripts/settings/session-settings.sql

+54-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,68 @@
11
WITH
22
'Settings.cpp' AS cpp_file,
3+
settings_changes AS
4+
(
5+
SELECT
6+
setting_name AS name,
7+
'[' ||
8+
arrayStringConcat(
9+
arrayMap(
10+
(i, x) -> '{' ||
11+
'"id": "row-' || toString(i) || '",' ||
12+
'"items": [' ||
13+
'{"label": "' || toString(x.1) || '"},' ||
14+
'{"label": "' || toString(x.2) || '"},' ||
15+
'{"label": "' || replaceRegexpAll(x.3, '([\\"])', '\\\\$1') || '"}' ||
16+
']' ||
17+
'}',
18+
arrayEnumerate(groupArray((version, default_value, comment))),
19+
groupArray((version, default_value, comment))
20+
),
21+
', '
22+
) ||
23+
']' AS rows
24+
FROM
25+
(
26+
SELECT
27+
(arrayJoin(changes) AS change).1 AS setting_name,
28+
version,
29+
change.3 AS default_value,
30+
change.4 AS comment
31+
FROM system.settings_changes
32+
WHERE type = 'Session'
33+
ORDER BY setting_name, version DESC
34+
)
35+
GROUP BY setting_name
36+
),
337
settings_from_cpp AS
438
(
5-
SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name
6-
FROM file(cpp_file, LineAsString)
7-
WHERE match(line, '^\\s*DECLARE\\(')
39+
SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name
40+
FROM file(cpp_file, LineAsString)
41+
WHERE match(line, '^\\s*DECLARE\\(')
42+
),
43+
settings_with_change_history AS
44+
(
45+
SELECT
46+
a.*,
47+
b.*
48+
FROM
49+
system.settings AS a
50+
INNER JOIN settings_changes as b
51+
ON a.name = b.name
52+
WHERE name IN settings_from_cpp
853
),
954
main_content AS
1055
(
1156
SELECT
12-
format('## {}{}{}{}{}{}\n\n',
57+
format('## {}{}{}{}{}{}{}\n\n',
1358
name,
1459
' {#'||name||'} \n\n',
1560
multiIf(tier == 'Experimental', '<ExperimentalBadge/>\n\n', tier == 'Beta', '<BetaBadge/>\n\n', ''),
1661
if(description LIKE '%Only has an effect in ClickHouse Cloud%', '<CloudAvailableBadge/>\n\n', ''),
17-
if(type != '' AND default != '', format('|Type|Default|\n|---|---|\n|`{}`|`{}`|\n\n',type, default), ''),
62+
if(type != '' AND default != '', format('<SettingsInfoBlock type="{}" default_value="{}" />', type, default), ''),
63+
if(rows != '', printf('<VersionHistory rows={%s}/>\n\n', rows), ''),
1864
replaceOne(trim(BOTH '\\n' FROM description), ' and [MaterializedMySQL](../../engines/database-engines/materialized-mysql.md)',''))
19-
FROM system.settings WHERE name IN settings_from_cpp
65+
FROM settings_with_change_history
2066
ORDER BY name
2167
),
2268
'---
@@ -30,6 +76,8 @@ description: ''Settings which are found in the ``system.settings`` table.''
3076
import ExperimentalBadge from \'@theme/badges/ExperimentalBadge\';
3177
import BetaBadge from \'@theme/badges/BetaBadge\';
3278
import CloudAvailableBadge from \'@theme/badges/CloudAvailableBadge\';
79+
import SettingsInfoBlock from \'@theme/SettingsInfoBlock/SettingsInfoBlock\';
80+
import VersionHistory from \'@theme/VersionHistory/VersionHistory\';
3381
3482
<!-- Autogenerated -->
3583
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).

src/theme/DocRoot/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import DocRoot from '@theme-original/DocRoot';
3+
import {ClickUIProvider} from '@clickhouse/click-ui/bundled';
4+
import {useColorMode} from "@docusaurus/theme-common";
5+
export default function DocRootWrapper(props) {
6+
const { colorMode } = useColorMode();
7+
return (
8+
<>
9+
<ClickUIProvider theme={colorMode}>
10+
<DocRoot {...props} />
11+
</ClickUIProvider>
12+
</>
13+
);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Accordion, Table, Container } from '@clickhouse/click-ui/bundled'
2+
import styles from './styles.module.css';
3+
4+
const SettingsInfoBlock = ({type, default_value}) => {
5+
return(
6+
<div
7+
className={styles.settingsInfoBlock}
8+
>
9+
<Table
10+
headers={[
11+
{
12+
label: 'Type'
13+
},
14+
{
15+
label: 'Default value'
16+
},
17+
]}
18+
rows={
19+
[
20+
{
21+
id: "row-1",
22+
items: [
23+
{label: `${type}`},
24+
{label: `${default_value}`}
25+
]
26+
}
27+
]
28+
}
29+
size="sm"
30+
className={styles.table}
31+
></Table>
32+
</div>
33+
)
34+
}
35+
36+
export default SettingsInfoBlock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.settingsInfoBlock {
2+
width: fit-content;
3+
max-width: 100%;
4+
word-wrap: break-word;
5+
overflow-wrap: break-word;
6+
margin-bottom: 15px;
7+
padding: 0;
8+
}
9+
10+
.table {
11+
overflow-x: auto;
12+
display: block;
13+
margin-bottom: 0px;
14+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Accordion, Table} from '@clickhouse/click-ui/bundled'
2+
import styles from './styles.module.css';
3+
4+
const VersionHistoryDropdown = ({rows=[]}) => {
5+
return(
6+
<div
7+
className={styles.versionHistory}
8+
>
9+
<Accordion
10+
color="default"
11+
title="Version history"
12+
size="sm"
13+
gap="md"
14+
>
15+
<Table
16+
headers={[
17+
{
18+
label: 'Version'
19+
},
20+
{
21+
label: 'Default value'
22+
},
23+
{
24+
label: 'Comment'
25+
}
26+
]}
27+
rows={rows}
28+
size="sm"
29+
className={styles.table}
30+
></Table>
31+
</Accordion>
32+
</div>
33+
)
34+
}
35+
36+
export default VersionHistoryDropdown
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.versionHistory {
2+
width: fit-content;
3+
max-width: 100%;
4+
word-wrap: break-word;
5+
overflow-wrap: break-word;
6+
margin-bottom: 15px;
7+
}
8+
9+
.table {
10+
overflow-x: auto;
11+
display: block;
12+
margin-bottom: 0px;
13+
}

0 commit comments

Comments
 (0)