-
Notifications
You must be signed in to change notification settings - Fork 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
feat: timestamp support - casting, comparisons and serde #6806
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.ksql.function.types; | ||
|
||
public final class TimestampType extends ObjectType { | ||
public static final TimestampType INSTANCE = new TimestampType(); | ||
|
||
private TimestampType() { | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 7; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
return obj instanceof TimestampType; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TIMESTAMP"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,12 @@ public void shouldIncludeRequiredFormatInErrorMessage() { | |
+ "with an optional numeric 4-digit timezone")); | ||
} | ||
|
||
@Test | ||
public void shouldParseToTimestamp() { | ||
assertThat(parser.parseToTimestamp("2017-11-13T23:59:58").getTime(), is(1510617598000L)); | ||
assertThat(parser.parseToTimestamp("2017-11-13T23:59:58.999-0100").getTime(), is(1510621198999L)); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a test to parse a time without timezone. Btw, are we supporting this? or what is the behavior we discussed when using timezone values in the a string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conclusion was to include a conversion function and to not store timezone information. Timezones in strings were not specified in the klip, but I think it makes sense to support it because this is basically the same thing as calling |
||
private static long fullParse(final String text) { | ||
return FULL_PARSER.parse(text); | ||
} | ||
|
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.
parse
is gonna parse strings with timezones if the string contains+0200
for instance. Isn't this going to cause an issue?