|
16 | 16 | exit 1 |
17 | 17 | fi |
18 | 18 |
|
19 | | - |
20 | 19 | target_dir=$(dirname "$(dirname "$(realpath "$0")")") |
21 | 20 | SCRIPT_NAME=$(basename "$0") |
| 21 | +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
22 | 22 | tmp_dir="$target_dir/tmp" |
23 | 23 |
|
24 | 24 | mkdir -p "$tmp_dir" || exit 1 |
|
41 | 41 |
|
42 | 42 | echo "Downloaded to: $script_path" |
43 | 43 | echo "[$SCRIPT_NAME] Auto-generating settings" |
44 | | - |
45 | | -# Autogenerate Format settings |
46 | 44 | chmod +x "$script_path" || { echo "Error: Failed to set execute permission"; exit 1; } |
47 | | - |
48 | 45 | root=$(dirname "$(dirname "$(realpath "$tmp_dir")")") |
49 | 46 |
|
50 | | -./clickhouse -q " |
51 | | -WITH |
52 | | -'FormatFactorySettings.h' AS cpp_file, |
53 | | -settings_from_cpp AS |
54 | | -( |
55 | | - SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name |
56 | | - FROM file(cpp_file, LineAsString) |
57 | | - WHERE match(line, '^\\s*DECLARE\\(') |
58 | | -), |
59 | | -main_content AS |
60 | | -( |
61 | | - SELECT format('## {} {}\\n{}\\n\\nType: \`{}\`\\n\\nDefault: \`{}\`\\n\\n{}\\n\\n', |
62 | | - name, '{#'||name||'}', multiIf(tier == 'Experimental', '<ExperimentalBadge/>', tier == 'Beta', '<BetaBadge/>', ''), type, default, trim(BOTH '\\n' FROM description)) |
63 | | - FROM system.settings WHERE name IN settings_from_cpp |
64 | | - ORDER BY name |
65 | | -), |
66 | | -'--- |
67 | | -title: ''Format Settings'' |
68 | | -sidebar_label: ''Format Settings'' |
69 | | -slug: /operations/settings/formats |
70 | | -toc_max_heading_level: 2 |
71 | | -description: ''Settings which control input and output formats.'' |
72 | | ---- |
73 | | -
|
74 | | -import ExperimentalBadge from \'@theme/badges/ExperimentalBadge\'; |
75 | | -import BetaBadge from \'@theme/badges/BetaBadge\'; |
76 | | -
|
77 | | -<!-- Autogenerated --> |
78 | | -These settings are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/FormatFactorySettings.h). |
79 | | -
|
80 | | -' AS prefix |
81 | | -SELECT prefix || (SELECT groupConcat(*) FROM main_content) |
82 | | -INTO OUTFILE 'settings-formats.md' TRUNCATE FORMAT LineAsString |
83 | | -" > /dev/null || { echo "Failed to Autogenerate Format settings"; exit 1; } |
84 | | - |
85 | | -# Autogenerate settings |
86 | | -./clickhouse -q " |
87 | | -WITH |
88 | | -'Settings.cpp' AS cpp_file, |
89 | | -settings_from_cpp AS |
90 | | -( |
91 | | - SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name |
92 | | - FROM file(cpp_file, LineAsString) |
93 | | - WHERE match(line, '^\\s*DECLARE\\(') |
94 | | -), |
95 | | -main_content AS |
96 | | -( |
97 | | - SELECT format( |
98 | | - '## {} {}\\n{}\\n{}\\n\\nType: {}\\n\\nDefault value: {}\\n\\n{}\\n\\n', |
99 | | - name, |
100 | | - '{#'||name||'}', |
101 | | - multiIf(tier == 'Experimental', '<ExperimentalBadge/>', tier == 'Beta', '<BetaBadge/>', ''), |
102 | | - if(description LIKE '%Only has an effect in ClickHouse Cloud%', '\\n<CloudAvailableBadge/>', ''), |
103 | | - type, |
104 | | - default, |
105 | | - replaceOne( |
106 | | - trim(BOTH '\\n' FROM description), |
107 | | - ' and [MaterializedMySQL](../../engines/database-engines/materialized-mysql.md)','' |
108 | | - ) |
109 | | - ) |
110 | | - FROM system.settings WHERE name IN settings_from_cpp |
111 | | - ORDER BY name |
112 | | -), |
113 | | -'--- |
114 | | -title: ''Session Settings'' |
115 | | -sidebar_label: ''Session Settings'' |
116 | | -slug: /operations/settings/settings |
117 | | -toc_max_heading_level: 2 |
118 | | -description: ''Settings which are found in the ``system.settings`` table.'' |
119 | | ---- |
120 | | -
|
121 | | -import ExperimentalBadge from \'@theme/badges/ExperimentalBadge\'; |
122 | | -import BetaBadge from \'@theme/badges/BetaBadge\'; |
123 | | -import CloudAvailableBadge from \'@theme/badges/CloudAvailableBadge\'; |
124 | | -
|
125 | | -<!-- Autogenerated --> |
126 | | -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). |
127 | | -
|
128 | | -' AS prefix |
129 | | -SELECT prefix || (SELECT groupConcat(*) FROM main_content) |
130 | | -INTO OUTFILE 'settings.md' TRUNCATE FORMAT LineAsString |
131 | | -" > /dev/null || { echo "Failed to Autogenerate Core settings"; exit 1; } |
132 | | - |
133 | | -# Autogenerate MergeTree settings |
134 | | -./clickhouse -q " |
135 | | - WITH |
136 | | - merge_tree_settings AS |
137 | | - ( |
138 | | - SELECT format( |
139 | | - '## {} {} \n{}\nType: \`{}\`\n\nDefault: \`{}\`\n{}', |
140 | | - name, |
141 | | - '{#'||name||'}', |
142 | | - multiIf(tier == 'Experimental', '\n<ExperimentalBadge/>\n', tier == 'Beta', '\n<BetaBadge/>\n', ''), |
143 | | - type, |
144 | | - default, |
145 | | - replaceRegexpAll(description, '(?m)(^[ \t]+|[ \t]+$)', '') |
146 | | - ) |
147 | | - FROM system.merge_tree_settings ORDER BY name |
148 | | - ) |
149 | | - SELECT * FROM merge_tree_settings |
150 | | - INTO OUTFILE 'generated_merge_tree_settings.md' TRUNCATE FORMAT LineAsString |
151 | | -" > /dev/null || { echo "Failed to Autogenerate Core settings"; exit 1; } |
152 | | - |
153 | | -# Auto generate global server settings |
154 | | -./clickhouse -q " |
155 | | -WITH |
156 | | - server_settings_outside_source AS |
157 | | - ( |
158 | | - SELECT |
159 | | - arrayJoin(extractAllGroups(raw_blob, '## (\\w+)(?:\\s[^\n]+)?\n\\s+((?:[^#]|#[^#]|##[^ ])+)')) AS g, |
160 | | - g[1] AS name, |
161 | | - replaceRegexpAll(replaceRegexpAll(g[2], '\n(Type|Default( value)?): [^\n]+\n', ''), '^\n+|\n+$', '') AS doc |
162 | | - FROM file('_server_settings_outside_source.md', RawBLOB) |
163 | | - ), |
164 | | - server_settings_in_source AS |
165 | | - ( |
166 | | - SELECT |
167 | | - name, |
168 | | - replaceRegexpAll(description, '(?m)^[ \t]+', '') AS description, |
169 | | - type, |
170 | | - default |
171 | | - FROM system.server_settings |
172 | | - ), |
173 | | - combined_server_settings AS |
174 | | - ( |
175 | | - SELECT |
176 | | - name, |
177 | | - description, |
178 | | - type, |
179 | | - default |
180 | | - FROM server_settings_in_source |
181 | | - UNION ALL |
182 | | - SELECT |
183 | | - name, |
184 | | - doc AS description, |
185 | | - '' AS type, |
186 | | - '' AS default |
187 | | - FROM server_settings_outside_source |
188 | | - ), |
189 | | - formatted_settings AS |
190 | | - ( |
191 | | - SELECT |
192 | | - format( |
193 | | - '## {} {}\n\n{}{}{}\n\n', |
194 | | - name, |
195 | | - lcase('{#'||name||'}'), |
196 | | - if(type != '', concat('Type: \`', type, '\`\n\n'), ''), |
197 | | - if(default != '', concat('Default: \`', default, '\`\n\n'), ''), |
198 | | - description |
199 | | - ) AS formatted_text |
200 | | - FROM combined_server_settings |
201 | | - ORDER BY name ASC |
202 | | - ), |
203 | | - prefix_text AS |
204 | | - ( |
205 | | - SELECT |
206 | | - '--- |
207 | | -description: ''This section contains descriptions of server settings i.e settings |
208 | | - which cannot be changed at the session or query level.'' |
209 | | -keywords: [''global server settings''] |
210 | | -sidebar_label: ''Server Settings'' |
211 | | -sidebar_position: 57 |
212 | | -slug: /operations/server-configuration-parameters/settings |
213 | | -title: ''Server Settings'' |
214 | | ---- |
215 | | -
|
216 | | -import Tabs from ''@theme/Tabs''; |
217 | | -import TabItem from ''@theme/TabItem''; |
218 | | -import SystemLogParameters from ''@site/docs/operations/server-configuration-parameters/_snippets/_system-log-parameters.md'' |
219 | | -
|
220 | | -# Server Settings |
221 | | -
|
222 | | -This section contains descriptions of server settings. These are settings which |
223 | | -cannot be changed at the session or query level. |
224 | | -
|
225 | | -For more information on configuration files in ClickHouse see [""Configuration Files""](/operations/configuration-files). |
226 | | -
|
227 | | -Other settings are described in the ""[Settings](/operations/settings/overview)"" section. |
228 | | -Before studying the settings, we recommend reading the [Configuration files](/operations/configuration-files) |
229 | | -section and note the use of substitutions (the `incl` and `optional` attributes). |
230 | | -
|
231 | | -' AS prefix_content |
232 | | - ) |
233 | | -SELECT |
234 | | - arrayStringConcat([ |
235 | | - (SELECT prefix_content FROM prefix_text), |
236 | | - arrayStringConcat(groupArray(formatted_text), '') |
237 | | - ], '') |
238 | | -FROM formatted_settings |
239 | | -INTO OUTFILE 'server_settings.md' |
240 | | -TRUNCATE FORMAT LineAsString" > /dev/null || { echo "Failed to Autogenerate Format settings"; exit 1; } |
| 47 | +# Autogenerate settings for all .sql files in directory |
| 48 | +for SQL_FILE in "$SCRIPT_DIR"/*.sql; do |
| 49 | + if [ -f "$SQL_FILE" ]; then |
| 50 | + ./clickhouse --queries-file "$SQL_FILE" > /dev/null || { echo "Failed to generate some settings"; exit 1; } |
| 51 | + fi |
| 52 | +done |
241 | 53 |
|
| 54 | +# move across files to where they need to be |
242 | 55 | mv settings-formats.md "$root/docs/operations/settings" || { echo "Failed to move generated settings-format.md"; exit 1; } |
243 | 56 | mv settings.md "$root/docs/operations/settings" || { echo "Failed to move generated settings.md"; exit 1; } |
244 | 57 | cat generated_merge_tree_settings.md >> "$root/docs/operations/settings/merge-tree-settings.md" || { echo "Failed to append MergeTree settings.md"; exit 1; } |
|
0 commit comments