Skip to content

Commit 5c2dd6f

Browse files
authored
Merge pull request #3509 from Blargian/fix_highlights
fix code block highlighting
2 parents 151d6ee + 1aa69ca commit 5c2dd6f

File tree

5 files changed

+95
-63
lines changed

5 files changed

+95
-63
lines changed

Diff for: contribute/style-guide.md

+32
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,38 @@ Code blocks:
9292
- Have a title (optional) such as 'Query' or 'Response'
9393
- Use language `response` if it is for the result of a query.
9494

95+
### Highlighting
96+
97+
You can highlight lines in a code block using the following keywords:
98+
99+
- `highlight-next-line`
100+
- `highlight-start`
101+
- `highlight-end`
102+
103+
These keywords should be added as comments in the codeblock with the appropriate
104+
escape symbol for the codeblock language.
105+
106+
For example, if the codeblock is SQL:
107+
108+
```text
109+
SELECT UserID, count(UserID) AS Count
110+
-- highlight-next-line
111+
FROM mv_hits_URL_UserID
112+
WHERE URL = 'http://public_search'
113+
GROUP BY UserID
114+
ORDER BY Count DESC
115+
LIMIT 10;
116+
```
117+
118+
If the codeblock is a response:
119+
120+
```text
121+
10 rows in set. Elapsed: 0.026 sec.
122+
# highlight-next-line
123+
Processed 335.87 thousand rows,
124+
13.54 MB (12.91 million rows/s., 520.38 MB/s.)
125+
```
126+
95127
### Associated markdown rule or CI check
96128

97129
- [`MD040` enforces that codeblocks have a language specified](/scripts/.markdownlint-cli2.yaml)

Diff for: docs/cloud/bestpractices/avoidnullablecolumns.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To avoid `Nullable` columns, consider setting a default value for that column.
1313
CREATE TABLE default.sample
1414
(
1515
`x` Int8,
16-
# highlight-next-line
16+
-- highlight-next-line
1717
`y` Nullable(Int8)
1818
)
1919
ENGINE = MergeTree
@@ -25,7 +25,7 @@ use
2525
CREATE TABLE default.sample2
2626
(
2727
`x` Int8,
28-
# highlight-next-line
28+
-- highlight-next-line
2929
`y` Int8 DEFAULT 0
3030
)
3131
ENGINE = MergeTree

Diff for: docs/guides/best-practices/sparse-primary-indexes.md

