Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of JSON columns (#3643) #3653

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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