Skip to content

Commit 45ff4e5

Browse files
committed
Merge remote-tracking branch 'origin/master' into split_kafka_tests
2 parents 3ee8afd + 9a480c9 commit 45ff4e5

File tree

201 files changed

+5569
-1494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+5569
-1494
lines changed

ci/jobs/scripts/check_style/aspell-ignore/en/aspell-dict.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,8 +1887,10 @@ geospatial
18871887
getClientHTTPHeader
18881888
getMacro
18891889
getMaxTableNameLengthForDatabase
1890+
getMergeTreeSetting
18901891
getOSKernelVersion
18911892
getServerPort
1893+
getServerSetting
18921894
getSetting
18931895
getSettingOrDefault
18941896
getSizeOfEnumType
@@ -2233,6 +2235,7 @@ mebibytes
22332235
memtable
22342236
memtables
22352237
mergeTreeIndex
2238+
mergeTreeProjection
22362239
mergeable
22372240
mergetree
22382241
messageID

ci/jobs/scripts/workflow_hooks/filter_job.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,18 @@ def should_skip_job(job_name):
8383
f"Skipped, labeled with '{Labels.CI_FUNCTIONAL_FLAKY}' - run stateless test jobs only",
8484
)
8585

86-
if Labels.CI_INTEGRATION in _info_cache.pr_labels and (
86+
if Labels.CI_INTEGRATION in _info_cache.pr_labels and not (
8787
job_name.startswith(JobNames.INTEGRATION) or job_name in JobConfigs.builds_for_tests
8888
):
8989
return (
9090
True,
9191
f"Skipped, labeled with '{Labels.CI_INTEGRATION}' - run integration test jobs only",
9292
)
9393

94-
if Labels.CI_FUNCTIONAL in _info_cache.pr_labels and (
94+
if Labels.CI_FUNCTIONAL in _info_cache.pr_labels and not (
9595
job_name.startswith(JobNames.STATELESS)
96-
or job_name.startswith(JobNames.STATEFUL or job_name in JobConfigs.builds_for_tests)
96+
or job_name.startswith(JobNames.STATEFUL)
97+
or job_name in JobConfigs.builds_for_tests
9798
):
9899
return (
99100
True,

contrib/zstd

Submodule zstd updated 71 files

docs/en/sql-reference/functions/other-functions.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4671,3 +4671,67 @@ Result:
46714671
│ 206 │
46724672
└─────────────────────────────────────────────┘
46734673
```
4674+
4675+
## getServerSetting {#getserversetting}
4676+
4677+
Returns the current value of one of the server settings
4678+
4679+
**Syntax**
4680+
4681+
```sql
4682+
getServerSetting('server_setting');
4683+
```
4684+
4685+
**Parameter**
4686+
4687+
- `server_setting` — The setting name. [String](../data-types/string.md).
4688+
4689+
**Returned value**
4690+
4691+
- The server setting's current value.
4692+
4693+
**Example**
4694+
4695+
```sql
4696+
SELECT getServerSetting('allow_use_jemalloc_memory');
4697+
```
4698+
4699+
Result:
4700+
4701+
```text
4702+
┌─getServerSetting('allow_use_jemalloc_memory')─┐
4703+
│ true │
4704+
└───────────────────────────────────────────────┘
4705+
```
4706+
4707+
## getMergeTreeSetting {#getmergetreesetting}
4708+
4709+
Returns the current value of one of the merge tree settings
4710+
4711+
**Syntax**
4712+
4713+
```sql
4714+
getMergeTreeSetting('merge_tree_setting');
4715+
```
4716+
4717+
**Parameter**
4718+
4719+
- `merge_tree_setting` — The setting name. [String](../data-types/string.md).
4720+
4721+
**Returned value**
4722+
4723+
- The merge tree setting's current value.
4724+
4725+
**Example**
4726+
4727+
```sql
4728+
SELECT getMergeTreeSetting('index_granularity');
4729+
```
4730+
4731+
Result:
4732+
4733+
```text
4734+
┌─getMergeTree(index_granularity')─┐
4735+
│ 8192 │
4736+
└──────────────────────────────────┘
4737+
```

docs/en/sql-reference/statements/alter/projection.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,49 @@ As mentioned before, we could review the `system.query_log` table. On the `proje
137137
SELECT query, projections FROM system.query_log WHERE query_id='<query_id>'
138138
```
139139

140+
## Normal projection with `_part_offset` field {#normal-projection-with-part-offset-field}
141+
142+
Creating a table with a normal projection that utilizes the `_part_offset` field:
143+
144+
```sql
145+
CREATE TABLE events
146+
(
147+
`event_time` DateTime,
148+
`event_id` UInt64,
149+
`user_id` UInt64,
150+
`huge_string` String,
151+
PROJECTION order_by_user_id
152+
(
153+
SELECT
154+
_part_offset
155+
ORDER BY user_id
156+
)
157+
)
158+
ENGINE = MergeTree()
159+
ORDER BY (event_id);
160+
```
161+
162+
Inserting some sample data:
163+
164+
```sql
165+
INSERT INTO events SELECT * FROM generateRandom() LIMIT 100000;
166+
```
167+
168+
### Using `_part_offset` as a secondary index {#normal-projection-secondary-index}
169+
170+
The `_part_offset` field preserves its value through merges and mutations, making it valuable for secondary indexing. We can leverage this in queries:
171+
172+
```sql
173+
SELECT
174+
count()
175+
FROM events
176+
WHERE (_part, _part_offset) IN (
177+
SELECT _part, _part_offset
178+
FROM events
179+
WHERE user_id = 42
180+
)
181+
```
182+
140183
# Manipulating Projections
141184

142185
The following operations with [projections](/engines/table-engines/mergetree-family/mergetree.md/#projections) are available:
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
description: 'Represents the contents of some projection in MergeTree tables.
3+
It can be used for introspection.'
4+
sidebar_label: 'mergeTreeProjection'
5+
sidebar_position: 77
6+
slug: /sql-reference/table-functions/mergeTreeProjection
7+
title: 'mergeTreeProjection'
8+
---
9+
10+
# mergeTreeProjection Table Function
11+
12+
Represents the contents of some projection in MergeTree tables. It can be used for introspection.
13+
14+
```sql
15+
mergeTreeProjection(database, table, projection)
16+
```
17+
18+
**Arguments**
19+
20+
- `database`- The database name to read projection from.
21+
- `table`- The table name to read projection from.
22+
- `projection` - The projection to read from.
23+
24+
**Returned Value**
25+
26+
A table object with columns provided by given projection.
27+
28+
## Usage Example {#usage-example}
29+
30+
```sql
31+
CREATE TABLE test
32+
(
33+
`user_id` UInt64,
34+
`item_id` UInt64,
35+
PROJECTION order_by_item_id
36+
(
37+
SELECT _part_offset
38+
ORDER BY item_id
39+
)
40+
)
41+
ENGINE = MergeTree
42+
ORDER BY user_id;
43+
44+
INSERT INTO test SELECT number, 100 - number FROM numbers(5);
45+
```
46+
47+
```sql
48+
SELECT *, _part_offset FROM mergeTreeProjection(currentDatabase(), test, order_by_item_id);
49+
```
50+
51+
```text
52+
┌─item_id─┬─_parent_part_offset─┬─_part_offset─┐
53+
1. │ 96 │ 4 │ 0 │
54+
2. │ 97 │ 3 │ 1 │
55+
3. │ 98 │ 2 │ 2 │
56+
4. │ 99 │ 1 │ 3 │
57+
5. │ 100 │ 0 │ 4 │
58+
└─────────┴─────────────────────┴──────────────┘
59+
```
60+
61+
```sql
62+
DESCRIBE mergeTreeProjection(currentDatabase(), test, order_by_item_id) SETTINGS describe_compact_output = 1;
63+
```
64+
65+
```text
66+
┌─name────────────────┬─type───┐
67+
1. │ item_id │ UInt64 │
68+
2. │ _parent_part_offset │ UInt64 │
69+
└─────────────────────┴────────┘
70+
```

programs/benchmark/Benchmark.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ class Benchmark : public Poco::Util::Application
313313
std::lock_guard lock(mutex);
314314

315315
log << "\nQueries executed: " << num;
316-
if (queries.size() > 1)
316+
if (max_iterations > 1)
317+
log << " (" << (num * 100.0 / max_iterations) << "%)";
318+
else if (queries.size() > 1)
317319
log << " (" << (num * 100.0 / queries.size()) << "%)";
318320
log << ".\n" << flush;
319321
}

programs/server/Server.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,12 @@ namespace ServerSetting
314314
extern const ServerSettingsUInt64 max_prefixes_deserialization_thread_pool_size;
315315
extern const ServerSettingsUInt64 max_prefixes_deserialization_thread_pool_free_size;
316316
extern const ServerSettingsUInt64 prefixes_deserialization_thread_pool_thread_pool_queue_size;
317-
extern const ServerSettingsUInt64 page_cache_block_size;
318317
extern const ServerSettingsUInt64 page_cache_history_window_ms;
319318
extern const ServerSettingsString page_cache_policy;
320319
extern const ServerSettingsDouble page_cache_size_ratio;
321320
extern const ServerSettingsUInt64 page_cache_min_size;
322321
extern const ServerSettingsUInt64 page_cache_max_size;
323322
extern const ServerSettingsDouble page_cache_free_memory_ratio;
324-
extern const ServerSettingsUInt64 page_cache_lookahead_blocks;
325323
extern const ServerSettingsUInt64 page_cache_shards;
326324
extern const ServerSettingsUInt64 os_cpu_busy_time_threshold;
327325
extern const ServerSettingsFloat min_os_cpu_wait_time_ratio_to_drop_connection;
@@ -1170,8 +1168,6 @@ try
11701168
if (server_settings[ServerSetting::page_cache_max_size] != 0)
11711169
{
11721170
global_context->setPageCache(
1173-
server_settings[ServerSetting::page_cache_block_size],
1174-
server_settings[ServerSetting::page_cache_lookahead_blocks],
11751171
std::chrono::milliseconds(Int64(server_settings[ServerSetting::page_cache_history_window_ms])),
11761172
server_settings[ServerSetting::page_cache_policy],
11771173
server_settings[ServerSetting::page_cache_size_ratio],

programs/server/dashboard.html

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@
553553
let params = default_params;
554554

555555
/// Palette generation for charts
556-
function generatePalette(numColors) {
556+
function generateColor(l, c, h) {
557557
// oklch() does not work in firefox<=125 inside <canvas> element so we convert it back to rgb for now.
558558
// Based on https://github.com/color-js/color.js/blob/main/src/spaces/oklch.js
559559
const multiplyMatrices = (A, B) => {
@@ -598,13 +598,17 @@
598598
], xyz)
599599
}
600600

601-
const oklch2rgb = lch => srgbLinear2rgb(xyz2rgbLinear(oklab2xyz(oklch2oklab(lch))))
601+
const oklch2rgb = lch => srgbLinear2rgb(xyz2rgbLinear(oklab2xyz(oklch2oklab(lch))))
602+
603+
let rgb = oklch2rgb([l, c, h]);
604+
return `rgb(${rgb[0] * 255}, ${rgb[1] * 255}, ${rgb[2] * 255})`;
605+
}
606+
607+
function generatePalette(numColors) {
602608

603609
palette = [];
604610
for (let i = 0; i < numColors; i++) {
605-
//palette.push(`oklch(${theme != 'dark' ? 0.75 : 0.5}, 0.15, ${360 * i / numColors})`);
606-
let rgb = oklch2rgb([theme != 'dark' ? 0.75 : 0.5, 0.15, 360 * i / numColors]);
607-
palette.push(`rgb(${rgb[0] * 255}, ${rgb[1] * 255}, ${rgb[2] * 255})`);
611+
palette.push(generateColor(theme != 'dark' ? 0.75 : 0.5, 0.15, 360 * i / numColors));
608612
}
609613
return palette;
610614
}
@@ -1146,6 +1150,15 @@
11461150
return {reply, error};
11471151
}
11481152

1153+
function stringHash(str) {
1154+
let hash = 0;
1155+
for (let i = 0; i < str.length; i++) {
1156+
hash = ((hash << 5) - hash) + str.charCodeAt(i);
1157+
hash = hash & hash;
1158+
}
1159+
return hash;
1160+
}
1161+
11491162
async function draw(idx, chart, url_params, query) {
11501163
if (plots[idx]) {
11511164
plots[idx].destroy();
@@ -1238,9 +1251,12 @@
12381251
title_div.style.display = 'block';
12391252
}
12401253

1241-
const [line_color, fill_color, grid_color, axes_color] = theme != 'dark'
1242-
? ["#ff8888", "#ffeeee", "#eeeedd", "#2c3235"]
1243-
: ["#886644", "#004455", "#2c3235", "#c7d0d9"];
1254+
const color_rotate = Math.abs(stringHash(query));
1255+
1256+
const line_color = theme != 'dark' ? generateColor(0.75, 0.14, (21 + color_rotate) % 360) : generateColor(0.53, 0.07, (56 + color_rotate) % 360);
1257+
const fill_color = theme != 'dark' ? generateColor(0.96, 0.02, (21 + color_rotate) % 360) : generateColor(0.36, 0.07, (56 + color_rotate) % 360);
1258+
const grid_color = theme != 'dark' ? "#eeeedd" : "#2c3235";
1259+
const axes_color = theme != 'dark' ? "#2c3235" : "#c7d0d9";
12441260

12451261
let sync = uPlot.sync("sync");
12461262

src/Analyzer/HashUtils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ using QueryTreeNodeConstRawPtrWithHashSet = std::unordered_set<QueryTreeNodeCons
5454
template <typename Value>
5555
using QueryTreeNodePtrWithHashMap = std::unordered_map<QueryTreeNodePtrWithHash, Value>;
5656

57+
class ColumnNode;
58+
using ColumnNodePtr = std::shared_ptr<ColumnNode>;
59+
using ColumnNodePtrWithHash = QueryTreeNodeWithHash<ColumnNodePtr>;
60+
using ColumnNodePtrWithHashSet = std::unordered_set<ColumnNodePtrWithHash>;
61+
5762
}
5863

5964
template <typename T, bool compare_aliases, bool compare_types>

0 commit comments

Comments
 (0)