Skip to content

Commit 9b5945c

Browse files
authored
Merge branch 'main' into ISSUE-7528/auto_extend_ts
2 parents 0ce2a1c + 40d9483 commit 9b5945c

File tree

43 files changed

+832
-262
lines changed

Some content is hidden

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

43 files changed

+832
-262
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/doc/30-reference/30-sql/00-ddl/40-stage/01-ddl-create-stage.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CREATE STAGE [ IF NOT EXISTS ] <internal_stage_name>
1212
[ FILE_FORMAT = ( { TYPE = { CSV | PARQUET } [ formatTypeOptions ] ) } ]
1313
[ COPY_OPTIONS = ( copyOptions ) ]
1414
[ COMMENT = '<string_literal>' ]
15-
15+
1616
-- External stage
1717
CREATE STAGE [ IF NOT EXISTS ] <external_stage_name>
1818
externalStageParams
@@ -70,8 +70,8 @@ externalStageParams ::=
7070
### formatTypeOptions
7171
```
7272
formatTypeOptions ::=
73-
RECORD_DELIMITER = '<character>'
74-
FIELD_DELIMITER = '<character>'
73+
RECORD_DELIMITER = '<character>'
74+
FIELD_DELIMITER = '<character>'
7575
SKIP_HEADER = <integer>
7676
```
7777

@@ -85,11 +85,13 @@ formatTypeOptions ::=
8585
```
8686
copyOptions ::=
8787
[ SIZE_LIMIT = <num> ]
88+
[ PURGE = <bool> ]
8889
```
8990

9091
| Parameters | Description | Required |
9192
| ----------- | ----------- | --- |
9293
| `SIZE_LIMIT = <num>` | Number (> 0) that specifies the maximum rows of data to be loaded for a given COPY statement. Default `0` | Optional |
94+
| `PURGE = <bool>` | True specifies that the command will purge the files in the stage if they are loaded successfully into table. Default `false` | Optional |
9395

9496

9597
## Examples

docs/doc/30-reference/30-sql/10-dml/dml-copy-into-location.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ externalLocation (for Amazon S3) ::=
5656
### formatTypeOptions
5757
```
5858
formatTypeOptions ::=
59-
RECORD_DELIMITER = '<character>'
60-
FIELD_DELIMITER = '<character>'
59+
RECORD_DELIMITER = '<character>'
60+
FIELD_DELIMITER = '<character>'
6161
SKIP_HEADER = <integer>
6262
```
6363

docs/doc/30-reference/30-sql/10-dml/dml-copy-into-table.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ A regular expression pattern string, enclosed in single quotes, specifying the f
9797

9898
```
9999
formatTypeOptions ::=
100-
RECORD_DELIMITER = '<character>'
101-
FIELD_DELIMITER = '<character>'
100+
RECORD_DELIMITER = '<character>'
101+
FIELD_DELIMITER = '<character>'
102102
SKIP_HEADER = <integer>
103103
COMPRESSION = AUTO | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE
104104
```
@@ -129,7 +129,7 @@ Default: `NONE`
129129

130130
Values:
131131

132-
| Values | Notes |
132+
| Values | Notes |
133133
|---------------|-----------------------------------------------------------------|
134134
| `AUTO` | Auto detect compression via file extensions |
135135
| `GZIP` | |
@@ -145,11 +145,13 @@ Values:
145145
```
146146
copyOptions ::=
147147
[ SIZE_LIMIT = <num> ]
148+
[ PURGE = <bool> ]
148149
```
149150

150151
| Parameters | Description | Required |
151152
| ----------- | ----------- | --- |
152153
| `SIZE_LIMIT = <num>` | Number (> 0) that specifies the maximum rows of data to be loaded for a given COPY statement. Default `0` | Optional |
154+
| `PURGE = <bool>` | True that specifies the command will purge the files in the stage if they are loaded successfully into table. Default `false` | Optional |
153155

154156
## Examples
155157

docs/doc/30-reference/30-sql/70-system-tables/system-query-log.md

Lines changed: 100 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,71 @@
22
title: system.query_log
33
---
44

5-
A read-only in-memory table stores all the query logs;
5+
A read-only in-memory table stores all the query logs.
66

