-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Hotfix] fix http source can not read yyyy-MM-dd HH:mm:ss format bug & Improve DateTime Utils #6601
Conversation
b2c39bb
to
3f44f9c
Compare
@@ -101,4 +274,66 @@ public static Formatter parse(String format) { | |||
throw new IllegalArgumentException(errorMsg); | |||
} | |||
} | |||
|
|||
public static void main(String[] args) { |
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 can move to UT
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.
+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.
Sorry, I will do it.
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.
done
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.
Please add ut/it for DateTimeUtils and DateUtils
@@ -101,4 +274,66 @@ public static Formatter parse(String format) { | |||
throw new IllegalArgumentException(errorMsg); | |||
} | |||
} | |||
|
|||
public static void main(String[] args) { |
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.
+1
case TIME: | ||
return TimeUtils.parse(field, timeFormatter); | ||
TemporalAccessor parsedTime = TIME_FORMAT.parse(field); | ||
return parsedTime.query(TemporalQueries.localTime()); | ||
case TIMESTAMP: |
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.
Why change this logic? What are the benefits?
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.
Why change this logic? What are the benefits?
TimeUtils.parse(field, timeFormatter)
have the best performance, but only can parse HH:mm:ss
format.
I replace it with a format can parse HH:mm:ss
between HH:mm:ss.SSSSSSSSS
, support 0
to 9
length nano of second.
public static final DateTimeFormatter TIME_FORMAT =
new DateTimeFormatterBuilder()
.appendPattern("HH:mm:ss")
.appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
.toFormatter();
c44202c
to
2a97ec0
Compare
done. |
336ba78
to
4046531
Compare
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.
Please maintain the http connector document
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.
Do we need to add test cases for the file connector to test time formatting?
I found |
This pr has no connector parameters or usage changes and does not require updating the http documentation. |
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.
LGTM
.dateFormatter(dateFormat) | ||
.dateTimeFormatter(datetimeFormat) | ||
.timeFormatter(timeFormat); | ||
TextDeserializationSchema.builder().delimiter(fieldDelimiter); |
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.
@EricJoy2048 This seems to prevent users from customizing the data format
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.
@EricJoy2048 This seems to prevent users from customizing the data format
For reading the contents of the file, the format of the custom read is meaningless, because if the user-defined format is not consistent with the date and time format in the file, it will fail to read, so the format must be consistent with the content format in the file under the reading scenario.
For scenarios where a date or time is written to a file, a user-defined format makes sense.So, I am not change the TextWriteStrategy
code.
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.
OK
4046531
to
979c175
Compare
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.
LGTM
…& Improve DateTime Utils (apache#6601)
Purpose of this pull request
yyyy-MM-dd HH:mm:ss
.Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
release-note
.