You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/10/17 07:12:25 UTC

[GitHub] [incubator-devlake] abeizn opened a new pull request, #3449: fix: starrocks cached plan must not change result type

abeizn opened a new pull request, #3449:
URL: https://github.com/apache/incubator-devlake/pull/3449

   # Summary
   
   fix: starrocks cached plan must not change result type
   
   ### Does this close any open issues?
   Closes #3407 
   
   ### Screenshots
   Include any relevant screenshots here.
   
   ### Other Information
   Any other information that is important to this PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn merged pull request #3449: fix: starrocks cached plan must not change result type

Posted by GitBox <gi...@apache.org>.
abeizn merged PR #3449:
URL: https://github.com/apache/incubator-devlake/pull/3449


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] long2ice commented on a diff in pull request #3449: fix: starrocks cached plan must not change result type

Posted by GitBox <gi...@apache.org>.
long2ice commented on code in PR #3449:
URL: https://github.com/apache/incubator-devlake/pull/3449#discussion_r996711468


##########
plugins/starrocks/tasks.go:
##########
@@ -162,13 +163,27 @@ func createTable(starrocks *sql.DB, db dal.Dal, starrocksTable string, table str
 
 func loadData(starrocks *sql.DB, c core.SubTaskContext, starrocksTable string, table string, columnMap map[string]string, db dal.Dal, config *StarRocksConfig) error {
 	offset := 0
-	starrocksTmpTable := starrocksTable + "_tmp"
-	// create tmp table in starrocks
-	_, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksTmpTable, starrocksTmpTable, starrocksTable))
+	var err error
+
+	// step1: create starrocksNewTable
+	starrocksNewTable := starrocksTable + "_new"
+	_, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksNewTable, starrocksNewTable, starrocksTable))
 	if execErr != nil {
 		return execErr
 	}
-	var err error
+
+	// step2: renmae starrocksTable to starrocksOldTable

Review Comment:
   rename拼写错误



##########
plugins/starrocks/tasks.go:
##########
@@ -162,13 +163,27 @@ func createTable(starrocks *sql.DB, db dal.Dal, starrocksTable string, table str
 
 func loadData(starrocks *sql.DB, c core.SubTaskContext, starrocksTable string, table string, columnMap map[string]string, db dal.Dal, config *StarRocksConfig) error {
 	offset := 0
-	starrocksTmpTable := starrocksTable + "_tmp"
-	// create tmp table in starrocks
-	_, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksTmpTable, starrocksTmpTable, starrocksTable))
+	var err error
+
+	// step1: create starrocksNewTable
+	starrocksNewTable := starrocksTable + "_new"
+	_, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksNewTable, starrocksNewTable, starrocksTable))
 	if execErr != nil {
 		return execErr
 	}
-	var err error
+
+	// step2: renmae starrocksTable to starrocksOldTable
+	starrocksOldTable := starrocksTable + "_old"
+	_, err = starrocks.Exec(fmt.Sprintf("alter table %s rename %s", starrocksTable, starrocksOldTable))

Review Comment:
   这里先把starrocksTable改为old了,那么在数据导入过程中这个表都不可用,不可用的时间会变长



##########
plugins/starrocks/tasks.go:
##########
@@ -162,13 +163,27 @@ func createTable(starrocks *sql.DB, db dal.Dal, starrocksTable string, table str
 
 func loadData(starrocks *sql.DB, c core.SubTaskContext, starrocksTable string, table string, columnMap map[string]string, db dal.Dal, config *StarRocksConfig) error {
 	offset := 0
-	starrocksTmpTable := starrocksTable + "_tmp"
-	// create tmp table in starrocks
-	_, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksTmpTable, starrocksTmpTable, starrocksTable))
+	var err error
+
+	// step1: create starrocksNewTable
+	starrocksNewTable := starrocksTable + "_new"
+	_, execErr := starrocks.Exec(fmt.Sprintf("drop table if exists %s; create table %s like %s", starrocksNewTable, starrocksNewTable, starrocksTable))
 	if execErr != nil {
 		return execErr
 	}
-	var err error
+
+	// step2: renmae starrocksTable to starrocksOldTable
+	starrocksOldTable := starrocksTable + "_old"
+	_, err = starrocks.Exec(fmt.Sprintf("alter table %s rename %s", starrocksTable, starrocksOldTable))
+	defer func() {
+		if err != nil {
+			_, err = starrocks.Exec(fmt.Sprintf("alter table %s rename %s", starrocksTable, starrocksOldTable))

Review Comment:
   这里是想在导入出错的时候把old恢复吧,好像反了



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org