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

[CALCITE-5446] Add support for TIMESTAMP WITH LOCAL TIME ZONE #207

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wnob
Copy link
Contributor

@wnob wnob commented Feb 14, 2023

I know you already suggested getting rid of the fixedInstant boolean. I'm going to start teasing that apart now, but I'm looking for feedback on the tests in the mean time, which make up the bulk of this PR. It's a big PR but all the test cases are relatively independent and the test files can be reviewed one at a time.

@@ -215,15 +270,18 @@ public TestMetaImpl(AvaticaConnection connection) {
List<Object> row = Collections.<Object>singletonList(
new Object[] {
true, (byte) 1, (short) 2, 3, 4L, 5.0f, 6.0d, "testvalue",
new Date(1476130718123L), new Time(1476130718123L),
new Timestamp(1476130718123L),
new Date(DST_INSTANT), new Time(DST_INSTANT),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note:

  • DST_INSTANT = 1476130718123
  • STANDARD_INSTANT = 1479123123242
  • VALID_TIME = 1476123
  • OVERFLOW_TIME = 147912242

So this is not changing any of the test values; it's just giving them names so that equivalence is more apparent throughout the file.

Copy link
Contributor

@julianhyde julianhyde Feb 14, 2023

Choose a reason for hiding this comment

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

When I merge to main, I might split out a 'refactor' commit that does not add or change tests but just moves literals into constant fields. That will reduce confusion for future readers.

@@ -634,7 +701,7 @@ private DateArrayAccessorTestHelper(Getter g) {
ColumnMetaData.ScalarType intType =
ColumnMetaData.scalar(Types.DATE, "DATE", ColumnMetaData.Rep.PRIMITIVE_INT);
Array expectedArray =
new ArrayFactoryImpl(TimeZone.getTimeZone("UTC")).createArray(
new ArrayFactoryImpl(DateTimeUtils.DEFAULT_ZONE).createArray(
Copy link
Contributor Author

@wnob wnob Feb 14, 2023

Choose a reason for hiding this comment

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

This is to work around https://issues.apache.org/jira/browse/CALCITE-5488. Using the default zone instead of UTC for the array factory means that it's only adjusted once, after the array is converted to a result set.

@wnob wnob marked this pull request as draft February 14, 2023 19:10
@@ -46,12 +49,13 @@ public class TimeAccessorTest {
*/
@Before public void before() {
final AbstractCursor.Getter getter = new LocalGetter();
localCalendar = Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT);
instance = new AbstractCursor.TimeAccessor(getter, localCalendar);
localCalendar = Calendar.getInstance(IST_ZONE, Locale.ROOT);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's better to use a hardcoded time zone than the system default for these unit tests, so adjustment is tested consistently regardless of the host machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general I agree.

But some of JDBC's behavior is defined to use the local time zone. We need to test that behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The local time zone is injected at a higher level than inside the getters. The getters are provided with the local time zone at construction time by AbstractCursor, so the logic involving the system default time zone is tested in AvaticaResultSetConversionsTest

@F21
Copy link
Member

F21 commented Nov 14, 2023

@wob, should this be closed since there's #209?

@F21 F21 force-pushed the main branch 2 times, most recently from b97b819 to 4c0999b Compare November 28, 2023 23:39
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.

3 participants