You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/08/19 12:17:34 UTC
[incubator-devlake] 01/02: feat: drop tmp table first and check redirect
This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 3e63caf2824b12ef75a973832178289384c99777
Author: Jinlong Peng <ji...@merico.dev>
AuthorDate: Fri Aug 19 17:39:41 2022 +0800
feat: drop tmp table first and check redirect
---
plugins/starrocks/tasks.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/starrocks/tasks.go b/plugins/starrocks/tasks.go
index 3bf9cfd3..9f9de75f 100644
--- a/plugins/starrocks/tasks.go
+++ b/plugins/starrocks/tasks.go
@@ -134,7 +134,7 @@ func loadData(starrocks *sql.DB, c core.SubTaskContext, starrocksTable string, t
offset := 0
starrocksTmpTable := starrocksTable + "_tmp"
// create tmp table in starrocks
- _, execErr := starrocks.Exec(fmt.Sprintf("create table %s like %s", starrocksTmpTable, starrocksTable))
+ _, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksTmpTable, starrocksTmpTable, starrocksTable))
if execErr != nil {
return execErr
}
@@ -195,10 +195,10 @@ func loadData(starrocks *sql.DB, c core.SubTaskContext, starrocksTable string, t
req.Header.Set(k, v)
}
resp, err := client.Do(req)
- if err != nil && err != http.ErrUseLastResponse {
+ if err != nil {
return err
}
- if err == http.ErrUseLastResponse {
+ if resp.StatusCode == 307 {
var location *url.URL
location, err = resp.Location()
req, err = http.NewRequest(http.MethodPut, location.String(), bytes.NewBuffer(jsonData))