Skip to content

Commit a4bc101

Browse files
authored
Merge branch 'main' into ISSUE-7609/drop_pin
2 parents a2bddd5 + d6b8631 commit a4bc101

File tree

465 files changed

+3527
-1991
lines changed

Some content is hidden

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

465 files changed

+3527
-1991
lines changed

Cargo.lock

Lines changed: 27 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ members = [
3434
"src/query/pipeline/sinks",
3535
"src/query/pipeline/sources",
3636
"src/query/pipeline/transforms",
37-
"src/query/planners",
37+
"src/query/legacy-planners",
3838
"src/query/settings",
3939
"src/query/storages/fuse",
4040
"src/query/storages/fuse-meta",

docs/doc/30-reference/20-functions/40-string-functions/substring.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ SUBSTRING(str FROM pos FOR len)
2424
| Arguments | Description |
2525
| ----------- | ----------- |
2626
| str | The main string from where the character to be extracted |
27-
| pos | The one-indexed position expression to start at. If negative, counts from the end |
28-
| len | The number expression of characters to extract |
27+
| pos | The position (starting from 1) the substring to start at. If negative, counts from the end |
28+
| len | The maximun length of the substring to extract |
2929

3030
## Return Type
3131

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
{
2-
"label": "Cluster Key",
3-
"link": {
4-
"type": "generated-index",
5-
"slug": "/reference/sql/ddl/clusterkey"
6-
}
2+
"label": "Cluster Key"
73
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: What is a Cluster Key?
3+
sidebar_position: 1
4+
slug: ./
5+
---
6+
7+
The cluster key is a data object for tables in Databend. It explicitly tells Databend how to divide and group rows of a table into the storage partitions rather than using the data ingestion order.
8+
9+
A table's cluster key is usually one or more columns or expressions. If you define a cluster key for a table, Databend reorganizes your data based on the cluster key and stores similar rows into the same or adjacent storage partitions.
10+
11+
The benefit of defining a cluster key is optimizing the query performance. The cluster key acts as a link between the metadata in the Databend's Meta Service Layer and the storage partitions. After the cluster key is defined for a table, the table's metadata implements a key-value-like list that shows the correspondences between the column or expression values and their storage partitions. When a query comes, Databend can quickly locate the storage partition by the metadata and fetch the results. To make this work, the cluster key you set must match the way how you filter the data in queries. For example, if you're most likely to query a table that holds all the employees' profile information by their first names, set the cluster key to the first name column.
12+
13+
In Databend, you [SET CLUSTER KEY](dml-set-cluster-key.md) when you create a table, and you can [ALTER CLUSTER KEY](https://databend.rs/doc/reference/sql/ddl/clusterkey/dml-alter-cluster-key) if necessary. A fully-clustered table might become chaotic if it continues to have ingestion or Data Manipulation Language operations (such as INSERT, UPDATE, DELETE), you will need to [RECLUSTER TABLE](./dml-recluster-table.md) to fix the chaos.
14+
15+
It's important to note that, most of the time you do not need to set the cluster key. Clustering or re-clustering a table consumes time and your credits if you're in Databend Cloud. Databend recommends setting cluster keys for large tables with slow query issues.

src/meta/api/src/kv_api_key.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub enum KVApiKeyError {
3030
#[error("Expect {expect} segments, but: '{got}'")]
3131
WrongNumberOfSegments { expect: usize, got: String },
3232

33+
#[error("Expect at least {expect} segments, but {actual} segments found")]
34+
AtleastSegments { expect: usize, actual: usize },
35+
3336
#[error("Invalid id string: '{s}': {reason}")]
3437
InvalidId { s: String, reason: String },
3538
}

src/meta/api/src/kv_api_test_suite.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ impl KVApiTestSuite {
483483
key: txn_key.clone(),
484484
value: b"new_v1".to_vec(),
485485
prev_value: true,
486+
expire_at: None,
486487
})),
487488
}];
488489

@@ -640,6 +641,7 @@ impl KVApiTestSuite {
640641
key: txn_key.clone(),
641642
value: b"new_v1".to_vec(),
642643
prev_value: true,
644+
expire_at: None,
643645
})),
644646
}];
645647

@@ -691,6 +693,7 @@ impl KVApiTestSuite {
691693
key: txn_key1.clone(),
692694
value: b"new_v1".to_vec(),
693695
prev_value: true,
696+
expire_at: None,
694697
})),
695698
}];
696699

