Skip to content

Commit

Permalink
feat: run in script mode for multi ddl (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbchaos authored Dec 6, 2024
1 parent c155c13 commit 9d84622
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mc2mc/internal/client/odps.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func NewODPSClient(logger *slog.Logger, client *odps.Odps) *odpsClient {
// with capability to do graceful shutdown by terminating task instance
// when context is cancelled.
func (c *odpsClient) ExecSQL(ctx context.Context, query string) error {
taskIns, err := c.client.ExecSQl(query)
hints := addHints(query)
taskIns, err := c.client.ExecSQlWithHints(query, hints)
if err != nil {
return errors.WithStack(err)
}
Expand Down Expand Up @@ -82,3 +83,14 @@ func wait(taskIns *odps.Instance) <-chan error {
}(errChan)
return errChan
}

func addHints(query string) map[string]string {
multisql := strings.Contains(query, ";")
if multisql {
return map[string]string{
"odps.sql.submit.mode": "script",
}
}

return nil
}

0 comments on commit 9d84622

Please sign in to comment.