Skip to content

Commit 472637f

Browse files
authored
Merge pull request #3342 from ClickHouse/anchors
Enable explicit anchors
2 parents 633bbfe + b5c93a9 commit 472637f

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

docs/guides/creating-tables.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ In the example above, `my_first_table` is a `MergeTree` table with four columns:
4242
There are many engines to choose from, but for a simple table on a single-node ClickHouse server, [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) is your likely choice.
4343
:::
4444

45-
## A Brief Intro to Primary Keys
45+
## A Brief Intro to Primary Keys {#a-brief-intro-to-primary-keys}
4646

47-
Before you go any further, it is important to understand how primary keys work in ClickHouse (the implementation
48-
of primary keys might seem unexpected!):
47+
Before you go any further, it is important to understand how primary keys work in ClickHouse (the implementation
48+
of primary keys might seem unexpected!):
4949

50-
- primary keys in ClickHouse are **_not unique_** for each row in a table
50+
- primary keys in ClickHouse are **_not unique_** for each row in a table
5151

52-
The primary key of a ClickHouse table determines how the data is sorted when written to disk. Every 8,192 rows or 10MB of
53-
data (referred to as the **index granularity**) creates an entry in the primary key index file. This granularity concept
54-
creates a **sparse index** that can easily fit in memory, and the granules represent a stripe of the smallest amount of
55-
column data that gets processed during `SELECT` queries.
52+
The primary key of a ClickHouse table determines how the data is sorted when written to disk. Every 8,192 rows or 10MB of
53+
data (referred to as the **index granularity**) creates an entry in the primary key index file. This granularity concept
54+
creates a **sparse index** that can easily fit in memory, and the granules represent a stripe of the smallest amount of
55+
column data that gets processed during `SELECT` queries.
5656

57-
The primary key can be defined using the `PRIMARY KEY` parameter. If you define a table without a `PRIMARY KEY` specified,
58-
then the key becomes the tuple specified in the `ORDER BY` clause. If you specify both a `PRIMARY KEY` and an `ORDER BY`, the primary key must be a prefix of the sort order.
57+
The primary key can be defined using the `PRIMARY KEY` parameter. If you define a table without a `PRIMARY KEY` specified,
58+
then the key becomes the tuple specified in the `ORDER BY` clause. If you specify both a `PRIMARY KEY` and an `ORDER BY`, the primary key must be a prefix of the sort order.
5959

60-
The primary key is also the sorting key, which is a tuple of `(user_id, timestamp)`. Therefore, the data stored in each
61-
column file will be sorted by `user_id`, then `timestamp`.
60+
The primary key is also the sorting key, which is a tuple of `(user_id, timestamp)`. Therefore, the data stored in each
61+
column file will be sorted by `user_id`, then `timestamp`.
6262