7-
```sql
8-
SELECT * FROM system.query_log ORDER BY event_time DESC LIMIT 1\G
9-
*************************** 1. row ***************************
7+
8+
## Columns
9+
10+
```
11+
CREATE TABLE `query_log` (
12+
`log_type` TINYINT,
13+
`handler_type` VARCHAR,
14+
`tenant_id` VARCHAR,
15+
`cluster_id` VARCHAR,
16+
`sql_user` VARCHAR,
17+
`sql_user_quota` VARCHAR,
18+
`sql_user_privileges` VARCHAR,
19+
`query_id` VARCHAR,
20+
`query_kind` VARCHAR,
21+
`query_text` VARCHAR,
22+
`event_date` DATE,
23+
`event_time` TIMESTAMP(3),
24+
`current_database` VARCHAR,
25+
`databases` VARCHAR,
26+
`tables` VARCHAR,
27+
`columns` VARCHAR,
28+
`projections` VARCHAR,
29+
`written_rows` BIGINT UNSIGNED,
30+
`written_bytes` BIGINT UNSIGNED,
31+
`written_io_bytes` BIGINT UNSIGNED,
32+
`written_io_bytes_cost_ms` BIGINT UNSIGNED,
33+
`scan_rows` BIGINT UNSIGNED,
34+
`scan_bytes` BIGINT UNSIGNED,
35+
`scan_io_bytes` BIGINT UNSIGNED,
36+
`scan_io_bytes_cost_ms` BIGINT UNSIGNED,
37+
`scan_partitions` BIGINT UNSIGNED,
38+
`total_partitions` BIGINT UNSIGNED,
39+
`result_rows` BIGINT UNSIGNED,
40+
`result_bytes` BIGINT UNSIGNED,
41+
`cpu_usage` INT UNSIGNED,
42+
`memory_usage` BIGINT UNSIGNED,
43+
`client_info` VARCHAR,
44+
`client_address` VARCHAR,
45+
`exception_code` INT,
46+
`exception_text` VARCHAR,
47+
`stack_trace` VARCHAR,
48+
`server_version` VARCHAR,
49+
`session_settings` VARCHAR,
50+
`extra` VARCHAR
51+
)
52+
```
53+
54+
## Examples
55+
56+
```
57+
*************************** 4. row ***************************
1058
log_type: 1
1159
handler_type: MySQL
12-
tenant_id: test_tenant
13-
cluster_id: test_cluster
60+
tenant_id: admin
61+
cluster_id:
1462
sql_user: root
1563
sql_user_quota: UserQuota<cpu:0,mem:0,store:0>
16-
sql_user_privileges: GRANT ALL ON *.* TO 'root'@'127.0.0.1', ROLES: []
17-
query_id: da879c17-94bb-4163-b2ac-ff4786bbe69e
18-
query_kind: SelectPlan
19-
query_text: SELECT * from system.query_log order by event_time desc limit 1
20-
event_date: 2022-03-24
21-
event_time: 2022-03-24 11:13:27.414
64+
sql_user_privileges: GRANT ALL ON *.*, ROLES: []
65+
query_id: eda2a82b-3667-4ffb-b436-953785178c39
66+
query_kind: Query
67+
query_text: select avg(number) from numbers(1000000)
68+
event_date: 2022-09-08
69+
event_time: 2022-09-08 03:32:39.517
2270
current_database: default
2371
databases:
2472
tables:
@@ -34,16 +82,50 @@ written_io_bytes_cost_ms: 0
3482
scan_io_bytes_cost_ms: 0
3583
scan_partitions: 0
3684
total_partitions: 0
37-
result_rows: 0
38-
result_bytes: 0
39-
cpu_usage: 10
40-
memory_usage: 1603
85+
86+
, skip_header=0, sql_dialect=PostgreSQL, storage_read_buffer_size=1048576, timezone=UTC, unquoted_ident_case_sensitive=0, wait_for_async_insert=1, wait_for_async_insert_timeout=100, scope: SESSION
87+
extra:
88+
89+
90+
*************************** 5. row ***************************
91+
log_type: 2
92+
handler_type: MySQL
93+
tenant_id: admin
94+
cluster_id:
95+
sql_user: root
96+
sql_user_quota: UserQuota<cpu:0,mem:0,store:0>
97+
sql_user_privileges: GRANT ALL ON *.*, ROLES: []
98+
query_id: eda2a82b-3667-4ffb-b436-953785178c39
99+
query_kind: Query
100+
query_text: select avg(number) from numbers(1000000)
101+
event_date: 2022-09-08
102+
event_time: 2022-09-08 03:32:39.519
103+
current_database: default
104+
databases:
105+
tables:
106+
columns:
107+
projections:
108+
written_rows: 0
109+
written_bytes: 0
110+
written_io_bytes: 0
111+
written_io_bytes_cost_ms: 0
112+
scan_rows: 1000000
113+
scan_bytes: 8000000
114+
scan_io_bytes: 0
115+
scan_io_bytes_cost_ms: 0
116+
scan_partitions: 0
117+
total_partitions: 0
118+
result_rows: 1
119+
result_bytes: 9
120+
cpu_usage: 24
121+
memory_usage: 0
41122
client_info:
42-
client_address: 127.0.0.1:56744
123+
client_address: 127.0.0.1:53304
43124
exception_code: 0
44125
exception_text:
45126
stack_trace:
46127
server_version:
47-
session_settings: enable_new_processor_framework=1, flight_client_timeout=60, max_block_size=10000, max_threads=8, storage_occ_backoff_init_delay_ms=5, storage_occ_backoff_max_delay_ms=20000, storage_occ_backoff_max_elapsed_ms=120000, storage_read_buffer_size=1048576, scope: SESSION
128+
session_settings: compression=None, empty_as_default=1, enable_async_insert=0, enable_new_processor_framework=1, enable_planner_v2=1, field_delimiter=,, flight_client_timeout=60, group_by_two_level_threshold=10000, max_block_size=10000, max_execute_time=0, max_threads=24, quoted_ident_case_sensitive=1, record_delimiter=
129+
, skip_header=0, sql_dialect=PostgreSQL, storage_read_buffer_size=1048576, timezone=UTC, unquoted_ident_case_sensitive=0, wait_for_async_insert=1, wait_for_async_insert_timeout=100, scope: SESSION
48130
extra:
49131
```

src/meta/api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ common-proto-conv = { path = "../proto-conv" }
2222
common-protos = { path = "../protos" }
2323
common-tracing = { path = "../../common/tracing" }
2424

25-
anyerror = "=0.1.6"
2625
anyhow = "1.0.58"
2726
async-trait = "0.1.56"
2827
enumflags2 = { version = "0.7.5", features = ["serde"] }

src/meta/api/src/kv_api_utils.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
use std::fmt::Display;
1616

17-
use anyerror::AnyError;
1817
use common_meta_app::schema::DatabaseId;
1918
use common_meta_app::schema::DatabaseIdToName;
2019
use common_meta_app::schema::DatabaseMeta;
2120
use common_meta_app::schema::DatabaseNameIdent;
2221
use common_meta_app::schema::TableNameIdent;
2322
use common_meta_app::share::*;
23+
use common_meta_types::anyerror::AnyError;
2424
use common_meta_types::app_error::AppError;
2525
use common_meta_types::app_error::ShareHasNoGrantedDatabase;
2626
use common_meta_types::app_error::UnknownDatabase;
@@ -32,6 +32,7 @@ use common_meta_types::txn_condition::Target;
3232
use common_meta_types::txn_op::Request;
3333
use common_meta_types::ConditionResult;
3434
use common_meta_types::MatchSeq;
35+
use common_meta_types::MetaBytesError;
3536
use common_meta_types::MetaError;
3637
use common_meta_types::Operation;
3738
use common_meta_types::TxnCondition;
@@ -107,7 +108,7 @@ pub async fn list_keys<K: KVApiKey>(
107108
let mut structured_keys = Vec::with_capacity(n);
108109

109110
for (str_key, _seq_id) in res.iter() {
110-
let struct_key = K::from_key(str_key).map_err(meta_encode_err)?;
111+
let struct_key = K::from_key(str_key).map_err(to_bytes_err)?;
111112
structured_keys.push(struct_key);
112113
}
113114

@@ -133,24 +134,24 @@ pub async fn list_u64_value<K: KVApiKey>(
133134
let mut values = Vec::with_capacity(n);
134135

135136
for (str_key, seqv) in res.iter() {
136-
let id = *deserialize_u64(&seqv.data).map_err(meta_encode_err)?;
137+
let id = *deserialize_u64(&seqv.data)?;
137138
values.push(id);
138139

139140
// Parse key
140-
let struct_key = K::from_key(str_key).map_err(meta_encode_err)?;
141+
let struct_key = K::from_key(str_key).map_err(to_bytes_err)?;
141142
structured_keys.push(struct_key);
142143
}
143144

144145
Ok((structured_keys, values))
145146
}
146147

147-
pub fn serialize_u64(value: impl Into<Id>) -> Result<Vec<u8>, MetaError> {
148-
let v = serde_json::to_vec(&*value.into()).map_err(meta_encode_err)?;
148+
pub fn serialize_u64(value: impl Into<Id>) -> Result<Vec<u8>, MetaBytesError> {
149+
let v = serde_json::to_vec(&*value.into())?;
149150
Ok(v)
150151
}
151152

152-
pub fn deserialize_u64(v: &[u8]) -> Result<Id, MetaError> {
153-
let id = serde_json::from_slice(v).map_err(meta_encode_err)?;
153+
pub fn deserialize_u64(v: &[u8]) -> Result<Id, MetaBytesError> {
154+
let id = serde_json::from_slice(v)?;
154155
Ok(Id::new(id))
155156
}
156157

@@ -173,30 +174,30 @@ pub async fn fetch_id<T: KVApiKey>(kv_api: &impl KVApi, generator: T) -> Result<
173174
Ok(seq_v.seq)
174175
}
175176

176-
pub fn serialize_struct<T>(value: &T) -> Result<Vec<u8>, MetaError>
177+
pub fn serialize_struct<T>(value: &T) -> Result<Vec<u8>, MetaBytesError>
177178
where
178179
T: FromToProto + 'static,
179180
T::PB: common_protos::prost::Message,
180181
{
181-
let p = value.to_pb().map_err(meta_encode_err)?;
182+
let p = value.to_pb().map_err(to_bytes_err)?;
182183
let mut buf = vec![];
183-
common_protos::prost::Message::encode(&p, &mut buf).map_err(meta_encode_err)?;
184+
common_protos::prost::Message::encode(&p, &mut buf)?;
184185
Ok(buf)
185186
}
186187

187-
pub fn deserialize_struct<T>(buf: &[u8]) -> Result<T, MetaError>
188+
pub fn deserialize_struct<T>(buf: &[u8]) -> Result<T, MetaBytesError>
188189
where
189190
T: FromToProto,
190191
T::PB: common_protos::prost::Message + Default,
191192
{
192-
let p: T::PB = common_protos::prost::Message::decode(buf).map_err(meta_encode_err)?;
193-
let v: T = FromToProto::from_pb(p).map_err(meta_encode_err)?;
193+
let p: T::PB = common_protos::prost::Message::decode(buf)?;
194+
let v: T = FromToProto::from_pb(p).map_err(to_bytes_err)?;
194195

195196
Ok(v)
196197
}
197198

198-
pub fn meta_encode_err<E: std::error::Error + 'static>(e: E) -> MetaError {
199-
MetaError::EncodeError(AnyError::new(&e))
199+
pub fn to_bytes_err<E: std::error::Error + 'static>(e: E) -> MetaBytesError {
200+
MetaBytesError::new(&e)
200201
}
201202

202203
pub async fn send_txn(
@@ -485,6 +486,8 @@ where
485486
Ok((false, None))
486487
}
487488

489+
/// Get existing value by key. Panic if key is absent.
490+
/// This function is only used for testing.
488491
pub async fn get_kv_data<T>(
489492
kv_api: &(impl KVApi + ?Sized),
490493
key: &impl KVApiKey,
@@ -495,11 +498,12 @@ where
495498
{
496499
let res = kv_api.get_kv(&key.to_key()).await?;
497500
if let Some(res) = res {
498-
return deserialize_struct(&res.data);
501+
let s = deserialize_struct(&res.data)?;
502+
return Ok(s);
499503
};
500504

501-
Err(MetaError::SerdeError(AnyError::error(format!(
502-
"get_kv {:?} fail",
505+
Err(MetaError::Fatal(AnyError::error(format!(
506+
"failed to get {}",
503507
key.to_key()
504508
))))
505509
}

src/meta/api/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ pub use kv_api_utils::is_all_db_data_removed;
5757
pub use kv_api_utils::is_db_need_to_be_remove;
5858
pub use kv_api_utils::list_keys;
5959
pub use kv_api_utils::list_u64_value;
60-
pub use kv_api_utils::meta_encode_err;
6160
pub use kv_api_utils::send_txn;
6261
pub use kv_api_utils::serialize_struct;
6362
pub use kv_api_utils::serialize_u64;

0 commit comments

Comments
 (0)