@@ -745,6 +748,7 @@ impl KVApiTestSuite {
745748
key: txn_key1.clone(),
746749
value: val1_new.to_vec(),
747750
prev_value: true,
751+
expire_at: None,
748752
})),
749753
},
750754
// change k2
@@ -753,6 +757,7 @@ impl KVApiTestSuite {
753757
key: txn_key2.clone(),
754758
value: b"new_v2".to_vec(),
755759
prev_value: true,
760+
expire_at: None,
756761
})),
757762
},
758763
// get k1
@@ -852,6 +857,7 @@ impl KVApiTestSuite {
852857
key: txn_key1.clone(),
853858
value: val1_new.to_vec(),
854859
prev_value: true,
860+
expire_at: None,
855861
})),
856862
},
857863
// get k1

src/meta/api/src/kv_api_utils.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ pub fn txn_op_put(key: &impl KVApiKey, value: Vec<u8>) -> TxnOp {
226226
key: key.to_key(),
227227
value,
228228
prev_value: true,
229+
expire_at: None,
230+
})),
231+
}
232+
}
233+
234+
pub fn txn_op_put_with_expire(key: &impl KVApiKey, value: Vec<u8>, expire_at: u64) -> TxnOp {
235+
TxnOp {
236+
request: Some(Request::Put(TxnPutRequest {
237+
key: key.to_key(),
238+
value,
239+
prev_value: true,
240+
expire_at: Some(expire_at),
229241
})),
230242
}
231243
}

src/meta/api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub use kv_api_utils::table_has_to_exist;
6464
pub use kv_api_utils::txn_cond_seq;
6565
pub use kv_api_utils::txn_op_del;
6666
pub use kv_api_utils::txn_op_put;
67+
pub use kv_api_utils::txn_op_put_with_expire;
6768
pub use kv_api_utils::TXN_MAX_RETRY_TIMES;
6869
pub use schema_api::SchemaApi;
6970
pub(crate) use schema_api_impl::get_db_or_err;

src/meta/api/src/schema_api.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use common_meta_app::schema::DropDatabaseReq;
2626
use common_meta_app::schema::DropTableReply;
2727
use common_meta_app::schema::DropTableReq;
2828
use common_meta_app::schema::GetDatabaseReq;
29+
use common_meta_app::schema::GetTableCopiedFileReply;
30+
use common_meta_app::schema::GetTableCopiedFileReq;
2931
use common_meta_app::schema::GetTableReq;
3032
use common_meta_app::schema::ListDatabaseReq;
3133
use common_meta_app::schema::ListTableReq;
@@ -36,12 +38,16 @@ use common_meta_app::schema::RenameTableReq;
3638
use common_meta_app::schema::TableIdent;
3739
use common_meta_app::schema::TableInfo;
3840
use common_meta_app::schema::TableMeta;
41+
use common_meta_app::schema::TruncateTableReply;
42+
use common_meta_app::schema::TruncateTableReq;
3943
use common_meta_app::schema::UndropDatabaseReply;
4044
use common_meta_app::schema::UndropDatabaseReq;
4145
use common_meta_app::schema::UndropTableReply;
4246
use common_meta_app::schema::UndropTableReq;
4347
use common_meta_app::schema::UpdateTableMetaReply;
4448
use common_meta_app::schema::UpdateTableMetaReq;
49+
use common_meta_app::schema::UpsertTableCopiedFileReply;
50+
use common_meta_app::schema::UpsertTableCopiedFileReq;
4551
use common_meta_app::schema::UpsertTableOptionReply;
4652
use common_meta_app::schema::UpsertTableOptionReq;
4753
use common_meta_types::GCDroppedDataReply;
@@ -104,6 +110,18 @@ pub trait SchemaApi: Send + Sync {
104110
table_id: MetaId,
105111
) -> Result<(TableIdent, Arc<TableMeta>), MetaError>;
106112

113+
async fn get_table_copied_file_info(
114+
&self,
115+
req: GetTableCopiedFileReq,
116+
) -> Result<GetTableCopiedFileReply, MetaError>;
117+
118+
async fn upsert_table_copied_file_info(
119+
&self,
120+
req: UpsertTableCopiedFileReq,
121+
) -> Result<UpsertTableCopiedFileReply, MetaError>;
122+
123+
async fn truncate_table(&self, req: TruncateTableReq) -> Result<TruncateTableReply, MetaError>;
124+
107125
async fn upsert_table_option(
108126
&self,
109127
req: UpsertTableOptionReq,

0 commit comments

Comments
 (0)