6363
:::tip
6464
For more details, check out the [Modeling Data training module](https://learn.clickhouse.com/visitor_catalog_class/show/1328860/?utm_source=clickhouse&utm_medium=docs) in ClickHouse Academy.

docs/tutorial.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import SQLConsoleDetail from '@site/docs/_snippets/_launch_sql_console.md';
88

99
# Advanced Tutorial
1010

11-
## What to Expect from This Tutorial?
11+
## What to Expect from This Tutorial? {#what-to-expect-from-this-tutorial}
1212

1313
In this tutorial, you will create a table and insert a large dataset (two million rows of the [New York taxi data](/getting-started/example-datasets/nyc-taxi.md)). Then you will run queries on the dataset, including an example of how to create a dictionary and use it to perform a JOIN.
1414

1515
:::note
1616
This tutorial assumes you have access to a running ClickHouse service. If not, check out the [Quick Start](./quick-start.mdx).
1717
:::
1818

19-
## 1. Create a New Table
19+
## 1. Create a New Table {#1-create-a-new-table}
2020

2121
The New York City taxi data contains the details of millions of taxi rides, with columns like pickup and drop-off times and locations, cost, tip amount, tolls, payment type and so on. Let's create a table to store this data...
2222

@@ -81,7 +81,7 @@ The New York City taxi data contains the details of millions of taxi rides, with
8181
ORDER BY pickup_datetime;
8282
```
8383

84-
## 2. Insert the Dataset
84+
## 2. Insert the Dataset {#2-insert-the-dataset}
8585

8686
Now that you have a table created, let's add the NYC taxi data. It is in CSV files in S3, and you can load the data from there.
8787
@@ -163,7 +163,7 @@ Now that you have a table created, let's add the NYC taxi data. It is in CSV fil
163163
164164
This query has to process 2M rows and return 190 values, but notice it does this in about 1 second. The `pickup_ntaname` column represents the name of the neighborhood in New York City where the taxi ride originated.
165165
166-
## 3. Analyze the Data
166+
## 3. Analyze the Data {#3-analyze-the-data}
167167
168168
Let's run some queries to analyze the 2M rows of data...
169169

@@ -341,7 +341,7 @@ Let's run some queries to analyze the 2M rows of data...
341341
│ 2015-07-01 00:41:48 │ 2015-07-01 00:44:45 │ 6.3 │ -94 │ 132 │ JFK │ 2015 │ 1 │ 0 │
342342
│ 2015-07-01 01:06:18 │ 2015-07-01 01:14:43 │ 11.76 │ 37 │ 132 │ JFK │ 2015 │ 1 │ 1 │
343343
```
344-
## 4. Create a Dictionary
344+
## 4. Create a Dictionary {#4-create-a-dictionary}
345345
346346
If you are new to ClickHouse, it is important to understand how ***dictionaries*** work. A simple way of thinking about a dictionary is a mapping of key->value pairs that is stored in memory. The details and all the options for dictionaries are linked at the end of the tutorial.
347347
@@ -442,7 +442,7 @@ If you are new to ClickHouse, it is important to understand how ***dictionaries*
442442
```
443443
444444
445-
## 5. Perform a Join
445+
## 5. Perform a Join {#5-perform-a-join}
446446
447447
Let's write some queries that join the `taxi_zone_dictionary` with your `trips` table.
448448

@@ -487,7 +487,7 @@ Let's write some queries that join the `taxi_zone_dictionary` with your `trips`
487487
LIMIT 1000
488488
```
489489

490-
#### Congrats!
490+
#### Congrats! {#congrats}
491491

492492
Well done - you made it through the tutorial, and hopefully you have a better understanding of how to use ClickHouse. Here are some options for what to do next:
493493

scripts/.markdownlint-cli2.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config:
77
default: false
88
MD040: false # Fenced code blocks should have a language specified
99
links-url-type: false # Disallow relative links to a .md or .mdx file
10-
custom-anchor-headings: false # Headings must have a custom anchor which is unique per page eg. # A Heading {#a-heading}
10+
custom-anchor-headings: true # Headings must have a custom anchor which is unique per page eg. # A Heading {#a-heading}
1111

1212
# Keep this item last due to length
1313
proper-names: # MD044
@@ -22,6 +22,8 @@ ignores:
2222
- "docs/zh"
2323
- "docs/en/whats-new"
2424
- "docs/en/_placeholders"
25+
- "docs/operations/settings/settings.md" # autogenerated
26+
- "docs/operations/settings/settings-formats.md" # autogenerated
2527
customRules:
2628
# add custom rules here
2729
- "./markdownlint/rules/links_url_type.js"

scripts/markdownlint/rules/headings_have_custom_anchors.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ module.exports = {
2121
function: (params, onError) => {
2222
const headingIds = {};
2323
filterTokens(params, "heading_open", (token) => {
24+
if (token.markup === "#") {
25+
return;
26+
}
2427
const headingLine = params.lines[token.map[0]];
2528
const match = /\{#([a-zA-Z0-9_-]+)\}/.exec(headingLine);
2629

0 commit comments

Comments
 (0)