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

The nanos portion of a timestamp needs to come before the tz #3798

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

quodlibetor
Copy link
Contributor

@quodlibetor quodlibetor commented Jul 30, 2020

This change is Reviewable

Copy link
Member

@benesch benesch left a comment

Choose a reason for hiding this comment

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

LGTM, but can you add a test?

@quodlibetor
Copy link
Contributor Author

I didn't see any tests for this module, happy to add one, it's a bit hard to verify with testdrive since it just does string comparison.

@benesch
Copy link
Member

benesch commented Jul 30, 2020

I would think that testdrive attempting to parse the timestamptz output format would break?

@benesch
Copy link
Member

benesch commented Jul 30, 2020

Hmm, dates-times.td already has a bunch of tests that don't break. I wonder what's going wrong.

@benesch
Copy link
Member

benesch commented Jul 30, 2020

Oh, right, because testdrive uses the binary format, which isn't broken. Something like this should do the trick:

diff --git a/test/testdrive/dates-times.td b/test/testdrive/dates-times.td
index 4f802280..92af95c3 100644
--- a/test/testdrive/dates-times.td
+++ b/test/testdrive/dates-times.td
@@ -105,3 +105,6 @@ $ kafka-ingest format=avro topic=data schema=${schema} timestamp=10
 
 > SELECT TIMESTAMPTZ '1989-06-01 9:10:10.410+700'
 "1989-06-01 02:10:10.410 UTC"
+
+> SELECT '1989-06-01 10:10:10.410+04:00'::timestamptz::text
+"1989-06-01 06:10:10.410+00"

@quodlibetor
Copy link
Contributor Author

Does it parse, or just verify that they match? I'll dig in.

@quodlibetor
Copy link
Contributor Author

To be clear, I posted my comment about adding tests concurrently with you asking for tests, I'm happy to look into it.

@quodlibetor
Copy link
Contributor Author

Oh that's a different category of test than I was thinking of, but yeah, that would catch this, I'll add it.

@benesch
Copy link
Member

benesch commented Jul 30, 2020

Yeah, sorry, GH reviews is failing to keep up with us :D. The problem is that we don't have any tests of the timestamptz->text cast. Testdrive (or SLT) can handle that if you just force the timestamptz->text cast to happen explicitly in the query, rather than implicitly as part of the pgwire format (since testdrive uses the binary serialization, and SLT looks at Datums directly).

@quodlibetor
Copy link
Contributor Author

Yeah I was thinking of adding a unit test directly in the module to make sure that it round-trips correctly, but this seems fine to prevent regressions.

@benesch
Copy link
Member

benesch commented Jul 30, 2020

Yeah if you do wanna add a unit test heads up that they are in https://github.com/MaterializeInc/materialize/blob/main/src/repr/tests/strconv.rs for this module (i.e., what Cargo would fall an “integration” test). This looks great though!

@quodlibetor quodlibetor merged commit b210464 into MaterializeInc:main Jul 30, 2020
@quodlibetor quodlibetor deleted the fix-ts-format branch July 30, 2020 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants