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
changefeedccl: fix bug with avro encoding and zero-scale decimal cols #118815
Conversation
An alternative idea would be to either submit a patch to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @andyyang890, @nicktrav, @rharding6373, and @wenyihu6)
pkg/ccl/changefeedccl/avro.go
line 78 at r1 (raw file):
SchemaType avroSchemaType `json:"type"` LogicalType string `json:"logicalType"` Precision int `json:"precision,omitempty"`
Looks like tests are failing due to precision 0 and scale 0 being included when they shouldn't. Maybe we need to do this https://stackoverflow.com/questions/38486564/unmarshal-marshal-json-with-int-set-to-0-does-not-seem-to-work
This patch fixes a bug where creating a changefeed that targeted tables with a `DECIMAL(n)` column (i.e. zero-scale `DECIMAL` column), `format='avro'`, and `diff` would cause a panic. The cause of this panic was the fact that the third-party `goavro` library we use expected the JSON encoding of the schema to have a numeric `scale` field for decimal types, but we omitted this field whenever it was zero (using `omitempty`), which led to a runtime type assertion failure. We've updated the field to a pointer type in our type definition so that we can distinguish between an unset value and a zero value. Release note (enterprise change): Fixed a bug where creating a changefeed that targeted tables with a `DECIMAL(n)` column (i.e. zero-scale `DECIMAL` column), `format='avro'`, and `diff` would cause a panic.
a5273b7
to
907aaa6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jayshrivastava, @nicktrav, @rharding6373, and @wenyihu6)
pkg/ccl/changefeedccl/avro.go
line 78 at r1 (raw file):
Previously, jayshrivastava (Jayant) wrote…
Looks like tests are failing due to precision 0 and scale 0 being included when they shouldn't. Maybe we need to do this https://stackoverflow.com/questions/38486564/unmarshal-marshal-json-with-int-set-to-0-does-not-seem-to-work
Done. Thanks for the pointer (no pun intended).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @jayshrivastava, @nicktrav, and @wenyihu6)
TFTRs! bors r=jayshrivastava,rharding6373 |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from 907aaa6 to blathers/backport-release-23.1-118815: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 23.1.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
blathers backport 23.2.1-rc |
This patch fixes a bug where creating a changefeed that targeted
tables with a
DECIMAL(n)
column (i.e. zero-scaleDECIMAL
column),format='avro'
, anddiff
would cause a panic.The cause of this panic was the fact that the third-party
goavro
library we use expected the JSON encoding of the schema to have
a numeric
scale
field for decimal types, but we omitted thisfield whenever it was zero (using
omitempty
), which led to aruntime type assertion failure. We've updated the field to a pointer
type in our type definition so that we can distinguish between an
unset value and a zero value.
Fixes #118647
Release note (enterprise change): Fixed a bug where creating a
changefeed that targeted tables with a
DECIMAL(n)
column(i.e. zero-scale
DECIMAL
column),format='avro'
, anddiff
would cause a panic.