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

VStreamer Events: remove preceding zeroes from decimals in Row Events #7297

Merged

Conversation

rohit-nayak-ps
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps commented Jan 14, 2021

Description

Currently in VStreamer ROW Events, Decimal numbers get prefix-padded with 0s when precision is greater than 12.
e.g. for a value of 1.23, DECIMAL(12,2) gives 1.23, DECIMAL(13,2) gives 000000001.23

This PR removes these extra 0s so, for the example above, we return 1.23 for DECIMAL(13,2)

Related Issue(s)

#7282

Checklist

  • Should this PR be backported?
  • Tests were added or are not required
  • Documentation was added or is not required

Impacted Areas in Vitess

  • Query Serving
  • VReplication
  • Cluster Management
  • Build
  • VTAdmin

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
@rohit-nayak-ps rohit-nayak-ps changed the title VStreamer Events: remove preceding zeroes from decimals VStreamer Events: remove preceding zeroes from decimals in Row Events Jan 14, 2021
@rohit-nayak-ps rohit-nayak-ps marked this pull request as ready for review January 14, 2021 18:37
Copy link
Contributor

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for completeness, can we add a unit test for a negative -0000000001.23 value?

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
@@ -1610,6 +1612,16 @@ func TestTypes(t *testing.T) {
`type:ROW row_event:<table_name:"vitess_decimal" row_changes:<after:<lengths:1 lengths:7 lengths:7 values:"2-1.2300-1.2300" > > > `,
`gtid`,
`commit`,
}, {
`begin`,
`type:ROW row_event:<table_name:"vitess_decimal" row_changes:<after:<lengths:1 lengths:6 lengths:6 values:"31.23001.2300" > > > `,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess its because I do not understand the encodings, but 31.23001.2300 is mightily confusing to me. What separates the values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, skip that. solved by lengths 1, 6, 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants