From 8b03619e6b18bd19dc8e5b3e94b37ea9025e532b Mon Sep 17 00:00:00 2001 From: Ildar Nurislamov Date: Wed, 4 Dec 2024 15:27:17 +0400 Subject: [PATCH] bulker: snowflake: don't load primary keys for empty tables --- bulkerlib/implementations/sql/snowflake.go | 4 ++++ config-keeper/router.go | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bulkerlib/implementations/sql/snowflake.go b/bulkerlib/implementations/sql/snowflake.go index b01cbaf..8f32ca9 100644 --- a/bulkerlib/implementations/sql/snowflake.go +++ b/bulkerlib/implementations/sql/snowflake.go @@ -291,6 +291,10 @@ func (s *Snowflake) GetTableSchema(ctx context.Context, namespace string, tableN Statement: query, }) } + + if table.ColumnsCount() == 0 { + return table, nil + } primaryKeyName, pkFields, err := s.getPrimaryKey(ctx, namespace, tableName) if err != nil { diff --git a/config-keeper/router.go b/config-keeper/router.go index c9cf53f..5cc8627 100644 --- a/config-keeper/router.go +++ b/config-keeper/router.go @@ -57,10 +57,17 @@ func NewRouter(appContext *Context) *Router { } repStatuses[name] = status } - c.JSON(http.StatusOK, gin.H{ - "status": utils.Ternary(healthy, "pass", "fail"), - "repositories": repStatuses, - }) + if healthy { + c.JSON(http.StatusOK, gin.H{ + "status": "pass", + "repositories": repStatuses, + }) + } else { + c.JSON(http.StatusServiceUnavailable, gin.H{ + "status": "fail", + "repositories": repStatuses, + }) + } }) return router