-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Round TimeWithTimeZone
when supportsParametricDateTime
is false
#14950
Conversation
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.
FYI @findepi/@martint
|
||
if (type instanceof TimeWithTimeZoneType) { | ||
return ((SqlTimeWithTimeZone) value).roundTo(3); | ||
} |
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.
good catch. I didn't notice this myself when I shared the link. 👍
*/ | ||
package io.trino.spi.type; | ||
|
||
import org.testng.annotations.Test; |
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.
Use junit for new tests.
assertThat(newInstance(0, 0, 1).toString()).isEqualTo("00:00:00+00:01"); | ||
assertThat(newInstance(1, 0, 1).toString()).isEqualTo("00:00:00.0+00:01"); | ||
assertThat(newInstance(2, 0, 1).toString()).isEqualTo("00:00:00.00+00:01"); | ||
assertThat(newInstance(3, 0, 1).toString()).isEqualTo("00:00:00.000+00:01"); | ||
assertThat(newInstance(4, 0, 1).toString()).isEqualTo("00:00:00.0000+00:01"); | ||
assertThat(newInstance(5, 0, 1).toString()).isEqualTo("00:00:00.00000+00:01"); | ||
assertThat(newInstance(6, 0, 1).toString()).isEqualTo("00:00:00.000000+00:01"); | ||
assertThat(newInstance(7, 0, 1).toString()).isEqualTo("00:00:00.0000000+00:01"); | ||
assertThat(newInstance(8, 0, 1).toString()).isEqualTo("00:00:00.00000000+00:01"); | ||
assertThat(newInstance(9, 0, 1).toString()).isEqualTo("00:00:00.000000000+00:01"); | ||
assertThat(newInstance(10, 0, 1).toString()).isEqualTo("00:00:00.0000000000+00:01"); | ||
assertThat(newInstance(11, 0, 1).toString()).isEqualTo("00:00:00.00000000000+00:01"); | ||
assertThat(newInstance(12, 0, 1).toString()).isEqualTo("00:00:00.000000000000+00:01"); |
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.
Don't convert to String before comparing. Compare directly against instances created with SqlTimeWithTimeZone.newInstance
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.
I agree in case of all other tests except here we don't apply any transformation, so we have to compare against another representation.
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.
Ah, yes, I meant to put the comment in the methods below. For this one, rename the test to testToString
, as that's what's being tested here.
Also, this test is unrelated to the fix in this commit, so move it to a separate commit.
@@ -15,14 +15,66 @@ | |||
|
|||
import org.testng.annotations.Test; | |||
|
|||
import static io.trino.spi.type.SqlTimeWithTimeZone.newInstance; |
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.
Don't static import this method. The name is too ambiguous.
import static io.trino.spi.type.SqlTime.newInstance; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class TestSqlTime |
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.
This test is unrelated to the fix in this commit. Move it to a separate commit.
assertThat(newInstance(0, 0, 1).toString()).isEqualTo("00:00:00+00:01"); | ||
assertThat(newInstance(1, 0, 1).toString()).isEqualTo("00:00:00.0+00:01"); | ||
assertThat(newInstance(2, 0, 1).toString()).isEqualTo("00:00:00.00+00:01"); | ||
assertThat(newInstance(3, 0, 1).toString()).isEqualTo("00:00:00.000+00:01"); | ||
assertThat(newInstance(4, 0, 1).toString()).isEqualTo("00:00:00.0000+00:01"); | ||
assertThat(newInstance(5, 0, 1).toString()).isEqualTo("00:00:00.00000+00:01"); | ||
assertThat(newInstance(6, 0, 1).toString()).isEqualTo("00:00:00.000000+00:01"); | ||
assertThat(newInstance(7, 0, 1).toString()).isEqualTo("00:00:00.0000000+00:01"); | ||
assertThat(newInstance(8, 0, 1).toString()).isEqualTo("00:00:00.00000000+00:01"); | ||
assertThat(newInstance(9, 0, 1).toString()).isEqualTo("00:00:00.000000000+00:01"); | ||
assertThat(newInstance(10, 0, 1).toString()).isEqualTo("00:00:00.0000000000+00:01"); | ||
assertThat(newInstance(11, 0, 1).toString()).isEqualTo("00:00:00.00000000000+00:01"); | ||
assertThat(newInstance(12, 0, 1).toString()).isEqualTo("00:00:00.000000000000+00:01"); |
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.
Ah, yes, I meant to put the comment in the methods below. For this one, rename the test to testToString
, as that's what's being tested here.
Also, this test is unrelated to the fix in this commit, so move it to a separate commit.
public class TestSqlTime | ||
{ | ||
@Test | ||
public void testBaseline() |
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.
Rename to testToString
a369a2d
to
f83ecc2
Compare
f83ecc2
to
4e42bd4
Compare
@@ -40,7 +40,40 @@ public void testToString() | |||
@Test | |||
public void testEqualsDifferentZone() | |||
{ | |||
assertThat(SqlTimeWithTimeZone.newInstance(12, 0, 0)) | |||
.isNotEqualTo(SqlTimeWithTimeZone.newInstance(12, 0, 1)); | |||
assertThat(SqlTimeWithTimeZone.newInstance(12, 0, 0)).isNotEqualTo(SqlTimeWithTimeZone.newInstance(12, 0, 1)); |
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.
Unrelated change
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.
Sorry for that, removed!
4e42bd4
to
6a28dfb
Compare
Description
When
PARAMETRIC_DATETIME
is not set, all temporal types should be rounded up to precision 3. However TimeWithTimeZone is not rounded.Non-technical explanation
Release notes
( ) This is not user-visible or docs only and no release notes are required.
(x) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: