Skip to content

Commit

Permalink
changefeedccl: reject updated option when using Avro's key_only e…
Browse files Browse the repository at this point in the history
…nvelope

Before this change, we would accept the `WITH updated` option when using Avro's
`WITH envelope=key_only` option but would never actually output any updated
fields. This commit properly rejects the config, which doesn't make any sense.

Release note (backwards-incompatible change): The combination of
CHANGEFEED's format=experimental_avro, envelope=key_only, and updated
is now rejected. This is because the use of key_only prevents any
rows with updated fields from being emitted, so the updated option
is meaningless.
  • Loading branch information
nvanbenschoten committed Nov 21, 2019
1 parent e80f726 commit d44467b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/ccl/changefeedccl/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ func newConfluentAvroEncoder(opts map[string]string) (*confluentAvroEncoder, err
optEnvelope, opts[optEnvelope], optFormat, optFormatAvro)
}
_, e.updatedField = opts[optUpdatedTimestamps]
if e.updatedField && e.keyOnly {
return nil, errors.Errorf(`%s is only usable with %s=%s`,
optUpdatedTimestamps, optEnvelope, optEnvelopeWrapped)
}
_, e.beforeField = opts[optDiff]
if e.beforeField && e.keyOnly {
return nil, errors.Errorf(`%s is only usable with %s=%s`,
Expand Down
6 changes: 2 additions & 4 deletions pkg/ccl/changefeedccl/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ func TestEncoders(t *testing.T) {
resolved: `{"resolved":{"string":"1.0000000002"}}`,
},
`format=experimental_avro,envelope=key_only,updated`: {
insert: `{"a":{"long":1}}->`,
delete: `{"a":{"long":1}}->`,
resolved: `{"resolved":{"string":"1.0000000002"}}`,
err: `updated is only usable with envelope=wrapped`,
},
`format=experimental_avro,envelope=key_only,diff`: {
err: `diff is only usable with envelope=wrapped`,
},
`format=experimental_avro,envelope=key_only,updated,diff`: {
err: `diff is only usable with envelope=wrapped`,
err: `updated is only usable with envelope=wrapped`,
},
`format=experimental_avro,envelope=row`: {
err: `envelope=row is not supported with format=experimental_avro`,
Expand Down

0 comments on commit d44467b

Please sign in to comment.