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

c2c: allow user to pass start time as a decimal to crdb_internal.fingerprint() #104219

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

msbutler
Copy link
Collaborator

@msbutler msbutler commented Jun 1, 2023

Previously, the user could only pass the startTime variable to crdb_internal.fingerprint() as a TimestampTZ, which only has microsecond precision. To enable nanosecond precision, this patch allows the user to pass the startTime as a decimal. This patch is consistent with the user's ability to pass and AOST timestamp as a decimal as well.

Informs #103072

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@msbutler msbutler force-pushed the butler-fingerprint-input branch 2 times, most recently from 40f9e68 to 90287ed Compare June 1, 2023 18:06
@msbutler msbutler marked this pull request as ready for review June 1, 2023 19:14
@msbutler msbutler requested review from a team as code owners June 1, 2023 19:14
@msbutler msbutler requested review from srosenberg and smg260 and removed request for a team June 1, 2023 19:14
},
Info: "This function is used only by CockroachDB's developers for testing purposes.",
Volatility: volatility.Stable,
},
tree.Overload{
Types: tree.ParamTypes{
{Name: "span", Typ: types.BytesArray},
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need the TimestampTZ overload? or can we just replace it with the more accurate decimal overload that you added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept the TimestampTZ overload because it's userfriendly and bc i'm lazy and didn't want to refactor all the tests that already use it :D.

var fingerprint int64
query := fmt.Sprintf(`SELECT * FROM crdb_internal.fingerprint(ARRAY[$1::BYTES, $2::BYTES], $3, $4) AS OF SYSTEM TIME %s`, decimal.String())
require.NoError(t, sqlDB.QueryRow(query, roachpb.Key(startKey), roachpb.Key(endKey), startTime.GoTime(), allRevisions).Scan(&fingerprint))
query := fmt.Sprintf(`SELECT * FROM crdb_internal.fingerprint(ARRAY[$1::BYTES, $2::BYTES],$3::DECIMAL, $4) AS OF SYSTEM TIME '%s'`, aost)
Copy link
Contributor

Choose a reason for hiding this comment

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

so this test is for the decimal overload, do we have a test for the TimestampTZ one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, there's a test below this one in this package and plenty of other unit tests in other packages use the timestamp overload.

…erprint()

Previously, the user could only pass the startTime variable to
crdb_internal.fingerprint() as a TimestampTZ, which only has microsecond
precision. To enable nanosecond precision, this patch allows the user to pass
the startTime as a decimal. This patch is consistent with the user's ability to
pass and AOST timestamp as a decimal as well.

Informs cockroachdb#103072

Release note: None
@msbutler msbutler force-pushed the butler-fingerprint-input branch from 90287ed to bb45084 Compare June 12, 2023 15:47
@msbutler
Copy link
Collaborator Author

TFTR!!

bors r=lidorcarmel

@craig
Copy link
Contributor

craig bot commented Jun 13, 2023

This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried.

Additional information:

{"message":"Changes must be made through a pull request.","documentation_url":"https://docs.github.com/articles/about-protected-branches"}

@msbutler
Copy link
Collaborator Author

bors r+ single on

@craig
Copy link
Contributor

craig bot commented Jun 13, 2023

Build succeeded:

@craig craig bot merged commit b6262d5 into cockroachdb:master Jun 13, 2023
@msbutler
Copy link
Collaborator Author

blathers backport 23.1

@blathers-crl
Copy link

blathers-crl bot commented Jun 13, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from bb45084 to blathers/backport-release-23.1-104219: 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 failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

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.

3 participants