Skip to content

Commit bc2b978

Browse files
committed
Merge remote-tracking branch 'upstream/main' into add-default-role
2 parents 22eb73c + 5946b0a commit bc2b978

File tree

142 files changed

+5016
-1288
lines changed

Some content is hidden

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

142 files changed

+5016
-1288
lines changed

.github/mergify.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ queue_rules:
1313
- check-success=test_stateless_standalone_linux
1414
- check-success=test_stateless_cluster_linux
1515
- check-success=test_stateful_standalone_linux
16-
- check-success~=^test_sqllogic_(base|ydb)_standalone_linux$
16+
- check-success=test_sqllogic_base_standalone_linux
17+
- check-success=test_sqllogic_ydb_standalone_linux
1718

1819
- name: docs_queue
1920
conditions:

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.

Cargo.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ exclude = ["tools/fuzz"]
5858
[profile.release]
5959
debug = 1
6060
lto = "thin"
61-
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
61+
overflow-checks = false
62+
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
6263

6364
[profile.release.package]
6465
arrow2 = { codegen-units = 4 }
@@ -67,9 +68,21 @@ databend-query = { codegen-units = 4 }
6768

6869
[profile.bench]
6970
debug = true
71+
overflow-checks = false
7072

7173
[profile.dev]
7274
split-debuginfo = "unpacked"
75+
overflow-checks = false
76+
77+
[profile.test]
78+
opt-level = 0
79+
debug = 0
80+
codegen-units = 16
81+
lto = false
82+
incremental = true
83+
debug-assertions = true
84+
overflow-checks = true
85+
rpath = false
7386

7487
[profile.dev.package]
7588
addr2line = { opt-level = 3 }

common/ast/src/ast/statements/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod explain;
1919
mod insert;
2020
mod kill;
2121
mod presign;
22+
mod share;
2223
mod show;
2324
mod stage;
2425
mod statement;
@@ -33,6 +34,7 @@ pub use explain::*;
3334
pub use insert::*;
3435
pub use kill::*;
3536
pub use presign::*;
37+
pub use share::*;
3638
pub use show::*;
3739
pub use stage::*;
3840
pub use statement::*;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2022 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use std::fmt::Display;
16+
use std::fmt::Formatter;
17+
18+
use crate::ast::Identifier;
19+
20+
#[derive(Debug, Clone, PartialEq, Eq)]
21+
pub struct CreateShareStmt<'a> {
22+
pub if_not_exists: bool,
23+
pub share: Identifier<'a>,
24+
pub comment: Option<String>,
25+
}
26+
27+
impl Display for CreateShareStmt<'_> {
28+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29+
write!(f, "CREATE SHARE ")?;
30+
if self.if_not_exists {
31+
write!(f, "IF NOT EXISTS ")?;
32+
}
33+
write!(f, "{}", self.share)?;
34+
if let Some(comment) = &self.comment {
35+
write!(f, " COMMENT = '{comment}'")?;
36+
}
37+
Ok(())
38+
}
39+
}

common/ast/src/ast/statements/statement.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ pub enum Statement<'a> {
157157
},
158158

159159
Presign(PresignStmt),
160+
161+
// share
162+
CreateShare(CreateShareStmt<'a>),
160163
}
161164

162165
#[derive(Debug, Clone, PartialEq)]
@@ -358,6 +361,7 @@ impl<'a> Display for Statement<'a> {
358361
Statement::DescribeStage { stage_name } => write!(f, "DESC STAGE {stage_name}")?,
359362
Statement::Call(stmt) => write!(f, "{stmt}")?,
360363
Statement::Presign(stmt) => write!(f, "{stmt}")?,
364+
Statement::CreateShare(stmt) => write!(f, "{stmt}")?,
361365
}
362366
Ok(())
363367
}

