From 6d4cdc8f5fdbfb16a3e35e648d20191974cd68cc Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Mon, 26 Sep 2022 19:19:20 +0800 Subject: [PATCH 1/8] Update snowflake endpoint Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/tasks/plugins/webapi/snowflake/plugin.go b/go/tasks/plugins/webapi/snowflake/plugin.go index bdbf8b565..370bb699f 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin.go +++ b/go/tasks/plugins/webapi/snowflake/plugin.go @@ -209,7 +209,7 @@ func buildRequest(method string, queryInfo QueryInfo, snowflakeEndpoint string, if snowflakeEndpoint == "" { snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/statements" } else { - snowflakeURL = snowflakeEndpoint + "/api/statements" + snowflakeURL = snowflakeEndpoint + "/api/v2/statements" } var data []byte From 1a51cb13c970ee2963dfed133bdb0311dfb170f0 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 28 Sep 2022 16:31:18 +0800 Subject: [PATCH 2/8] update endpoint Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/tasks/plugins/webapi/snowflake/plugin.go b/go/tasks/plugins/webapi/snowflake/plugin.go index 370bb699f..c216fc8bf 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin.go +++ b/go/tasks/plugins/webapi/snowflake/plugin.go @@ -207,7 +207,7 @@ func buildRequest(method string, queryInfo QueryInfo, snowflakeEndpoint string, var snowflakeURL string // for mocking/testing purposes if snowflakeEndpoint == "" { - snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/statements" + snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/v2/statements" } else { snowflakeURL = snowflakeEndpoint + "/api/v2/statements" } From bf3083439492f11517ea634ae56a1c1de86769a4 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 28 Sep 2022 16:46:41 +0800 Subject: [PATCH 3/8] update endpoint Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/tasks/plugins/webapi/snowflake/plugin.go b/go/tasks/plugins/webapi/snowflake/plugin.go index c216fc8bf..e2e6346ca 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin.go +++ b/go/tasks/plugins/webapi/snowflake/plugin.go @@ -207,14 +207,14 @@ func buildRequest(method string, queryInfo QueryInfo, snowflakeEndpoint string, var snowflakeURL string // for mocking/testing purposes if snowflakeEndpoint == "" { - snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/v2/statements" + snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/v2" } else { - snowflakeURL = snowflakeEndpoint + "/api/v2/statements" + snowflakeURL = snowflakeEndpoint + "/api/v2" } var data []byte if method == post && !isCancel { - snowflakeURL += "?async=true" + snowflakeURL += "/statements?async=true" data = []byte(fmt.Sprintf(`{ "statement": "%v", "database": "%v", From 46354be367c3d4e4b95123c94608e65a5a07952a Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 28 Sep 2022 17:02:36 +0800 Subject: [PATCH 4/8] update endpoint Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/tasks/plugins/webapi/snowflake/plugin.go b/go/tasks/plugins/webapi/snowflake/plugin.go index e2e6346ca..c216fc8bf 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin.go +++ b/go/tasks/plugins/webapi/snowflake/plugin.go @@ -207,14 +207,14 @@ func buildRequest(method string, queryInfo QueryInfo, snowflakeEndpoint string, var snowflakeURL string // for mocking/testing purposes if snowflakeEndpoint == "" { - snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/v2" + snowflakeURL = "https://" + account + ".snowflakecomputing.com/api/v2/statements" } else { - snowflakeURL = snowflakeEndpoint + "/api/v2" + snowflakeURL = snowflakeEndpoint + "/api/v2/statements" } var data []byte if method == post && !isCancel { - snowflakeURL += "/statements?async=true" + snowflakeURL += "?async=true" data = []byte(fmt.Sprintf(`{ "statement": "%v", "database": "%v", From 537494723e0b8742faa2dd92191d93f104eb0788 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 28 Sep 2022 17:06:27 +0800 Subject: [PATCH 5/8] update endpoint Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go/tasks/plugins/webapi/snowflake/plugin.go b/go/tasks/plugins/webapi/snowflake/plugin.go index c216fc8bf..09ff0156d 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin.go +++ b/go/tasks/plugins/webapi/snowflake/plugin.go @@ -167,6 +167,9 @@ func (p Plugin) Get(ctx context.Context, taskCtx webapi.GetContext) (latest weba } func (p Plugin) Delete(ctx context.Context, taskCtx webapi.DeleteContext) error { + if taskCtx.ResourceMeta() == nil { + return nil + } exec := taskCtx.ResourceMeta().(*ResourceMetaWrapper) req, err := buildRequest(post, QueryInfo{}, p.cfg.snowflakeEndpoint, exec.Account, exec.Token, exec.QueryID, true) From a81eb2325b81e8f69e012c5b3dc9fd3437511817 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 28 Sep 2022 17:21:26 +0800 Subject: [PATCH 6/8] update endpoint Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/go/tasks/plugins/webapi/snowflake/plugin.go b/go/tasks/plugins/webapi/snowflake/plugin.go index 09ff0156d..c216fc8bf 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin.go +++ b/go/tasks/plugins/webapi/snowflake/plugin.go @@ -167,9 +167,6 @@ func (p Plugin) Get(ctx context.Context, taskCtx webapi.GetContext) (latest weba } func (p Plugin) Delete(ctx context.Context, taskCtx webapi.DeleteContext) error { - if taskCtx.ResourceMeta() == nil { - return nil - } exec := taskCtx.ResourceMeta().(*ResourceMetaWrapper) req, err := buildRequest(post, QueryInfo{}, p.cfg.snowflakeEndpoint, exec.Account, exec.Token, exec.QueryID, true) From 6b033f26fae4df384134695b6fe1558e758d0923 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 28 Sep 2022 17:29:10 +0800 Subject: [PATCH 7/8] update tests Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/plugin_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/tasks/plugins/webapi/snowflake/plugin_test.go b/go/tasks/plugins/webapi/snowflake/plugin_test.go index 1c9e56d09..16a3ec4ae 100644 --- a/go/tasks/plugins/webapi/snowflake/plugin_test.go +++ b/go/tasks/plugins/webapi/snowflake/plugin_test.go @@ -66,7 +66,7 @@ func TestBuildRequest(t *testing.T) { token := "test-token" queryID := "019e70eb-0000-278b-0000-40f100012b1a" snowflakeEndpoint := "" - snowflakeURL := "https://" + account + ".snowflakecomputing.com/api/statements" + snowflakeURL := "https://" + account + ".snowflakecomputing.com/api/v2/statements" t.Run("build http request for submitting a snowflake query", func(t *testing.T) { queryInfo := QueryInfo{ Account: account, From ac8ed89f74ff4c7e50e2af768502c32cabe26150 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 29 Sep 2022 01:59:31 +0800 Subject: [PATCH 8/8] fix tests Signed-off-by: Kevin Su --- go/tasks/plugins/webapi/snowflake/integration_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/tasks/plugins/webapi/snowflake/integration_test.go b/go/tasks/plugins/webapi/snowflake/integration_test.go index b003433fb..3ee4048c3 100644 --- a/go/tasks/plugins/webapi/snowflake/integration_test.go +++ b/go/tasks/plugins/webapi/snowflake/integration_test.go @@ -65,7 +65,7 @@ func TestEndToEnd(t *testing.T) { func newFakeSnowflakeServer() *httptest.Server { statementHandle := "019e7546-0000-278c-0000-40f10001a082" return httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { - if request.URL.Path == "/api/statements" && request.Method == "POST" { + if request.URL.Path == "/api/v2/statements" && request.Method == "POST" { writer.WriteHeader(202) bytes := []byte(fmt.Sprintf(`{ "statementHandle": "%v", @@ -75,7 +75,7 @@ func newFakeSnowflakeServer() *httptest.Server { return } - if request.URL.Path == "/api/statements/"+statementHandle && request.Method == "GET" { + if request.URL.Path == "/api/v2/statements/"+statementHandle && request.Method == "GET" { writer.WriteHeader(200) bytes := []byte(fmt.Sprintf(`{ "statementHandle": "%v", @@ -85,7 +85,7 @@ func newFakeSnowflakeServer() *httptest.Server { return } - if request.URL.Path == "/api/statements/"+statementHandle+"/cancel" && request.Method == "POST" { + if request.URL.Path == "/api/v2/statements/"+statementHandle+"/cancel" && request.Method == "POST" { writer.WriteHeader(200) return }