+30-30
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ The response is:
146146
└────────────────────────────────┴───────┘
147147
148148
10 rows in set. Elapsed: 0.022 sec.
149-
// highlight-next-line
149+
# highlight-next-line
150150
Processed 8.87 million rows,
151151
70.45 MB (398.53 million rows/s., 3.17 GB/s.)
152152
```
@@ -183,7 +183,7 @@ CREATE TABLE hits_UserID_URL
183183
`EventTime` DateTime
184184
)
185185
ENGINE = MergeTree
186-
// highlight-next-line
186+
-- highlight-next-line
187187
PRIMARY KEY (UserID, URL)
188188
ORDER BY (UserID, URL, EventTime)
189189
SETTINGS index_granularity = 8192, index_granularity_bytes = 0, compress_primary_key = 0;
@@ -532,7 +532,7 @@ The response is:
532532
└────────────────────────────────┴───────┘
533533
534534
10 rows in set. Elapsed: 0.005 sec.
535-
// highlight-next-line
535+
# highlight-next-line
536536
Processed 8.19 thousand rows,
537537
740.18 KB (1.53 million rows/s., 138.59 MB/s.)
538538
```
@@ -543,13 +543,13 @@ The output for the ClickHouse client is now showing that instead of doing a full
543543
If <a href="https://clickhouse.com/docs/operations/server-configuration-parameters/settings/#server_configuration_parameters-logger" target="_blank">trace logging</a> is enabled then the ClickHouse server log file shows that ClickHouse was running a <a href="https://github.com/ClickHouse/ClickHouse/blob/22.3/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp#L1452" target="_blank">binary search</a> over the 1083 UserID index marks, in order to identify granules that possibly can contain rows with a UserID column value of `749927693`. This requires 19 steps with an average time complexity of `O(log2 n)`:
544544
```response
545545
...Executor): Key condition: (column 0 in [749927693, 749927693])
546-
// highlight-next-line
546+
# highlight-next-line
547547
...Executor): Running binary search on index range for part all_1_9_2 (1083 marks)
548548
...Executor): Found (LEFT) boundary mark: 176
549549
...Executor): Found (RIGHT) boundary mark: 177
550550
...Executor): Found continuous range in 19 steps
551551
...Executor): Selected 1/1 parts by partition key, 1 parts by primary key,
552-
// highlight-next-line
552+
# highlight-next-line
553553
1/1083 marks by primary key, 1 marks to read from 1 ranges
554554
...Reading ...approx. 8192 rows starting from 1441792
555555
```
@@ -597,7 +597,7 @@ The response looks like:
597597
│ UserID │
598598
│ Condition: (UserID in [749927693, 749927693]) │
599599
│ Parts: 1/1 │
600-
// highlight-next-line
600+
# highlight-next-line
601601
│ Granules: 1/1083 │
602602
└───────────────────────────────────────────────────────────────────────────────────────┘
603603
@@ -765,7 +765,7 @@ The response is: <a name="query-on-url-slow"></a>
765765
└────────────┴───────┘
766766
767767
10 rows in set. Elapsed: 0.086 sec.
768-
// highlight-next-line
768+
# highlight-next-line
769769
Processed 8.81 million rows,
770770
799.69 MB (102.11 million rows/s., 9.27 GB/s.)
771771
```
@@ -776,11 +776,11 @@ If [trace_logging](/operations/server-configuration-parameters/settings#logger)
776776
```response
777777
...Executor): Key condition: (column 1 in ['http://public_search',
778778
'http://public_search'])
779-
// highlight-next-line
779+
# highlight-next-line
780780
...Executor): Used generic exclusion search over index for part all_1_9_2
781781
with 1537 steps
782782
...Executor): Selected 1/1 parts by partition key, 1 parts by primary key,
783-
// highlight-next-line
783+
# highlight-next-line
784784
1076/1083 marks by primary key, 1076 marks to read from 5 ranges
785785
...Executor): Reading approx. 8814592 rows with 10 streams
786786
```
@@ -927,7 +927,7 @@ CREATE TABLE hits_URL_UserID
927927
`EventTime` DateTime
928928
)
929929
ENGINE = MergeTree
930-
// highlight-next-line
930+
-- highlight-next-line
931931
PRIMARY KEY (URL, UserID)
932932
ORDER BY (URL, UserID, EventTime)
933933
SETTINGS index_granularity = 8192, index_granularity_bytes = 0, compress_primary_key = 0;
@@ -964,7 +964,7 @@ This is the resulting primary key:
964964
That can now be used to significantly speed up the execution of our example query filtering on the URL column in order to calculate the top 10 users that most frequently clicked on the URL "http://public_search":
965965
```sql
966966
SELECT UserID, count(UserID) AS Count
967-
// highlight-next-line
967+
-- highlight-next-line
968968
FROM hits_URL_UserID
969969
WHERE URL = 'http://public_search'
970970
GROUP BY UserID
@@ -990,7 +990,7 @@ The response is:
990990
└────────────┴───────┘
991991
992992
10 rows in set. Elapsed: 0.017 sec.
993-
// highlight-next-line
993+
# highlight-next-line
994994
Processed 319.49 thousand rows,
995995
11.38 MB (18.41 million rows/s., 655.75 MB/s.)
996996
```
@@ -1004,13 +1004,13 @@ The corresponding trace log in the ClickHouse server log file confirms that:
10041004
```response
10051005
...Executor): Key condition: (column 0 in ['http://public_search',
10061006
'http://public_search'])
1007-
// highlight-next-line
1007+
# highlight-next-line
10081008
...Executor): Running binary search on index range for part all_1_9_2 (1083 marks)
10091009
...Executor): Found (LEFT) boundary mark: 644
10101010
...Executor): Found (RIGHT) boundary mark: 683
10111011
...Executor): Found continuous range in 19 steps
10121012
...Executor): Selected 1/1 parts by partition key, 1 parts by primary key,
1013-
// highlight-next-line
1013+
# highlight-next-line
10141014
39/1083 marks by primary key, 39 marks to read from 1 ranges
10151015
...Executor): Reading approx. 319488 rows with 2 streams
10161016
```
@@ -1055,19 +1055,19 @@ The response is:
10551055
└────────────────────────────────┴───────┘
10561056
10571057
10 rows in set. Elapsed: 0.024 sec.
1058-
// highlight-next-line
1058+
# highlight-next-line
10591059
Processed 8.02 million rows,
10601060
73.04 MB (340.26 million rows/s., 3.10 GB/s.)
10611061
```
10621062

