From a34b5dff2a5da249dba551fdd07440677a14fbd2 Mon Sep 17 00:00:00 2001
From: Shaun Struwig <41984034+Blargian@users.noreply.github.com>
Date: Wed, 16 Apr 2025 17:25:44 +0200
Subject: [PATCH 1/5] Add version history for session settings
---
scripts/settings/session-settings.sql | 60 +++++++++++++++++--
.../SettingsInfoBlock/SettingsInfoBlock.js | 40 +++++++++++++
src/theme/SettingsInfoBlock/styles.module.css | 14 +++++
src/theme/VersionHistory/VersionHistory.js | 40 +++++++++++++
src/theme/VersionHistory/styles.module.css | 13 ++++
5 files changed, 161 insertions(+), 6 deletions(-)
create mode 100644 src/theme/SettingsInfoBlock/SettingsInfoBlock.js
create mode 100644 src/theme/SettingsInfoBlock/styles.module.css
create mode 100644 src/theme/VersionHistory/VersionHistory.js
create mode 100644 src/theme/VersionHistory/styles.module.css
diff --git a/scripts/settings/session-settings.sql b/scripts/settings/session-settings.sql
index 40024a41263..90c03e4238c 100644
--- a/scripts/settings/session-settings.sql
+++ b/scripts/settings/session-settings.sql
@@ -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 ASC
+ )
+ 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', '\n\n', tier == 'Beta', '\n\n', ''),
if(description LIKE '%Only has an effect in ClickHouse Cloud%', '\n\n', ''),
- if(type != '' AND default != '', format('|Type|Default|\n|---|---|\n|`{}`|`{}`|\n\n',type, default), ''),
+ if(type != '' AND default != '', format('', type, default), ''),
+ if(rows != '', printf('\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
),
'---
@@ -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\';
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).
diff --git a/src/theme/SettingsInfoBlock/SettingsInfoBlock.js b/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
new file mode 100644
index 00000000000..4ee0aa6d3e2
--- /dev/null
+++ b/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
@@ -0,0 +1,40 @@
+import { Accordion, Table, ClickUIProvider, Container } from '@clickhouse/click-ui/bundled'
+import { useColorMode } from '@docusaurus/theme-common'
+import styles from './styles.module.css';
+
+const SettingsInfoBlock = ({type, default_value}) => {
+ const { colorMode } = useColorMode();
+ return(
+
+
+
+ )
+}
+
+export default SettingsInfoBlock
diff --git a/src/theme/SettingsInfoBlock/styles.module.css b/src/theme/SettingsInfoBlock/styles.module.css
new file mode 100644
index 00000000000..f38fc0921a4
--- /dev/null
+++ b/src/theme/SettingsInfoBlock/styles.module.css
@@ -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;
+}
\ No newline at end of file
diff --git a/src/theme/VersionHistory/VersionHistory.js b/src/theme/VersionHistory/VersionHistory.js
new file mode 100644
index 00000000000..af24f484d52
--- /dev/null
+++ b/src/theme/VersionHistory/VersionHistory.js
@@ -0,0 +1,40 @@
+import { Accordion, Table, ClickUIProvider, Container } from '@clickhouse/click-ui/bundled'
+import { useColorMode } from '@docusaurus/theme-common'
+import styles from './styles.module.css';
+
+const VersionHistoryDropdown = ({rows=[]}) => {
+ const { colorMode } = useColorMode();
+ return(
+
+
+
+ )
+}
+
+export default VersionHistoryDropdown
diff --git a/src/theme/VersionHistory/styles.module.css b/src/theme/VersionHistory/styles.module.css
new file mode 100644
index 00000000000..cfe5e305443
--- /dev/null
+++ b/src/theme/VersionHistory/styles.module.css
@@ -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;
+}
\ No newline at end of file
From 70acee970bf7a6326d42901616e6a389116dd6de Mon Sep 17 00:00:00 2001
From: Shaun Struwig <41984034+Blargian@users.noreply.github.com>
Date: Wed, 16 Apr 2025 17:27:51 +0200
Subject: [PATCH 2/5] new lines end of files
---
src/theme/SettingsInfoBlock/styles.module.css | 2 +-
src/theme/VersionHistory/styles.module.css | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/theme/SettingsInfoBlock/styles.module.css b/src/theme/SettingsInfoBlock/styles.module.css
index f38fc0921a4..c9b3af7ed25 100644
--- a/src/theme/SettingsInfoBlock/styles.module.css
+++ b/src/theme/SettingsInfoBlock/styles.module.css
@@ -11,4 +11,4 @@
overflow-x: auto;
display: block;
margin-bottom: 0px;
-}
\ No newline at end of file
+}
diff --git a/src/theme/VersionHistory/styles.module.css b/src/theme/VersionHistory/styles.module.css
index cfe5e305443..9e763caf6f7 100644
--- a/src/theme/VersionHistory/styles.module.css
+++ b/src/theme/VersionHistory/styles.module.css
@@ -10,4 +10,4 @@
overflow-x: auto;
display: block;
margin-bottom: 0px;
-}
\ No newline at end of file
+}
From 6817d65a1912d2f1728c1ad14a47a63c66ef2fe7 Mon Sep 17 00:00:00 2001
From: Shaun Struwig <41984034+Blargian@users.noreply.github.com>
Date: Wed, 16 Apr 2025 17:37:30 +0200
Subject: [PATCH 3/5] Switch order of container element and ClickUIProvider
---
src/theme/SettingsInfoBlock/SettingsInfoBlock.js | 4 ++--
src/theme/VersionHistory/VersionHistory.js | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/theme/SettingsInfoBlock/SettingsInfoBlock.js b/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
index 4ee0aa6d3e2..7918cdce32a 100644
--- a/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
+++ b/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
@@ -5,10 +5,10 @@ import styles from './styles.module.css';
const SettingsInfoBlock = ({type, default_value}) => {
const { colorMode } = useColorMode();
return(
-
+
{
size="sm"
className={styles.table}
>
+
-
)
}
diff --git a/src/theme/VersionHistory/VersionHistory.js b/src/theme/VersionHistory/VersionHistory.js
index af24f484d52..b707b69103d 100644
--- a/src/theme/VersionHistory/VersionHistory.js
+++ b/src/theme/VersionHistory/VersionHistory.js
@@ -5,10 +5,10 @@ import styles from './styles.module.css';
const VersionHistoryDropdown = ({rows=[]}) => {
const { colorMode } = useColorMode();
return(
-
+
{
className={styles.table}
>
+
-
)
}
From 893e5356272ec00b46b054b01cbdf774243b2daa Mon Sep 17 00:00:00 2001
From: Shaun Struwig <41984034+Blargian@users.noreply.github.com>
Date: Wed, 16 Apr 2025 17:46:41 +0200
Subject: [PATCH 4/5] Refactor for performance
---
src/theme/DocRoot/index.js | 14 ++++++++++++++
src/theme/SettingsInfoBlock/SettingsInfoBlock.js | 6 +-----
src/theme/VersionHistory/VersionHistory.js | 6 +-----
3 files changed, 16 insertions(+), 10 deletions(-)
create mode 100644 src/theme/DocRoot/index.js
diff --git a/src/theme/DocRoot/index.js b/src/theme/DocRoot/index.js
new file mode 100644
index 00000000000..7de0dd40126
--- /dev/null
+++ b/src/theme/DocRoot/index.js
@@ -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 (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/src/theme/SettingsInfoBlock/SettingsInfoBlock.js b/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
index 7918cdce32a..bc87364a959 100644
--- a/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
+++ b/src/theme/SettingsInfoBlock/SettingsInfoBlock.js
@@ -1,14 +1,11 @@
-import { Accordion, Table, ClickUIProvider, Container } from '@clickhouse/click-ui/bundled'
-import { useColorMode } from '@docusaurus/theme-common'
+import { Accordion, Table, Container } from '@clickhouse/click-ui/bundled'
import styles from './styles.module.css';
const SettingsInfoBlock = ({type, default_value}) => {
- const { colorMode } = useColorMode();
return(
-
{
size="sm"
className={styles.table}
>
-
)
}
diff --git a/src/theme/VersionHistory/VersionHistory.js b/src/theme/VersionHistory/VersionHistory.js
index b707b69103d..a0ea2a452e2 100644
--- a/src/theme/VersionHistory/VersionHistory.js
+++ b/src/theme/VersionHistory/VersionHistory.js
@@ -1,14 +1,11 @@
-import { Accordion, Table, ClickUIProvider, Container } from '@clickhouse/click-ui/bundled'
-import { useColorMode } from '@docusaurus/theme-common'
+import { Accordion, Table} from '@clickhouse/click-ui/bundled'
import styles from './styles.module.css';
const VersionHistoryDropdown = ({rows=[]}) => {
- const { colorMode } = useColorMode();
return(
-
{
className={styles.table}
>
-
)
}
From f7bab53de031b215662505aefa1cebfc888aecdd Mon Sep 17 00:00:00 2001
From: Shaun Struwig <41984034+Blargian@users.noreply.github.com>
Date: Wed, 16 Apr 2025 18:18:42 +0200
Subject: [PATCH 5/5] Fix version ordering
---
scripts/settings/session-settings.sql | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/settings/session-settings.sql b/scripts/settings/session-settings.sql
index 90c03e4238c..100faccd3c1 100644
--- a/scripts/settings/session-settings.sql
+++ b/scripts/settings/session-settings.sql
@@ -30,7 +30,7 @@ WITH
change.4 AS comment
FROM system.settings_changes
WHERE type = 'Session'
- ORDER BY setting_name, version ASC
+ ORDER BY setting_name, version DESC
)
GROUP BY setting_name
),