Skip to content

Commit b13bf4c

Browse files
committed
move hints to string function
1 parent 0b825ad commit b13bf4c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

mc2mc/internal/client/odps.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,8 @@ func (c *odpsClient) ExecSQL(ctx context.Context, query string, additionalHints
3838
return nil
3939
}
4040

41-
// add job-specific hints, which takes priority over the global hints
4241
hints := addHints(additionalHints, query)
4342

44-
logHints := make([]string, 0)
45-
for k, v := range hints {
46-
logHints = append(logHints, fmt.Sprintf("%s: %s", k, v))
47-
}
48-
4943
taskIns, err := c.client.ExecSQlWithHints(query, hints)
5044
if err != nil {
5145
return errors.WithStack(err)
@@ -57,7 +51,7 @@ func (c *odpsClient) ExecSQL(ctx context.Context, query string, additionalHints
5751
err = e.Join(err, taskIns.Terminate())
5852
return errors.WithStack(err)
5953
}
60-
c.logger.Info(fmt.Sprintf("taskId: %s, log view: %s, hints: (%s)", taskIns.Id(), url, strings.Join(logHints, ", ")))
54+
c.logger.Info(fmt.Sprintf("taskId: %s, log view: %s, hints: (%s)", taskIns.Id(), url, getHintsString(hints)))
6155

6256
// wait execution success
6357
select {
@@ -219,3 +213,14 @@ func retry(l *slog.Logger, retryMax int, retryBackoffMs int64, f func() error) e
219213

220214
return err
221215
}
216+
217+
func getHintsString(hints map[string]string) string {
218+
if hints == nil {
219+
return ""
220+
}
221+
var hintsStr []string
222+
for k, v := range hints {
223+
hintsStr = append(hintsStr, fmt.Sprintf("%s: %s", k, v))
224+
}
225+
return strings.Join(hintsStr, ", ")
226+
}

0 commit comments

Comments
 (0)