Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion mc2mc/internal/client/odps.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
e "errors"
"fmt"
"log/slog"
"net/url"
"strings"
"time"

Expand Down Expand Up @@ -46,7 +47,7 @@ func (c *odpsClient) ExecSQL(ctx context.Context, query string, additionalHints
}

// generate log view
url, err := odps.NewLogView(c.client).GenerateLogView(taskIns, c.logViewRetentionInDays*24)
url, err := c.generateLogView(taskIns)
if err != nil {
err = e.Join(err, taskIns.Terminate())
return errors.WithStack(err)
Expand Down Expand Up @@ -109,6 +110,28 @@ func (c *odpsClient) GetOrderedColumns(tableID string) ([]string, error) {
return columnNames, nil
}

// generateLogView generates the log view for the given task instance
func (c *odpsClient) generateLogView(taskIns *odps.Instance) (string, error) {
u, err := c.client.LogView().GenerateLogView(taskIns, c.logViewRetentionInDays*24)
if err != nil {
return "", errors.WithStack(err)
}

// change query parameter h to http://service.id-all.maxcompute.aliyun-inc.com
parsedURL, err := url.Parse(u)
if err != nil {
return "", errors.WithStack(err)
}
q := parsedURL.Query()
q.Set("h", "http://service.id-all.maxcompute.aliyun-inc.com/api")

// reconstruct the URL with the new query parameter
parsedURL.RawQuery = q.Encode()
u = parsedURL.String()

return u, nil
}

// wait waits for the task instance to finish on a separate goroutine
func (c *odpsClient) wait(taskIns *odps.Instance) <-chan error {
errChan := make(chan error)
Expand Down
Loading