Skip to content

Commit a19659b

Browse files
committed
update scripts to show aliases
1 parent d513ff9 commit a19659b

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

scripts/settings/format-settings.sql

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,31 @@ WITH
66
FROM file(cpp_file, LineAsString)
77
WHERE match(line, '^\\s*DECLARE\\(')
88
),
9+
setting_aliases AS
10+
(
11+
SELECT
12+
alias_for,
13+
groupArray(name) AS aliases
14+
FROM system.settings
15+
WHERE alias_for != ''
16+
AND alias_for IN settings_from_cpp
17+
GROUP BY alias_for
18+
),
919
main_content AS
1020
(
11-
SELECT format('## {} {} {} \n\n{}\n\n{}\n\n',
12-
name,
13-
'{#'||name||'}',
14-
multiIf(tier == 'Experimental', '<ExperimentalBadge/>', tier == 'Beta', '<BetaBadge/>', ''),
15-
if(type != '' AND default != '', format('<SettingsInfoBlock type="{}" default_value="{}" />', type, default), ''),
16-
trim(BOTH '\\n' FROM description))
17-
FROM system.settings WHERE name IN settings_from_cpp
18-
ORDER BY name
21+
SELECT format('## {} {} {} \n\n{}{}\n\n{}\n\n',
22+
s.name,
23+
'{#'||s.name||'}',
24+
multiIf(s.tier == 'Experimental', '<ExperimentalBadge/>', s.tier == 'Beta', '<BetaBadge/>', ''),
25+
if(sa.aliases IS NOT NULL AND length(sa.aliases) > 0,
26+
'**Aliases**: ' || arrayStringConcat(arrayMap(x -> '`' || x || '`', sa.aliases), ', ') || '\n\n',
27+
''),
28+
if(s.type != '' AND s.default != '', format('<SettingsInfoBlock type="{}" default_value="{}" />', s.type, s.default), ''),
29+
trim(BOTH '\\n' FROM s.description))
30+
FROM system.settings s
31+
LEFT JOIN setting_aliases sa ON s.name = sa.alias_for
32+
WHERE s.name IN settings_from_cpp
33+
ORDER BY s.name
1934
),
2035
'' ||
2136
'---

scripts/settings/session-settings.sql

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ WITH
4040
FROM file(cpp_file, LineAsString)
4141
WHERE match(line, '^\\s*DECLARE(?:_WITH_ALIAS)?\\(')
4242
),
43+
setting_aliases AS
44+
(
45+
SELECT
46+
alias_for,
47+
groupArray(name) AS aliases
48+
FROM system.settings
49+
WHERE alias_for != ''
50+
AND alias_for IN settings_from_cpp
51+
GROUP BY alias_for
52+
),
4353
settings_with_change_history AS
4454
(
4555
SELECT
@@ -54,11 +64,14 @@ WITH
5464
main_content AS
5565
(
5666
SELECT
57-
format('## {}{}{}{}{}{}{}\n\n',
67+
format('## {}{}{}{}{}{}{}{}\n\n',
5868
name,
5969
' {#'||name||'} \n\n',
6070
multiIf(tier == 'Experimental', '<ExperimentalBadge/>\n\n', tier == 'Beta', '<BetaBadge/>\n\n', ''),
6171
if(description LIKE '%Only has an effect in ClickHouse Cloud%', '<CloudOnlyBadge/>\n\n', ''),
72+
if(sa.aliases IS NOT NULL AND length(sa.aliases) > 0,
73+
'**Aliases**: ' || arrayStringConcat(arrayMap(x -> '`' || x || '`', sa.aliases), ', ') || '\n\n',
74+
''),
6275
if(
6376
type != '' AND default != '',
6477
format(
@@ -71,6 +84,7 @@ WITH
7184
if(rows != '', printf('\n\n<VersionHistory rows={%s}/>\n\n', rows), ''),
7285
replaceOne(trim(BOTH '\\n' FROM description), ' and [MaterializedMySQL](../../engines/database-engines/materialized-mysql.md)',''))
7386
FROM settings_with_change_history
87+
LEFT JOIN setting_aliases sa ON settings_with_change_history.name = sa.alias_for
7488
ORDER BY name
7589
),
7690
'---

0 commit comments

Comments
 (0)