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

[fix](Nereids) fix str_to_date datetimev2 literal showing problem #44018

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public String getStringValue() {
int scale = ((ScalarType) type).getScalarScale();
long scaledMicroseconds = (long) (microsecond / SCALE_FACTORS[scale]);

if (scaledMicroseconds != 0) {
if (scale > 0) {
dateTimeChars[19] = '.';
fillPaddedValue(dateTimeChars, 20, (int) scaledMicroseconds, scale);
return new String(dateTimeChars, 0, 20 + scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ public void testDateFormatForDatetimeV2() {
Assert.assertEquals(2022, literal.getYear());
Assert.assertEquals(6, literal.getMonth());
Assert.assertEquals(1, literal.getDay());

literal = new DateLiteral("2022-6-01 00:00:00.000000", ScalarType.createDatetimeV2Type(6));
Assert.assertTrue(literal.toSql().contains(".000000"));
} catch (AnalysisException e) {
e.printStackTrace();
hasException = true;
Expand Down
Loading