From 9d84622bb3148361227e994f014bddc4273d9e4c Mon Sep 17 00:00:00 2001 From: Sandeep Bhardwaj Date: Fri, 6 Dec 2024 11:28:04 +0530 Subject: [PATCH] feat: run in script mode for multi ddl (#46) --- mc2mc/internal/client/odps.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mc2mc/internal/client/odps.go b/mc2mc/internal/client/odps.go index ffec60b..320e20c 100644 --- a/mc2mc/internal/client/odps.go +++ b/mc2mc/internal/client/odps.go @@ -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) } @@ -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 +}