From 9fd89d8957c22dad1490a1d2ab5045986ba1e0e2 Mon Sep 17 00:00:00 2001 From: Hongzheng Shi Date: Mon, 26 Nov 2018 16:47:17 -0800 Subject: [PATCH 1/3] fix schema fetch metric --- metastore/schema_fetch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metastore/schema_fetch.go b/metastore/schema_fetch.go index cc11051f..549a2f96 100644 --- a/metastore/schema_fetch.go +++ b/metastore/schema_fetch.go @@ -70,7 +70,7 @@ func (j *SchemaFetchJob) fetchSchema() { } j.hash = newHash } - utils.GetRootReporter().GetCounter(utils.SchemaFetchSuccess) + utils.GetRootReporter().GetCounter(utils.SchemaFetchSuccess).Inc(1) } func (j *SchemaFetchJob) applySchemaChange(tables []common.Table) (err error) { @@ -131,6 +131,6 @@ func (j *SchemaFetchJob) applySchemaChange(tables []common.Table) (err error) { } func reportError(err error) { - utils.GetRootReporter().GetCounter(utils.SchemaFetchFailure) + utils.GetRootReporter().GetCounter(utils.SchemaFetchFailure).Inc(1) utils.GetLogger().Error(utils.StackError(err, "err running schema fetch job")) } From f2a4bc5b06d4b47372f39279b8e9092156cc9e2a Mon Sep 17 00:00:00 2001 From: Hongzheng Shi Date: Mon, 26 Nov 2018 17:46:39 -0800 Subject: [PATCH 2/3] fix default value compare --- metastore/schema_fetch.go | 1 + metastore/validator.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/metastore/schema_fetch.go b/metastore/schema_fetch.go index 549a2f96..2486949f 100644 --- a/metastore/schema_fetch.go +++ b/metastore/schema_fetch.go @@ -70,6 +70,7 @@ func (j *SchemaFetchJob) fetchSchema() { } j.hash = newHash } + utils.GetLogger().Info("Succeeded to run schema fetch job") utils.GetRootReporter().GetCounter(utils.SchemaFetchSuccess).Inc(1) } diff --git a/metastore/validator.go b/metastore/validator.go index ad8a87fb..2775de3c 100644 --- a/metastore/validator.go +++ b/metastore/validator.go @@ -167,7 +167,7 @@ func (v tableSchemaValidatorImpl) validateSchemaUpdate(newTable, oldTable *commo // check that no column configs are modified, even for deleted columns if oldCol.Name != newCol.Name || oldCol.Type != newCol.Type || - oldCol.DefaultValue != newCol.DefaultValue || + !reflect.DeepEqual(oldCol.DefaultValue, newCol.DefaultValue) || oldCol.CaseInsensitive != newCol.CaseInsensitive || oldCol.DisableAutoExpand != newCol.DisableAutoExpand { return ErrSchemaUpdateNotAllowed From 09f8902a1fef4a252c7c90f24be723777f475f7c Mon Sep 17 00:00:00 2001 From: Hongzheng Shi Date: Mon, 26 Nov 2018 17:59:59 -0800 Subject: [PATCH 3/3] add test --- metastore/validator_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/metastore/validator_test.go b/metastore/validator_test.go index 24fa09ce..1f0adaa7 100644 --- a/metastore/validator_test.go +++ b/metastore/validator_test.go @@ -108,6 +108,9 @@ var _ = ginkgo.Describe("Validator", func() { }) ginkgo.It("should be happy with valid updates", func() { + dv1 := "foo" + dv2 := "foo" + oldTable := common.Table{ Name: "testTable", Columns: []common.Column{ @@ -115,6 +118,11 @@ var _ = ginkgo.Describe("Validator", func() { Name: "col1", Type: "Int32", }, + { + Name: "col2", + Type: "SmallEnum", + DefaultValue: &dv1, + }, }, PrimaryKeyColumns: []int{0}, IsFactTable: true, @@ -130,6 +138,11 @@ var _ = ginkgo.Describe("Validator", func() { }, { Name: "col2", + Type: "SmallEnum", + DefaultValue: &dv2, + }, + { + Name: "col3", Type: "Int32", }, },