10631063
Server Log:
10641064
```response
10651065
...Executor): Key condition: (column 1 in [749927693, 749927693])
1066-
// highlight-next-line
1066+
# highlight-next-line
10671067
...Executor): Used generic exclusion search over index for part all_1_9_2
10681068
with 1453 steps
10691069
...Executor): Selected 1/1 parts by partition key, 1 parts by primary key,
1070-
// highlight-next-line
1070+
# highlight-next-line
10711071
980/1083 marks by primary key, 980 marks to read from 23 ranges
10721072
...Executor): Reading approx. 8028160 rows with 10 streams
10731073
```
@@ -1119,7 +1119,7 @@ ClickHouse is storing the [column data files](#data-is-stored-on-disk-ordered-by
11191119
The implicitly created table (and its primary index) backing the materialized view can now be used to significantly speed up the execution of our example query filtering on the URL column:
11201120
```sql
11211121
SELECT UserID, count(UserID) AS Count
1122-
// highlight-next-line
1122+
-- highlight-next-line
11231123
FROM mv_hits_URL_UserID
11241124
WHERE URL = 'http://public_search'
11251125
GROUP BY UserID
@@ -1144,7 +1144,7 @@ The response is:
11441144
└────────────┴───────┘
11451145
11461146
10 rows in set. Elapsed: 0.026 sec.
1147-
// highlight-next-line
1147+
# highlight-next-line
11481148
Processed 335.87 thousand rows,
11491149
13.54 MB (12.91 million rows/s., 520.38 MB/s.)
11501150
```
@@ -1156,11 +1156,11 @@ The corresponding trace log in the ClickHouse server log file confirms that Clic
11561156
```response
11571157
...Executor): Key condition: (column 0 in ['http://public_search',
11581158
'http://public_search'])
1159-
// highlight-next-line
1159+
# highlight-next-line
11601160
...Executor): Running binary search on index range ...
11611161
...
11621162
...Executor): Selected 4/4 parts by partition key, 4 parts by primary key,
1163-
// highlight-next-line
1163+
# highlight-next-line
11641164
41/1083 marks by primary key, 41 marks to read from 4 ranges
11651165
...Executor): Reading approx. 335872 rows with 4 streams
11661166
```
@@ -1203,7 +1203,7 @@ ClickHouse is storing the [column data files](#data-is-stored-on-disk-ordered-by
12031203
The hidden table (and its primary index) created by the projection can now be (implicitly) used to significantly speed up the execution of our example query filtering on the URL column. Note that the query is syntactically targeting the source table of the projection.
12041204
```sql
12051205
SELECT UserID, count(UserID) AS Count
1206-
// highlight-next-line
1206+
-- highlight-next-line
12071207
FROM hits_UserID_URL
12081208
WHERE URL = 'http://public_search'
12091209
GROUP BY UserID
@@ -1228,7 +1228,7 @@ The response is:
12281228
└────────────┴───────┘
12291229
12301230
10 rows in set. Elapsed: 0.029 sec.
1231-
// highlight-next-line
1231+
# highlight-next-line
12321232
Processed 319.49 thousand rows, 1
12331233
1.38 MB (11.05 million rows/s., 393.58 MB/s.)
12341234
```
@@ -1241,14 +1241,14 @@ The corresponding trace log in the ClickHouse server log file confirms that Clic
12411241
```response
12421242
...Executor): Key condition: (column 0 in ['http://public_search',
12431243
'http://public_search'])
1244-
// highlight-next-line
1244+
# highlight-next-line
12451245
...Executor): Running binary search on index range for part prj_url_userid (1083 marks)
12461246
...Executor): ...
1247-
// highlight-next-line
1247+
# highlight-next-line
12481248
...Executor): Choose complete Normal projection prj_url_userid
12491249
...Executor): projection required columns: URL, UserID
12501250
...Executor): Selected 1/1 parts by partition key, 1 parts by primary key,
1251-
// highlight-next-line
1251+
# highlight-next-line
12521252
39/1083 marks by primary key, 39 marks to read from 1 ranges
12531253
...Executor): Reading approx. 319488 rows with 2 streams
12541254
```
@@ -1327,7 +1327,7 @@ CREATE TABLE hits_URL_UserID_IsRobot
13271327
`IsRobot` UInt8
13281328
)
13291329
ENGINE = MergeTree
1330-
// highlight-next-line
1330+
-- highlight-next-line
13311331
PRIMARY KEY (URL, UserID, IsRobot);
13321332
```
13331333

@@ -1355,7 +1355,7 @@ CREATE TABLE hits_IsRobot_UserID_URL
13551355
`IsRobot` UInt8
13561356
)
13571357
ENGINE = MergeTree
1358-
// highlight-next-line
1358+
-- highlight-next-line
13591359
PRIMARY KEY (IsRobot, UserID, URL);
13601360
```
13611361
And populate it with the same 8.87 million rows that we used to populate the previous table:
@@ -1395,7 +1395,7 @@ The response is:
13951395
└─────────┘
13961396
13971397
1 row in set. Elapsed: 0.026 sec.
1398-
// highlight-next-line
1398+
# highlight-next-line
13991399
Processed 7.92 million rows,
14001400
31.67 MB (306.90 million rows/s., 1.23 GB/s.)
14011401
```
@@ -1413,7 +1413,7 @@ The response is:
14131413
└─────────┘
14141414
14151415
1 row in set. Elapsed: 0.003 sec.
1416-
// highlight-next-line
1416+
# highlight-next-line
14171417
Processed 20.32 thousand rows,
14181418
81.28 KB (6.61 million rows/s., 26.44 MB/s.)
14191419
```

Diff for: docs/integrations/data-ingestion/gcs/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ CREATE TABLE trips_gcs
155155
ENGINE = MergeTree
156156
PARTITION BY toYYYYMM(pickup_date)
157157
ORDER BY pickup_datetime
158-
# highlight-next-line
158+
-- highlight-next-line
159159
SETTINGS storage_policy='gcs_main'
160160
```
161161

@@ -468,10 +468,10 @@ zk_synced_followers 2
468468
# highlight-end
469469
```
470470

471-
472471
### Start ClickHouse server {#start-clickhouse-server}
473472

474473
On `chnode1` and `chnode` run:
474+
475475
```bash
476476
sudo service clickhouse-server start
477477
```
@@ -546,7 +546,7 @@ cache_path:
546546
```
547547
#### Verify that tables created on the cluster are created on both nodes {#verify-that-tables-created-on-the-cluster-are-created-on-both-nodes}
548548
```sql
549-
# highlight-next-line
549+
-- highlight-next-line
550550
create table trips on cluster 'cluster_1S_2R' (
551551
`trip_id` UInt32,
552552
`pickup_date` Date,
@@ -564,7 +564,7 @@ create table trips on cluster 'cluster_1S_2R' (
564564
ENGINE = ReplicatedMergeTree
565565
PARTITION BY toYYYYMM(pickup_date)
566566
ORDER BY pickup_datetime
567-
# highlight-next-line
567+
-- highlight-next-line
568568
SETTINGS storage_policy='gcs_main'
569569
```
570570
```response

0 commit comments

Comments
 (0)