Skip to content
Closed
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 @@ -215,11 +215,24 @@ public Void visit(TimeType timeType) {

@Override
public Void visit(TimestampType timestampType) {
// Precision 0 maps to the Arrow SECOND time unit, which the native
// mosaic writer cannot open a file with.
if (timestampType.getPrecision() == 0) {
throw new UnsupportedOperationException(
"Mosaic file format does not support type TIMESTAMP(0), "
+ "use TIMESTAMP(3) instead");
}
return null;
}

@Override
public Void visit(LocalZonedTimestampType localZonedTimestampType) {
if (localZonedTimestampType.getPrecision() == 0) {
throw new UnsupportedOperationException(
"Mosaic file format does not support type "
+ "TIMESTAMP(0) WITH LOCAL TIME ZONE, "
+ "use TIMESTAMP(3) WITH LOCAL TIME ZONE instead");
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -98,6 +99,47 @@ void testValidateDataFieldsMapSupported() {
format.validateDataFields(rowType);
}

@Test
void testValidateDataFieldsTimestampPrecisionZeroUnsupported() {
MosaicFileFormat format = createFormat();
for (RowType rowType :
Arrays.asList(
DataTypes.ROW(DataTypes.TIMESTAMP(0)),
DataTypes.ROW(DataTypes.ARRAY(DataTypes.TIMESTAMP(0))))) {
assertThatThrownBy(() -> format.validateDataFields(rowType))
.isInstanceOf(UnsupportedOperationException.class)
.hasMessage(
"Mosaic file format does not support type TIMESTAMP(0), "
+ "use TIMESTAMP(3) instead");
}
for (RowType rowType :
Arrays.asList(
DataTypes.ROW(DataTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE(0)),
DataTypes.ROW(
DataTypes.MAP(
DataTypes.STRING(),
DataTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE(0))))) {
assertThatThrownBy(() -> format.validateDataFields(rowType))
.isInstanceOf(UnsupportedOperationException.class)
.hasMessage(
"Mosaic file format does not support type "
+ "TIMESTAMP(0) WITH LOCAL TIME ZONE, "
+ "use TIMESTAMP(3) WITH LOCAL TIME ZONE instead");
}
}

@Test
void testValidateDataFieldsTimestampPositivePrecisionSupported() {
MosaicFileFormat format = createFormat();
RowType rowType =
DataTypes.ROW(
DataTypes.TIMESTAMP(1),
DataTypes.TIMESTAMP(9),
DataTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE(1),
DataTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE(9));
format.validateDataFields(rowType);
}

@Test
void testValidateDataFieldsMultisetUnsupported() {
MosaicFileFormat format = createFormat();
Expand Down
Loading