Skip to content

Commit

Permalink
fix: fix the bug when setting is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Breeze0806 committed May 13, 2024
1 parent d428444 commit 76c5ec4
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
[![Coverage Status][cov-img]][cov]
[![GoDoc][doc-img]][doc]

[English](README.md) | 简体中文

go-etl是一个集数据源抽取,转化,加载的工具集,提供强大的数据同步能力。

go-etl将提供的etl能力如下:
Expand Down
4 changes: 2 additions & 2 deletions datax/core/job/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ func (c *Container) Start() (err error) {
log.Errorf("DataX jobContainer %v prepare failed. err: %v", c.jobID, err)
return
}
log.Infof("DataX jobContainer %v starts to split. err: %v", c.jobID)
log.Infof("DataX jobContainer %v starts to split.", c.jobID)
if err = c.split(); err != nil {
log.Errorf("DataX jobContainer %v split failed. err: %v", c.jobID, err)
return
}
log.Infof("DataX jobContainer %v starts to schedule. err: %v", c.jobID)
log.Infof("DataX jobContainer %v starts to schedule.", c.jobID)
if err = c.schedule(); err != nil {
log.Errorf("DataX jobContainer %v schedule failed. err: %v", c.jobID, err)
return
Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/db2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ Describes the DB2 table information.
- Default: None

###### left
- Description: Specifies the default maximum value for the split key of the DB2 table.
- Description: Specifies the default minimum value for the split key of the DB2 table.
- Required: No
- Default: None

###### right
- Description: Specifies the default minimum value for the split key of the DB2 table.
- Description: Specifies the default maximum value for the split key of the DB2 table.
- Required: No
- Default: None

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/db2/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ DB2Reader通过使用dbmsreader中定义的查询流程调用go-etl自定义的s
- 默认值: 无

###### left
- 描述 主要用于配置db2表的切分键默认最大值
- 描述 主要用于配置db2表的切分键默认最小值
- 必选:否
- 默认值: 无

###### right
- 描述 主要用于配置db2表的切分键默认最小值
- 描述 主要用于配置db2表的切分键默认最大值
- 必选:否
- 默认值: 无

Expand Down
2 changes: 1 addition & 1 deletion datax/plugin/reader/dbms/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (j *Job) Split(ctx context.Context, number int) (configs []*config.JSON, er
return
}

if j.Config.GetSplitConfig().Key == "" || number == 1 {
if j.Config.GetSplitConfig().Key == "" {
return []*config.JSON{j.PluginJobConf().CloneConfig()}, nil
}

Expand Down
24 changes: 24 additions & 0 deletions datax/plugin/reader/dbms/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,30 @@ func TestJob_Split(t *testing.T) {
testJSONFromString(`{"querySql":["select a,b,c from table_a join table_b on table_a.id = table_b.id"]}`),
},
},
{
name: "11",
j: &Job{
BaseJob: plugin.NewBaseJob(),
Config: &BaseConfig{
Where: "a < 1",
Split: SplitConfig{
Key: "f1",
},
},
Querier: &MockQuerier{},
handler: newMockDbHandler(func(name string, conf *config.JSON) (Querier, error) {
return &MockQuerier{}, nil
}),
},
args: args{
ctx: context.TODO(),
number: 1,
},
jobConf: testJSONFromString(`{"where":"a < 1"}`),
want: []*config.JSON{
testJSONFromString(`{"where":"(a < 1) and (f1 >= $1 and f1 <= $2)","split":{"range":{"type":"bigInt","layout":"","left":"10000","right":"30000"}}}`),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
29 changes: 29 additions & 0 deletions datax/plugin/reader/dbms/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,18 @@ func Test_doSplit(t *testing.T) {
big.NewInt(22),
},
},
{
name: "5",
args: args{
left: big.NewInt(22),
right: big.NewInt(19),
num: 1,
},
wantResults: []*big.Int{
big.NewInt(19),
big.NewInt(22),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -985,6 +997,23 @@ func Test_split(t *testing.T) {
},
wantErr: true,
},
{
name: "8",
args: args{
min: element.NewDefaultColumn(element.NewBigIntColumnValue(big.NewInt(10000)), "", 0),
max: element.NewDefaultColumn(element.NewBigIntColumnValue(big.NewInt(50003)), "", 0),
num: 1,
splitField: NewMockField(database.NewBaseField(0, "f1", NewMockFieldType(database.GoTypeInt64)), NewMockFieldType(database.GoTypeInt64)),
},
wantRanges: []SplitRange{
{
Type: element.TypeBigInt.String(),
Left: "10000",
Right: "50003",
where: "f1 >= $1 and f1 <= $2",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ Describes the MySQL table information.

###### left

- Description: Primarily used to configure the default maximum value of the split key for the MySQL table.
- Description: Primarily used to configure the default minimum value of the split key for the MySQL table.
- Required: No
- Default: None

###### right

- Description: Primarily used to configure the default minimum value of the split key for the MySQL table.
- Description: Primarily used to configure the default maximum value of the split key for the MySQL table.
- Required: No
- Default: None

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/mysql/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ MysqlReader通过使用dbmsreader中定义的查询流程调用go-etl自定义
- 默认值: 无

###### left
- 描述 主要用于配置mysql表的切分键默认最大值
- 描述 主要用于配置mysql表的切分键默认最小值
- 必选:否
- 默认值: 无

###### right
- 描述 主要用于配置mysql表的切分键默认最小值
- 描述 主要用于配置mysql表的切分键默认最大值
- 必选:否
- 默认值: 无

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ Describes the Oracle table information.

###### left

* Description: Primarily used to configure the default maximum value for the splitting key of the Oracle table.
* Description: Primarily used to configure the default minimum value for the splitting key of the Oracle table.
* Required: No
* Default: None

###### right

* Description: Primarily used to configure the default minimum value for the splitting key of the Oracle table.
* Description: Primarily used to configure the default maximum value for the splitting key of the Oracle table.
* Required: No
* Default: None

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/oracle/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ OracleReader通过使用dbmsreader中定义的查询流程调用go-etl自定义
- 默认值: 无

###### left
- 描述 主要用于配置oracle表的切分键默认最大值
- 描述 主要用于配置oracle表的切分键默认最小值
- 必选:否
- 默认值: 无

###### right
- 描述 主要用于配置oracle表的切分键默认最小值
- 描述 主要用于配置oracle表的切分键默认最大值
- 必选:否
- 默认值: 无

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ Describes the Postgres table information.
- Default: None

###### left
- Description: Mainly used to configure the default maximum value of the splitting key for the Postgres table.
- Description: Mainly used to configure the default minimum value of the splitting key for the Postgres table.
- Required: No
- Default: None

###### right
- Description: Mainly used to configure the default minimum value of the splitting key for the Postgres table.
- Description: Mainly used to configure the default maximum value of the splitting key for the Postgres table.
- Required: No
- Default: None

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/postgres/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ PostgresReader通过使用dbmsreader中定义的查询流程调用go-etl自定
- 默认值: 无

###### left
- 描述 主要用于配置db2表的切分键默认最大值
- 描述 主要用于配置db2表的切分键默认最小值
- 必选:否
- 默认值: 无

###### right
- 描述 主要用于配置db2表的切分键默认最小值
- 描述 主要用于配置db2表的切分键默认最大值
- 必选:否
- 默认值: 无

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/sqlserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ Describes the SQL Server table information.

###### left

- Description: Specifies the default maximum value for the SQL Server table's split key.
- Description: Specifies the default minimum value for the SQL Server table's split key.
- Required: No
- Default: None

###### right

- Description: Specifies the default minimum value for the SQL Server table's split key.
- Description: Specifies the default maximum value for the SQL Server table's split key.
- Required: No
- Default: None

Expand Down
4 changes: 2 additions & 2 deletions datax/plugin/reader/sqlserver/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ SQLServerReader通过使用dbmsreader中定义的查询流程调用go-etl自定
- 默认值: 无

###### left
- 描述 主要用于配置db2表的切分键默认最大值
- 描述 主要用于配置db2表的切分键默认最小值
- 必选:否
- 默认值: 无

###### right
- 描述 主要用于配置db2表的切分键默认最小值
- 描述 主要用于配置db2表的切分键默认最大值
- 必选:否
- 默认值: 无

Expand Down

0 comments on commit 76c5ec4

Please sign in to comment.