common/ast/src/parser/statement.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
208208
);
209209
let show_tables = map(
210210
rule! {
211-
SHOW ~ FULL? ~ TABLES ~ HISTORY? ~ ( FROM ~ ^#ident )? ~ #show_limit?
211+
SHOW ~ FULL? ~ TABLES ~ HISTORY? ~ ( ( FROM | IN ) ~ ^#ident )? ~ #show_limit?
212212
},
213213
|(_, opt_full, _, opt_history, opt_database, limit)| {
214214
Statement::ShowTables(ShowTablesStmt {
@@ -741,6 +741,23 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
741741
},
742742
);
743743

744+
// share statements
745+
let create_share = map(
746+
rule! {
747+
CREATE ~ SHARE ~ (IF ~ NOT ~ EXISTS )? ~ #ident ~ ( COMMENT ~ "=" ~ #literal_string)?
748+
},
749+
|(_, _, opt_if_not_exists, share, comment_opt)| {
750+
Statement::CreateShare(CreateShareStmt {
751+
if_not_exists: opt_if_not_exists.is_some(),
752+
share,
753+
comment: match comment_opt {
754+
Some(opt) => Some(opt.2),
755+
None => None,
756+
},
757+
})
758+
},
759+
);
760+
744761
let statement_body = alt((
745762
rule!(
746763
#map(query, |query| Statement::Query(Box::new(query)))
@@ -826,6 +843,10 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
826843
rule!(
827844
#presign: "`PRESIGN [{DOWNLOAD | UPLOAD}] <location> [EXPIRE = 3600]`"
828845
),
846+
// share
847+
rule!(
848+
#create_share: "`CREATE SHARE <share_name> [ COMMENT = '<string_literal>' ]`"
849+
),
829850
));
830851

831852
map(

common/ast/src/parser/token.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ pub enum TokenKind {
607607
UPDATE,
608608
#[token("UPLOAD", ignore(ascii_case))]
609609
UPLOAD,
610+
#[token("SHARE", ignore(ascii_case))]
611+
SHARE,
610612
#[token("SUPER", ignore(ascii_case))]
611613
SUPER,
612614
#[token("STATUS", ignore(ascii_case))]

common/ast/tests/it/parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ fn test_statement() {
142142
r#"ALTER DATABASE catalog.c RENAME TO a;"#,
143143
r#"CREATE TABLE t (a INT COMMENT 'col comment') COMMENT='table comment';"#,
144144
r#"GRANT SELECT, CREATE ON * TO 'test-grant'@'localhost';"#,
145+
r#"GRANT SELECT, CREATE ON *.* TO 'test-grant'@'localhost';"#,
145146
r#"GRANT SELECT, CREATE ON * TO USER 'test-grant'@'localhost';"#,
146147
r#"GRANT SELECT, CREATE ON * TO ROLE 'role1';"#,
147148
r#"GRANT ALL ON *.* TO 'test-grant'@'localhost';"#,
@@ -255,6 +256,8 @@ fn test_statement() {
255256
r#"PRESIGN @my_stage/path/to/file"#,
256257
r#"PRESIGN DOWNLOAD @my_stage/path/to/file"#,
257258
r#"PRESIGN UPLOAD @my_stage/path/to/file EXPIRE=7200"#,
259+
r#"CREATE SHARE t COMMENT='share comment';"#,
260+
r#"CREATE SHARE IF NOT EXISTS t;"#,
258261
];
259262

260263
for case in cases {

common/ast/tests/it/testdata/statement.txt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4938,6 +4938,30 @@ Grant(
49384938
)
49394939

49404940

4941+
---------- Input ----------
4942+
GRANT SELECT, CREATE ON *.* TO 'test-grant'@'localhost';
4943+
---------- Output ---------
4944+
GRANT SELECT, CREATE ON *.* TO USER 'test-grant'@'localhost'
4945+
---------- AST ------------
4946+
Grant(
4947+
GrantStmt {
4948+
source: Privs {
4949+
privileges: [
4950+
Select,
4951+
Create,
4952+
],
4953+
level: Global,
4954+
},
4955+
principal: User(
4956+
UserIdentity {
4957+
username: "test-grant",
4958+
hostname: "localhost",
4959+
},
4960+
),
4961+
},
4962+
)
4963+
4964+
49414965
---------- Input ----------
49424966
GRANT SELECT, CREATE ON * TO USER 'test-grant'@'localhost';
49434967
---------- Output ---------
@@ -5883,3 +5907,41 @@ Presign(
58835907
)
58845908

58855909

5910+
---------- Input ----------
5911+
CREATE SHARE t COMMENT='share comment';
5912+
---------- Output ---------
5913+
CREATE SHARE t COMMENT = 'share comment'
5914+
---------- AST ------------
5915+
CreateShare(
5916+
CreateShareStmt {
5917+
if_not_exists: false,
5918+
share: Identifier {
5919+
name: "t",
5920+
quote: None,
5921+
span: Ident(13..14),
5922+
},
5923+
comment: Some(
5924+
"share comment",
5925+
),
5926+
},
5927+
)
5928+
5929+
5930+
---------- Input ----------
5931+
CREATE SHARE IF NOT EXISTS t;
5932+
---------- Output ---------
5933+
CREATE SHARE IF NOT EXISTS t
5934+
---------- AST ------------
5935+
CreateShare(
5936+
CreateShareStmt {
5937+
if_not_exists: true,
5938+
share: Identifier {
5939+
name: "t",
5940+
quote: None,
5941+
span: Ident(27..28),
5942+
},
5943+
comment: None,
5944+
},
5945+
)
5946+
5947+

common/cache/src/meter/bytes_meter.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
use std::borrow::Borrow;
16+
use std::sync::Arc;
1617

1718
use super::Meter;
1819
pub struct BytesMeter;
@@ -24,3 +25,11 @@ impl<K> Meter<K, Vec<u8>> for BytesMeter {
2425
v.len()
2526
}
2627
}
28+
29+
impl<K> Meter<K, Arc<Vec<u8>>> for BytesMeter {
30+
type Measure = usize;
31+
fn measure<Q: ?Sized>(&self, _: &Q, v: &Arc<Vec<u8>>) -> usize
32+
where K: Borrow<Q> {
33+
v.len()
34+
}
35+
}

common/catalog/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ common-meta-types = { path = "../meta/types" }
2323
common-pipeline = { path = "../pipeline" }
2424
common-planners = { path = "../planners" }
2525
common-settings = { path = "../settings" }
26-
common-streams = { path = "../streams" }
2726
common-users = { path = "../users" }
2827

2928
async-trait = "0.1.56"

common/catalog/src/table.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use common_planners::Partitions;
3434
use common_planners::ReadDataSourcePlan;
3535
use common_planners::Statistics;
3636
use common_planners::TruncateTablePlan;
37-
use common_streams::SendableDataBlockStream;
3837

3938
use crate::table_context::TableContext;
4039

@@ -128,20 +127,16 @@ pub trait Table: Sync + Send {
128127
_: &ReadDataSourcePlan,
129128
_: &mut Pipeline,
130129
) -> Result<()> {
131-
unimplemented!()
130+
Err(ErrorCode::UnImplement(format!(
131+
"read2 operation for table {} is not implemented, table engine is {}",
132+
self.name(),
133+
self.get_table_info().meta.engine
134+
)))
132135
}
133136

134137
fn append2(&self, _: Arc<dyn TableContext>, _: &mut Pipeline) -> Result<()> {
135-
unimplemented!()
136-
}
137-
138-
async fn append_data(
139-
&self,
140-
_ctx: Arc<dyn TableContext>,
141-
_stream: SendableDataBlockStream,
142-
) -> Result<SendableDataBlockStream> {
143138
Err(ErrorCode::UnImplement(format!(
144-
"append operation for table {} is not implemented, table engine is {}",
139+
"append2 operation for table {} is not implemented, table engine is {}",
145140
self.name(),
146141
self.get_table_info().meta.engine
147142
)))
@@ -216,5 +211,5 @@ pub struct TableStatistics {
216211
pub num_rows: Option<u64>,
217212
pub data_size: Option<u64>,
218213
pub data_size_compressed: Option<u64>,
219-
pub index_length: Option<u64>,
214+
pub index_size: Option<u64>,
220215
}

common/datablocks/src/utils.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@ use common_arrow::parquet::encoding::Encoding;
2222
use common_arrow::parquet::metadata::ThriftFileMetaData;
2323
use common_arrow::parquet::write::Version;
2424
use common_arrow::write_parquet_file;
25-
use common_datavalues::DataSchemaRef;
25+
use common_datavalues::DataSchema;
2626
use common_exception::ErrorCode;
2727
use common_exception::Result;
2828

2929
use crate::DataBlock;
3030

31-
pub fn serialize_data_blocks(
31+
pub fn serialize_data_blocks_with_compression(
3232
blocks: Vec<DataBlock>,
33-
schema: &DataSchemaRef,
33+
schema: impl AsRef<DataSchema>,
3434
buf: &mut Vec<u8>,
35+
compression: CompressionOptions,
3536
) -> Result<(u64, ThriftFileMetaData)> {
36-
let arrow_schema = schema.to_arrow();
37+
let arrow_schema = schema.as_ref().to_arrow();
3738

3839
let row_group_write_options = WriteOptions {
3940
write_statistics: false,
40-
compression: CompressionOptions::Lz4Raw,
41+
compression,
4142
version: Version::V2,
4243
};
4344
let batches = blocks
@@ -75,6 +76,14 @@ pub fn serialize_data_blocks(
7576
}
7677
}
7778

79+
pub fn serialize_data_blocks(
80+
blocks: Vec<DataBlock>,
81+
schema: impl AsRef<DataSchema>,
82+
buf: &mut Vec<u8>,
83+
) -> Result<(u64, ThriftFileMetaData)> {
84+
serialize_data_blocks_with_compression(blocks, schema, buf, CompressionOptions::Lz4Raw)
85+
}
86+
7887
fn col_encoding(_data_type: &ArrowDataType) -> Encoding {
7988
// Although encoding does work, parquet2 has not implemented decoding of DeltaLengthByteArray yet, we fallback to Plain
8089
// From parquet2: Decoding "DeltaLengthByteArray"-encoded required V2 pages is not yet implemented for Binary.

common/fuse-meta/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition = "2021"
99
[features]
1010

1111
[dependencies]
12+
common-arrow = { path = "../arrow" }
1213
common-base = { path = "../base" }
1314
common-cache = { path = "../cache" }
1415
common-config = { path = "../config" }

0 commit comments

Comments
 (0)