Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private static String convertField(final Type parquetType, boolean supportTimest
.append(decimalMetadata.getScale()).append(")").toString();
} else if (originalType == OriginalType.DATE) {
return field.append("DATE").toString();
} else if (supportTimestamp && originalType == OriginalType.TIMESTAMP_MICROS) {
} else if (supportTimestamp && (originalType == OriginalType.TIMESTAMP_MICROS || originalType == OriginalType.TIMESTAMP_MILLIS)) {
return field.append("TIMESTAMP").toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.parquet.schema.PrimitiveType;
import org.apache.parquet.schema.Types;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -113,10 +115,11 @@ public void testSchemaConvertArray() throws IOException {
assertEquals("`map_list` ARRAY< MAP< string, int>>", schemaString);
}

@Test
public void testSchemaConvertTimestampMicros() throws IOException {
@ParameterizedTest
@ValueSource(strings = {"TIMESTAMP_MICROS", "TIMESTAMP_MILLIS"})
public void testSchemaConvertTimestamp(String type) throws IOException {
MessageType schema = Types.buildMessage().optional(PrimitiveType.PrimitiveTypeName.INT64)
.as(OriginalType.TIMESTAMP_MICROS).named("my_element").named("my_timestamp");
.as(OriginalType.valueOf(type)).named("my_element").named("my_timestamp");
String schemaString = HiveSchemaUtil.generateSchemaString(schema);
// verify backward compatibility - int64 converted to bigint type
assertEquals("`my_element` bigint", schemaString);
Expand All @@ -125,10 +128,11 @@ public void testSchemaConvertTimestampMicros() throws IOException {
assertEquals("`my_element` TIMESTAMP", schemaString);
}

@Test
public void testSchemaDiffForTimestampMicros() {
@ParameterizedTest
@ValueSource(strings = {"TIMESTAMP_MICROS", "TIMESTAMP_MILLIS"})
public void testSchemaDiffForTimestamp(String type) {
MessageType schema = Types.buildMessage().optional(PrimitiveType.PrimitiveTypeName.INT64)
.as(OriginalType.TIMESTAMP_MICROS).named("my_element").named("my_timestamp");
.as(OriginalType.valueOf(type)).named("my_element").named("my_timestamp");
// verify backward compatibility - int64 converted to bigint type
SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDifference(schema,
Collections.emptyMap(), Collections.emptyList(), false);
Expand Down