Skip to content

Commit

Permalink
Merge pull request #27 from uber/fix
Browse files Browse the repository at this point in the history
fix schema fetch metric
  • Loading branch information
shz117 authored Nov 27, 2018
2 parents c8a79e0 + 09f8902 commit 5bde278
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions metastore/schema_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func (j *SchemaFetchJob) fetchSchema() {
}
j.hash = newHash
}
utils.GetRootReporter().GetCounter(utils.SchemaFetchSuccess)
utils.GetLogger().Info("Succeeded to run schema fetch job")
utils.GetRootReporter().GetCounter(utils.SchemaFetchSuccess).Inc(1)
}

func (j *SchemaFetchJob) applySchemaChange(tables []common.Table) (err error) {
Expand Down Expand Up @@ -131,6 +132,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"))
}
2 changes: 1 addition & 1 deletion metastore/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions metastore/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ 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{
{
Name: "col1",
Type: "Int32",
},
{
Name: "col2",
Type: "SmallEnum",
DefaultValue: &dv1,
},
},
PrimaryKeyColumns: []int{0},
IsFactTable: true,
Expand All @@ -130,6 +138,11 @@ var _ = ginkgo.Describe("Validator", func() {
},
{
Name: "col2",
Type: "SmallEnum",
DefaultValue: &dv2,
},
{
Name: "col3",
Type: "Int32",
},
},
Expand Down

0 comments on commit 5bde278

Please sign in to comment.