@@ -16,6 +16,7 @@ type odpsClient struct {
1616 client * odps.Odps
1717
1818 logViewRetentionInDays int
19+ additionalHints map [string ]string
1920}
2021
2122// NewODPSClient creates a new odpsClient instance
@@ -31,7 +32,7 @@ func NewODPSClient(logger *slog.Logger, client *odps.Odps) *odpsClient {
3132// with capability to do graceful shutdown by terminating task instance
3233// when context is cancelled.
3334func (c * odpsClient ) ExecSQL (ctx context.Context , query string ) error {
34- hints := addHints (query )
35+ hints := addHints (c . additionalHints , query )
3536 taskIns , err := c .client .ExecSQlWithHints (query , hints )
3637 if err != nil {
3738 return errors .WithStack (err )
@@ -57,6 +58,11 @@ func (c *odpsClient) ExecSQL(ctx context.Context, query string) error {
5758 }
5859}
5960
61+ // SetAdditionalHints sets the additional hints for the odps client
62+ func (c * odpsClient ) SetAdditionalHints (hints map [string ]string ) {
63+ c .additionalHints = hints
64+ }
65+
6066// SetLogViewRetentionInDays sets the log view retention in days
6167func (c * odpsClient ) SetLogViewRetentionInDays (days int ) {
6268 c .logViewRetentionInDays = days
@@ -108,15 +114,17 @@ func wait(taskIns *odps.Instance) <-chan error {
108114 return errChan
109115}
110116
111- func addHints (query string ) map [string ]string {
117+ func addHints (additionalHints map [string ]string , query string ) map [string ]string {
118+ hints := make (map [string ]string )
119+ for k , v := range additionalHints {
120+ hints [k ] = v
121+ }
112122 multisql := strings .Contains (query , ";" )
113123 if multisql {
114- return map [string ]string {
115- "odps.sql.submit.mode" : "script" ,
116- }
124+ hints ["odps.sql.submit.mode" ] = "script"
117125 }
118126
119- return nil
127+ return hints
120128}
121129
122130// getTable returns the table with the given tableID
0 commit comments