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

[HUDI-4464] Clear warnings in Azure CI #6210

Merged
merged 4 commits into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 13 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ stages:
displayName: UT FT common & flink & UT client/spark-client
timeoutInMinutes: '150'
steps:
- task: Maven@3
- task: Maven@3.205.1
xushiyan marked this conversation as resolved.
Show resolved Hide resolved
displayName: maven install
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean install'
options: $(MVN_OPTS_INSTALL)
publishJUnitResults: false
jdkVersionOption: '1.8'
- task: Maven@3
- task: Maven@3.205.1
displayName: UT common flink client/spark-client
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -108,7 +108,7 @@ stages:
publishJUnitResults: false
jdkVersionOption: '1.8'
mavenOptions: '-Xmx4g'
- task: Maven@3
- task: Maven@3.205.1
displayName: FT common flink
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -121,15 +121,15 @@ stages:
displayName: FT client/spark-client
timeoutInMinutes: '150'
steps:
- task: Maven@3
- task: Maven@3.205.1
displayName: maven install
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean install'
options: $(MVN_OPTS_INSTALL)
publishJUnitResults: false
jdkVersionOption: '1.8'
- task: Maven@3
- task: Maven@3.205.1
displayName: FT client/spark-client
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -142,15 +142,15 @@ stages:
displayName: UT FT clients & cli & utilities & sync
timeoutInMinutes: '150'
steps:
- task: Maven@3
- task: Maven@3.205.1
displayName: maven install
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean install'
options: $(MVN_OPTS_INSTALL)
publishJUnitResults: false
jdkVersionOption: '1.8'
- task: Maven@3
- task: Maven@3.205.1
displayName: UT clients & cli & utilities & sync
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -159,7 +159,7 @@ stages:
publishJUnitResults: false
jdkVersionOption: '1.8'
mavenOptions: '-Xmx4g'
- task: Maven@3
- task: Maven@3.205.1
displayName: FT clients & cli & utilities & sync
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -172,15 +172,15 @@ stages:
displayName: UT FT other modules
timeoutInMinutes: '150'
steps:
- task: Maven@3
- task: Maven@3.205.1
displayName: maven install
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean install'
options: $(MVN_OPTS_INSTALL)
publishJUnitResults: false
jdkVersionOption: '1.8'
- task: Maven@3
- task: Maven@3.205.1
displayName: UT other modules
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -189,7 +189,7 @@ stages:
publishJUnitResults: false
jdkVersionOption: '1.8'
mavenOptions: '-Xmx4g'
- task: Maven@3
- task: Maven@3.205.1
displayName: FT other modules
inputs:
mavenPomFile: 'pom.xml'
Expand All @@ -202,15 +202,15 @@ stages:
displayName: IT modules
timeoutInMinutes: '150'
steps:
- task: Maven@3
- task: Maven@3.205.1
displayName: maven install
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean install'
options: $(MVN_OPTS_INSTALL) -Pintegration-tests
publishJUnitResults: false
jdkVersionOption: '1.8'
- task: Maven@3
- task: Maven@3.205.1
displayName: UT integ-test
inputs:
mavenPomFile: 'pom.xml'
Expand Down
35 changes: 22 additions & 13 deletions hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -957,21 +959,28 @@ private static Object rewritePrimaryTypeWithDiffSchemaType(Object oldValue, Sche
throw new AvroRuntimeException(String.format("cannot support rewrite value for schema type: %s since the old schema type is: %s", newSchema, oldSchema));
}

// convert days to Date
private static java.sql.Date toJavaDate(int days) {
long localMillis = Math.multiplyExact(days, MILLIS_PER_DAY);
int timeZoneOffset;
TimeZone defaultTimeZone = TimeZone.getDefault();
if (defaultTimeZone instanceof sun.util.calendar.ZoneInfo) {
timeZoneOffset = ((sun.util.calendar.ZoneInfo) defaultTimeZone).getOffsetsByWall(localMillis, null);
} else {
timeZoneOffset = defaultTimeZone.getOffset(localMillis - defaultTimeZone.getRawOffset());
}
return new java.sql.Date(localMillis - timeZoneOffset);
/**
* convert days to Date
*
* NOTE: This method could only be used in tests
*
* @VisibleForTesting
*/
public static java.sql.Date toJavaDate(int days) {
LocalDate date = LocalDate.ofEpochDay(days);
ZoneId defaultZoneId = ZoneId.systemDefault();
ZonedDateTime zonedDateTime = date.atStartOfDay(defaultZoneId);
return new java.sql.Date(zonedDateTime.toInstant().toEpochMilli());
}

// convert Date to days
private static int fromJavaDate(Date date) {
/**
* convert Date to days
*
* NOTE: This method could only be used in tests
*
* @VisibleForTesting
*/
public static int fromJavaDate(Date date) {
long millisUtc = date.getTime();
long millisLocal = millisUtc + TimeZone.getDefault().getOffset(millisUtc);
int julianDays = Math.toIntExact(Math.floorDiv(millisLocal, MILLIS_PER_DAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -372,4 +373,11 @@ public void testReWriteAvroRecordWithNewSchema() {
GenericRecord studentRecordRename = HoodieAvroUtils.rewriteRecordWithNewSchema(rec3, nestedSchemaRename, colRenames);
Assertions.assertEquals(GenericData.get().validate(nestedSchemaRename, studentRecordRename), true);
}

@Test
public void testConvertDaysToDate() {
Date now = new Date(System.currentTimeMillis());
int days = HoodieAvroUtils.fromJavaDate(now);
assertEquals(now.toLocalDate(), HoodieAvroUtils.toJavaDate(days).toLocalDate());
}
}