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

[Hotfix] fix http source can not read yyyy-MM-dd HH:mm:ss format bug & Improve DateTime Utils #6601

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

EricJoy2048
Copy link
Member

@EricJoy2048 EricJoy2048 commented Mar 28, 2024

Purpose of this pull request

  1. Fix http source will dead cycle when url is error.
  2. Fix http source can not read datetime format yyyy-MM-dd HH:mm:ss.
  3. Fix txt read can not read different column with different datetime format bug.

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

@@ -101,4 +274,66 @@ public static Formatter parse(String format) {
throw new IllegalArgumentException(errorMsg);
}
}

public static void main(String[] args) {
Copy link
Contributor

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

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@TyrantLucifer TyrantLucifer left a 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) {
Copy link
Member

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:
Copy link
Member

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?

Copy link
Member Author

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();

@EricJoy2048
Copy link
Member Author

Please add ut/it for DateTimeUtils and DateUtils

done.

Copy link
Member

@liugddx liugddx left a 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

Copy link
Member

@liugddx liugddx left a 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?

@EricJoy2048
Copy link
Member Author

Do we need to add test cases for the file connector to test time formatting?

I found seatunnel-e2e/seatunnel-connector-v2-e2e/connector-file-local-e2e/src/test/resources/text/local_file_text_lzo_to_assert.conf have the timestamp datatype and date datetype.

@EricJoy2048
Copy link
Member Author

Please maintain the http connector document

This pr has no connector parameters or usage changes and does not require updating the http documentation.

liugddx
liugddx previously approved these changes Apr 8, 2024
Copy link
Member

@liugddx liugddx left a 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);
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

OK

Copy link
Member

@Carl-Zhou-CN Carl-Zhou-CN left a comment

Choose a reason for hiding this comment

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

LGTM

@liugddx liugddx merged commit 19888e7 into apache:dev Apr 9, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants