Skip to content

Commit

Permalink
Fix handling of JSON columns (pingcap#3643) (pingcap#3652)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored and 3AceShowHand committed Dec 25, 2021
1 parent 666ac9e commit 643fb1b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cdc/sink/codec/avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/pingcap/ticdc/cdc/model"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/tidb/types"
tijson "github.com/pingcap/tidb/types/json"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -474,7 +473,7 @@ func columnToAvroNativeData(col *model.Column, tz *time.Location) (interface{},
case mysql.TypeYear:
return col.Value.(int64), "long", nil
case mysql.TypeJSON:
return col.Value.(tijson.BinaryJSON).String(), "string", nil
return col.Value.(string), "string", nil
case mysql.TypeNewDecimal:
return col.Value.(string), "string", nil
case mysql.TypeEnum:
Expand Down
1 change: 1 addition & 0 deletions cdc/sink/codec/avro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (s *avroBatchEncoderSuite) TestAvroEncodeOnly(c *check.C) {
{Name: "myfloat", Value: float64(3.14), Type: mysql.TypeFloat},
{Name: "mybytes", Value: []byte("Hello World"), Type: mysql.TypeBlob},
{Name: "ts", Value: time.Now().Format(types.TimeFSPFormat), Type: mysql.TypeTimestamp},
{Name: "myjson", Value: "{\"foo\": \"bar\"}", Type: mysql.TypeJSON},
}, time.Local)
c.Assert(err, check.IsNil)

Expand Down

0 comments on commit 643fb1b

Please sign in to comment.