Skip to content

Commit 246acf2

Browse files
authored
Merge branch 'main' into hot-fix-settings
2 parents 37ecd53 + c6d644d commit 246acf2

File tree

20 files changed

+485
-232
lines changed

20 files changed

+485
-232
lines changed

src/meta/api/src/schema_api_test_suite.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ impl SchemaApiTestSuite {
15221522
let ident = TableIdent::new(tb_id, seq);
15231523

15241524
let want = TableInfo {
1525-
ident: ident.clone(),
1525+
ident,
15261526
desc: format!("'{}'.'{}'.'{}'", tenant, db_name, tbl_name),
15271527
name: tbl_name.into(),
15281528
meta: table_meta(created_on),
@@ -1549,7 +1549,7 @@ impl SchemaApiTestSuite {
15491549

15501550
let got = mt.get_table((tenant, db_name, tbl_name).into()).await?;
15511551
let want = TableInfo {
1552-
ident: tb_ident_2.clone(),
1552+
ident: tb_ident_2,
15531553
desc: format!("'{}'.'{}'.'{}'", tenant, db_name, tbl_name),
15541554
name: tbl_name.into(),
15551555
meta: table_meta(created_on),
@@ -1584,7 +1584,7 @@ impl SchemaApiTestSuite {
15841584

15851585
let got = mt.get_table((tenant, "db1", "tb2").into()).await.unwrap();
15861586
let want = TableInfo {
1587-
ident: tb_ident_2.clone(),
1587+
ident: tb_ident_2,
15881588
desc: format!("'{}'.'{}'.'{}'", tenant, db_name, tbl_name),
15891589
name: tbl_name.into(),
15901590
meta: table_meta(created_on),
@@ -1784,7 +1784,7 @@ impl SchemaApiTestSuite {
17841784
let cur_db = mt.get_database(Self::req_get_db(tenant, db1_name)).await?;
17851785
assert!(old_db.ident.seq < cur_db.ident.seq);
17861786
let got = mt.get_table((tenant, db1_name, tb2_name).into()).await?;
1787-
got.ident.clone()
1787+
got.ident
17881788
};
17891789

17901790
info!("--- rename table, ok");
@@ -1796,7 +1796,7 @@ impl SchemaApiTestSuite {
17961796

17971797
let got = mt.get_table((tenant, db1_name, tb3_name).into()).await?;
17981798
let want = TableInfo {
1799-
ident: tb_ident.clone(),
1799+
ident: tb_ident,
18001800
desc: format!("'{}'.'{}'.'{}'", tenant, db1_name, tb3_name),
18011801
name: tb3_name.into(),
18021802
meta: table_meta(created_on),
@@ -1842,7 +1842,7 @@ impl SchemaApiTestSuite {
18421842
let got = mt.get_table((tenant, db1_name, tb2_name).into()).await?;
18431843
assert_ne!(tb_ident.table_id, got.ident.table_id);
18441844
assert_ne!(tb_ident.seq, got.ident.seq);
1845-
got.ident.clone()
1845+
got.ident
18461846
};
18471847

18481848
info!("--- db1,tb2(no_nil) -> db1,tb3(no_nil), error");
@@ -2010,7 +2010,7 @@ impl SchemaApiTestSuite {
20102010
let ident = TableIdent::new(tb_id, seq);
20112011

20122012
let want = TableInfo {
2013-
ident: ident.clone(),
2013+
ident,
20142014
desc: format!("'{}'.'{}'.'{}'", tenant, db_name, tbl_name),
20152015
name: tbl_name.into(),
20162016
meta: table_meta(created_on),
@@ -2140,7 +2140,7 @@ impl SchemaApiTestSuite {
21402140
let ident = TableIdent::new(tb_id, seq);
21412141

21422142
let want = TableInfo {
2143-
ident: ident.clone(),
2143+
ident,
21442144
desc: format!("'{}'.'{}'.'{}'", tenant, db_name, tbl_name),
21452145
name: tbl_name.into(),
21462146
meta: table_meta(created_on),
@@ -3128,7 +3128,7 @@ impl SchemaApiTestSuite {
31283128
let ident = TableIdent::new(tb_id, seq);
31293129

31303130
let want = TableInfo {
3131-
ident: ident.clone(),
3131+
ident,
31323132
desc: format!("'{}'.'{}'.'{}'", tenant, db_name, tbl_name),
31333133
name: tbl_name.into(),
31343134
meta: table_meta(created_on),

src/meta/app/src/schema/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use maplit::hashmap;
2929
use crate::schema::database::DatabaseNameIdent;
3030

3131
/// Globally unique identifier of a version of TableMeta.
32-
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq, Default)]
32+
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug, Eq, PartialEq, Default)]
3333
pub struct TableIdent {
3434
/// Globally unique id to identify a table.
3535
pub table_id: u64,

src/query/legacy-planners/src/plan_delete.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,30 @@ use common_datavalues::DataSchema;
1818
use common_datavalues::DataSchemaRef;
1919
use common_meta_app::schema::TableIdent;
2020

21-
use crate::Expression;
2221
use crate::Projection;
2322

24-
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq)]
23+
/// # TODO
24+
///
25+
/// From @xuanwo
26+
///
27+
/// Ideally, we need to use `Scalar` in DeletePlan.selection. But we met a
28+
/// cycle deps here. So we have to change `selection` in String first, and
29+
/// change into `Scalar` when our `Planner` has been moved out.
30+
///
31+
/// At this stage, DeletePlan's selection expr will be parsed twice:
32+
///
33+
/// - Parsed during `bind` to get column index and projection index.
34+
/// - Parsed during `execution` to get the correct columns
35+
///
36+
/// It's an ugly but necessary price to pay. Without this, we would sink in
37+
/// hell forever.
38+
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
2539
pub struct DeletePlan {
2640
pub catalog_name: String,
2741
pub database_name: String,
2842
pub table_name: String,
2943
pub table_id: TableIdent,
30-
pub selection: Option<Expression>,
44+
pub selection: Option<String>,
3145
pub projection: Projection,
3246
}
3347

src/query/service/src/catalogs/default/immutable_catalog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl Catalog for ImmutableCatalog {
134134
.get_by_id(&table_id)
135135
.ok_or_else(|| ErrorCode::UnknownTable(format!("Unknown table id: '{}'", table_id)))?;
136136
let ti = table.get_table_info();
137-
Ok((ti.ident.clone(), Arc::new(ti.meta.clone())))
137+
Ok((ti.ident, Arc::new(ti.meta.clone())))
138138
}
139139

140140
async fn get_table(

src/query/service/src/pipelines/processors/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub use transforms::KeyU64HashTable;
5454
pub use transforms::KeyU8HashTable;
5555
pub use transforms::MarkJoinCompactor;
5656
pub use transforms::ProjectionTransform;
57+
pub use transforms::RightJoinCompactor;
5758
pub use transforms::SerializerHashTable;
5859
pub use transforms::SinkBuildHashTable;
5960
pub use transforms::SortMergeCompactor;

src/query/service/src/pipelines/processors/transforms/hash_join/desc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,36 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use std::collections::HashMap;
16+
1517
use common_exception::Result;
1618
use common_functions::scalars::FunctionFactory;
1719
use parking_lot::RwLock;
1820

1921
use crate::evaluator::EvalNode;
2022
use crate::evaluator::Evaluator;
23+
use crate::pipelines::processors::transforms::hash_join::row::RowPtr;
2124
use crate::pipelines::processors::transforms::hash_join::MarkJoinDesc;
2225
use crate::sql::executor::HashJoin;
2326
use crate::sql::executor::PhysicalScalar;
2427
use crate::sql::plans::JoinType;
2528

29+
pub struct RightJoinDesc {
30+
/// Record rows in build side that are matched with rows in probe side.
31+
pub(crate) build_indexes: RwLock<Vec<RowPtr>>,
32+
/// Record row in build side that is matched how many rows in probe side.
33+
pub(crate) row_state: RwLock<HashMap<RowPtr, usize>>,
34+
}
35+
36+
impl RightJoinDesc {
37+
pub fn create() -> Self {
38+
RightJoinDesc {
39+
build_indexes: RwLock::new(Vec::new()),
40+
row_state: RwLock::new(HashMap::new()),
41+
}
42+
}
43+
}
44+
2645
pub struct HashJoinDesc {
2746
pub(crate) build_keys: Vec<EvalNode>,
2847
pub(crate) probe_keys: Vec<EvalNode>,
@@ -31,6 +50,7 @@ pub struct HashJoinDesc {
3150
pub(crate) marker_join_desc: MarkJoinDesc,
3251
/// Whether the Join are derived from correlated subquery.
3352
pub(crate) from_correlated_subquery: bool,
53+
pub(crate) right_join_desc: RightJoinDesc,
3454
}
3555

3656
impl HashJoinDesc {
@@ -50,6 +70,7 @@ impl HashJoinDesc {
5070
marker_index: join.marker_index,
5171
},
5272
from_correlated_subquery: join.from_correlated_subquery,
73+
right_join_desc: RightJoinDesc::create(),
5374
})
5475
}
5576

src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_state.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ pub trait HashJoinState: Send + Sync {
4444

4545
/// Get mark join results
4646
fn mark_join_blocks(&self) -> Result<Vec<DataBlock>>;
47+
48+
/// Get right join results
49+
fn right_join_blocks(&self, blocks: &[DataBlock]) -> Result<Vec<DataBlock>>;
4750
}

0 commit comments

Comments
 (0)