Skip to content

Commit 9d84622

Browse files
authored
feat: run in script mode for multi ddl (#46)
1 parent c155c13 commit 9d84622

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mc2mc/internal/client/odps.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ func NewODPSClient(logger *slog.Logger, client *odps.Odps) *odpsClient {
2828
// with capability to do graceful shutdown by terminating task instance
2929
// when context is cancelled.
3030
func (c *odpsClient) ExecSQL(ctx context.Context, query string) error {
31-
taskIns, err := c.client.ExecSQl(query)
31+
hints := addHints(query)
32+
taskIns, err := c.client.ExecSQlWithHints(query, hints)
3233
if err != nil {
3334
return errors.WithStack(err)
3435
}
@@ -82,3 +83,14 @@ func wait(taskIns *odps.Instance) <-chan error {
8283
}(errChan)
8384
return errChan
8485
}
86+
87+
func addHints(query string) map[string]string {
88+
multisql := strings.Contains(query, ";")
89+
if multisql {
90+
return map[string]string{
91+
"odps.sql.submit.mode": "script",
92+
}
93+
}
94+
95+
return nil
96+
}

0 commit comments

Comments
 (0)