Skip to content

Commit

Permalink
Merge branch 'main' into m-4676
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 24, 2024
2 parents 0cc18a3 + fa123fd commit a85bf4c
Show file tree
Hide file tree
Showing 26 changed files with 160 additions and 4 deletions.
10 changes: 9 additions & 1 deletion pkg/sql/colexec/dedupjoin/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,15 @@ func (ctr *container) probe(bat *batch.Batch, ap *DedupJoin, proc *process.Proce

for j, rp := range ap.Result {
if rp.Rel == 1 {
if err := ctr.rbat.Vecs[j].UnionOne(ctr.joinBat1.Vecs[rp.Pos], 0, proc.Mp()); err != nil {
//if last index is row_id, meams need fetch right child's partition column
//@FIXME should have better way to get right child's partition column
var srcVec *vector.Vector
if ctr.joinBat1.Vecs[rp.Pos].GetType().Oid == types.T_Rowid {
srcVec = ctr.joinBat2.Vecs[rp.Pos]
} else {
srcVec = ctr.joinBat1.Vecs[rp.Pos]
}
if err := ctr.rbat.Vecs[j].UnionOne(srcVec, 0, proc.Mp()); err != nil {
return err
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/plan/bind_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ func (builder *QueryBuilder) appendDedupAndMultiUpdateNodesForBindInsert(
if tableDef.Partition != nil {
partitionTableIDs, partitionTableNames := getPartitionInfos(builder.compCtx, objRef, tableDef)
updateCtx.NewPartitionIdx = partitionExprIdx
if onDupAction == plan.Node_UPDATE {
updateCtx.OldPartitionIdx = partitionExprIdx
}
updateCtx.PartitionTableIds = partitionTableIDs
updateCtx.PartitionTableNames = partitionTableNames
dmlNode.BindingTags = append(dmlNode.BindingTags, selectTag)
Expand Down
20 changes: 19 additions & 1 deletion test/distributed/cases/dml/insert/on_duplicate_key.result
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,22 @@ internal error: do not support update primary key/unique key for on duplicate ke
delete from t1;
insert into t1 values (1,1),(3,2);
insert into t1 values (1,2) on duplicate key update a = a+2;
internal error: do not support update primary key/unique key for on duplicate key update
internal error: do not support update primary key/unique key for on duplicate key update
drop table if exists t1;
create table t1(a int primary key, b int) partition by key(a) partitions 2;
insert into t1 values (1,1),(2,2);
insert into t1 values (1,1),(3,3) on duplicate key update b = 10;
select * from t1 order by a;
a b
1 10
2 2
3 3
drop table if exists t1;
create table t1(a int, b int, c int, primary key(a,b)) partition by key(a,b) partitions 2;
insert into t1 values (1,1,1),(2,2,2);
insert into t1 values (1,1,1),(3,3,3) on duplicate key update c = 10;
select * from t1 order by a;
a b c
1 1 10
2 2 2
3 3 3
12 changes: 11 additions & 1 deletion test/distributed/cases/dml/insert/on_duplicate_key.sql
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,14 @@ insert into t1 values (1,1),(3,2);
insert into t1 values (1,2) on duplicate key update a = 10;
delete from t1;
insert into t1 values (1,1),(3,2);
insert into t1 values (1,2) on duplicate key update a = a+2;
insert into t1 values (1,2) on duplicate key update a = a+2;
drop table if exists t1;
create table t1(a int primary key, b int) partition by key(a) partitions 2;
insert into t1 values (1,1),(2,2);
insert into t1 values (1,1),(3,3) on duplicate key update b = 10;
select * from t1 order by a;
drop table if exists t1;
create table t1(a int, b int, c int, primary key(a,b)) partition by key(a,b) partitions 2;
insert into t1 values (1,1,1),(2,2,2);
insert into t1 values (1,1,1),(3,3,3) on duplicate key update c = 10;
select * from t1 order by a;
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ show snapshots;
SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME
drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;
drop table if exists Departments;
Expand Down Expand Up @@ -333,6 +334,7 @@ performancereviewid employeeid reviewdate reviewerid
4 4 2020-04-04 5
5 5 2020-05-05 6
6 6 2020-06-06 1
DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;
drop table if exists Projects;
Expand Down Expand Up @@ -401,6 +403,7 @@ projectid employeeid
4 4
5 5
6 6
DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;
drop table if exists Salaries;
Expand Down Expand Up @@ -600,6 +603,7 @@ show snapshots;
SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME
drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';
DROP DATABASE IF EXISTS School;
CREATE DATABASE School;
USE School;
drop table if exists Students;
Expand Down Expand Up @@ -672,6 +676,7 @@ select * from CourseAverageGrades;
courseid title averagegrade
101 Calculus 3.55000000
102 Physics 3.70000000
DROP DATABASE IF EXISTS University;
CREATE DATABASE University;
USE University;
drop table if exists Departments;
Expand Down Expand Up @@ -795,6 +800,7 @@ select * from TopStudents;
name averagegrade
Eve 3.50000000
Frank 3.60000000
DROP DATABASE IF EXISTS EducationSystem;
CREATE DATABASE EducationSystem;
USE EducationSystem;
CREATE VIEW ComprehensiveStudentCourseInfo AS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';

-- @session:id=2&user=acc01:test_account&password=111
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;

Expand Down Expand Up @@ -301,6 +302,7 @@ select * from Benefits;
select * from TimeOff;
select * from PerformanceReviews;

DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;

Expand Down Expand Up @@ -356,6 +358,7 @@ select * from Projects;
select * from ProjectMembers;
select * from ProjectManagers;

DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;

Expand Down Expand Up @@ -459,6 +462,7 @@ drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';

-- @session:id=3&user=acc01:test_account&password=111
DROP DATABASE IF EXISTS School;
CREATE DATABASE School;
USE School;

Expand Down Expand Up @@ -524,6 +528,7 @@ select * from HighGradeStudents;
select * from CourseAverageGrades;

-- database University
DROP DATABASE IF EXISTS University;
CREATE DATABASE University;
USE University;

Expand Down Expand Up @@ -635,6 +640,7 @@ select * from ProfessorCourses;
select * from DepartmentAverageGrade;
select * from TopStudents;

DROP DATABASE IF EXISTS EducationSystem;
CREATE DATABASE EducationSystem;
USE EducationSystem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ show snapshots;
SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME
drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;
drop table if exists Departments;
Expand Down Expand Up @@ -336,6 +337,7 @@ performancereviewid employeeid reviewdate reviewerid
4 4 2020-04-04 5
5 5 2020-05-05 6
6 6 2020-06-06 1
DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;
drop table if exists Projects;
Expand Down Expand Up @@ -404,6 +406,7 @@ projectid employeeid
4 4
5 5
6 6
DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;
drop table if exists Salaries;
Expand Down Expand Up @@ -606,6 +609,7 @@ show snapshots;
SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME
drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';
DROP DATABASE IF EXISTS School;
CREATE DATABASE School;
USE School;
drop table if exists Students;
Expand Down Expand Up @@ -678,6 +682,7 @@ select * from CourseAverageGrades;
courseid title averagegrade
101 Calculus 3.55000000
102 Physics 3.70000000
DROP DATABASE IF EXISTS University;
CREATE DATABASE University;
USE University;
drop table if exists Departments;
Expand Down Expand Up @@ -801,6 +806,7 @@ select * from TopStudents;
name averagegrade
Eve 3.50000000
Frank 3.60000000
DROP DATABASE IF EXISTS EducationSystem;
CREATE DATABASE EducationSystem;
USE EducationSystem;
CREATE VIEW ComprehensiveStudentCourseInfo AS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';

-- @session:id=3&user=acc01:test_account&password=111
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;

Expand Down Expand Up @@ -305,6 +306,7 @@ select * from Benefits;
select * from TimeOff;
select * from PerformanceReviews;

DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;

Expand Down Expand Up @@ -360,6 +362,7 @@ select * from Projects;
select * from ProjectMembers;
select * from ProjectManagers;

DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;

Expand Down Expand Up @@ -467,6 +470,7 @@ drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';

-- @session:id=5&user=acc01:test_account&password=111
DROP DATABASE IF EXISTS School;
CREATE DATABASE School;
USE School;

Expand Down Expand Up @@ -532,6 +536,7 @@ select * from HighGradeStudents;
select * from CourseAverageGrades;

-- database University
DROP DATABASE IF EXISTS University;
CREATE DATABASE University;
USE University;

Expand Down Expand Up @@ -643,6 +648,7 @@ select * from ProfessorCourses;
select * from DepartmentAverageGrade;
select * from TopStudents;

DROP DATABASE IF EXISTS EducationSystem;
CREATE DATABASE EducationSystem;
USE EducationSystem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ drop account if exists acc01;
create account acc01 admin_name = 'test_account' identified by '111';
drop account if exists acc02;
create account acc02 admin_name = 'test_account' identified by '111';
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;
drop table if exists Departments;
Expand Down Expand Up @@ -179,6 +180,7 @@ performancereviewid employeeid reviewdate reviewerid
4 4 2020-04-04 5
5 5 2020-05-05 6
6 6 2020-06-06 1
DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;
drop table if exists Projects;
Expand Down Expand Up @@ -247,6 +249,7 @@ projectid employeeid
4 4
5 5
6 6
DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;
drop table if exists Salaries;
Expand Down Expand Up @@ -314,6 +317,7 @@ departmentid budget
4 400000.00
5 500000.00
6 600000.00
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;
drop table if exists Departments;
Expand Down Expand Up @@ -491,6 +495,7 @@ performancereviewid employeeid reviewdate reviewerid
4 4 2020-04-04 5
5 5 2020-05-05 6
6 6 2020-06-06 1
DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;
drop table if exists Projects;
Expand Down Expand Up @@ -559,6 +564,7 @@ projectid employeeid
4 4
5 5
6 6
DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;
drop table if exists Salaries;
Expand Down Expand Up @@ -626,6 +632,7 @@ departmentid budget
4 400000.00
5 500000.00
6 600000.00
DROP DATABASE IF EXISTS Company;
CREATE DATABASE Company;
USE Company;
drop table if exists Departments;
Expand Down Expand Up @@ -803,6 +810,7 @@ performancereviewid employeeid reviewdate reviewerid
4 4 2020-04-04 5
5 5 2020-05-05 6
6 6 2020-06-06 1
DROP DATABASE IF EXISTS Projects;
CREATE DATABASE Projects;
USE Projects;
drop table if exists Projects;
Expand Down Expand Up @@ -871,6 +879,7 @@ projectid employeeid
4 4
5 5
6 6
DROP DATABASE IF EXISTS Payroll;
CREATE DATABASE Payroll;
USE Payroll;
drop table if exists Salaries;
Expand Down
Loading

0 comments on commit a85bf4c

Please sign in to comment.