Skip to content

Commit e88268d

Browse files
committed
add test to TestTypeBuilders
1 parent d8ffe0e commit e88268d

1 file changed

Lines changed: 101 additions & 1 deletion

File tree

parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import java.util.ArrayList;
5656
import java.util.List;
5757
import java.util.concurrent.Callable;
58+
import org.apache.parquet.format.EdgeInterpolationAlgorithm;
5859
import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName;
5960
import org.apache.parquet.schema.Type.Repetition;
6061
import org.junit.Assert;
@@ -1101,7 +1102,7 @@ public void testMapWithPreBuiltKeyAndValueTypes() {
11011102

11021103
GroupType map = new GroupType(
11031104
REQUIRED, "myMap", OriginalType.MAP, new GroupType(REPEATED, "key_value", new Type[] {keyType, valueType
1104-
}));
1105+
}));
11051106
MessageType expected = new MessageType("mapParent", map);
11061107

11071108
GroupType actual = Types.buildMessage()
@@ -1477,6 +1478,105 @@ public void testDecimalLogicalTypeWithDeprecatedPrecisionMismatch() {
14771478
.named("aDecimal");
14781479
}
14791480

1481+
@Test
1482+
public void testGeometryLogicalType() {
1483+
// Test with default CRS
1484+
PrimitiveType defaultCrsExpected = new PrimitiveType(
1485+
REQUIRED, BINARY, "aGeometry", LogicalTypeAnnotation.geometryType("OGC:CRS84"));
1486+
PrimitiveType defaultCrsActual = Types.required(BINARY)
1487+
.as(LogicalTypeAnnotation.geometryType("OGC:CRS84"))
1488+
.named("aGeometry");
1489+
Assert.assertEquals(defaultCrsExpected, defaultCrsActual);
1490+
1491+
// Test with custom CRS
1492+
PrimitiveType customCrsExpected = new PrimitiveType(
1493+
REQUIRED, BINARY, "aGeometry", LogicalTypeAnnotation.geometryType("EPSG:4326"));
1494+
PrimitiveType customCrsActual = Types.required(BINARY)
1495+
.as(LogicalTypeAnnotation.geometryType("EPSG:4326"))
1496+
.named("aGeometry");
1497+
Assert.assertEquals(customCrsExpected, customCrsActual);
1498+
1499+
// Test with optional repetition
1500+
PrimitiveType optionalGeometryExpected = new PrimitiveType(
1501+
OPTIONAL, BINARY, "aGeometry", LogicalTypeAnnotation.geometryType("OGC:CRS84"));
1502+
PrimitiveType optionalGeometryActual = Types.optional(BINARY)
1503+
.as(LogicalTypeAnnotation.geometryType("OGC:CRS84"))
1504+
.named("aGeometry");
1505+
Assert.assertEquals(optionalGeometryExpected, optionalGeometryActual);
1506+
}
1507+
1508+
@Test
1509+
public void testGeographyLogicalType() {
1510+
// Test with default CRS and no edge algorithm
1511+
PrimitiveType defaultCrsExpected = new PrimitiveType(
1512+
REQUIRED, BINARY, "aGeography", LogicalTypeAnnotation.geographyType("OGC:CRS84", null));
1513+
PrimitiveType defaultCrsActual = Types.required(BINARY)
1514+
.as(LogicalTypeAnnotation.geographyType("OGC:CRS84", null))
1515+
.named("aGeography");
1516+
Assert.assertEquals(defaultCrsExpected, defaultCrsActual);
1517+
1518+
// Test with custom CRS and no edge algorithm
1519+
PrimitiveType customCrsExpected = new PrimitiveType(
1520+
REQUIRED, BINARY, "aGeography", LogicalTypeAnnotation.geographyType("EPSG:4326", null));
1521+
PrimitiveType customCrsActual = Types.required(BINARY)
1522+
.as(LogicalTypeAnnotation.geographyType("EPSG:4326", null))
1523+
.named("aGeography");
1524+
Assert.assertEquals(customCrsExpected, customCrsActual);
1525+
1526+
// Test with custom CRS and edge algorithm
1527+
EdgeInterpolationAlgorithm greatCircle = EdgeInterpolationAlgorithm.SPHERICAL;
1528+
PrimitiveType customCrsWithEdgeAlgorithmExpected = new PrimitiveType(
1529+
REQUIRED, BINARY, "aGeography", LogicalTypeAnnotation.geographyType("EPSG:4326", null));
1530+
PrimitiveType customCrsWithEdgeAlgorithmActual = Types.required(BINARY)
1531+
.as(LogicalTypeAnnotation.geographyType("EPSG:4326", null))
1532+
.named("aGeography");
1533+
Assert.assertEquals(customCrsWithEdgeAlgorithmExpected, customCrsWithEdgeAlgorithmActual);
1534+
1535+
// Test with optional repetition
1536+
PrimitiveType optionalGeographyExpected = new PrimitiveType(
1537+
OPTIONAL, BINARY, "aGeography", LogicalTypeAnnotation.geographyType("OGC:CRS84", null));
1538+
PrimitiveType optionalGeographyActual = Types.optional(BINARY)
1539+
.as(LogicalTypeAnnotation.geographyType("OGC:CRS84", null))
1540+
.named("aGeography");
1541+
Assert.assertEquals(optionalGeographyExpected, optionalGeographyActual);
1542+
}
1543+
1544+
@Test
1545+
public void testGeographyLogicalTypeWithoutEdgeInterpolationAlgorithm() {
1546+
// Test with default CRS and no edge algorithm
1547+
PrimitiveType defaultCrsExpected = new PrimitiveType(
1548+
REQUIRED, BINARY, "aGeography", LogicalTypeAnnotation.geographyType());
1549+
PrimitiveType defaultCrsActual = Types.required(BINARY)
1550+
.as(LogicalTypeAnnotation.geographyType())
1551+
.named("aGeography");
1552+
Assert.assertEquals(defaultCrsExpected, defaultCrsActual);
1553+
1554+
// Test with custom CRS and no edge algorithm
1555+
PrimitiveType customCrsExpected = new PrimitiveType(
1556+
REQUIRED, BINARY, "aGeography", LogicalTypeAnnotation.geographyType("EPSG:4326", null));
1557+
PrimitiveType customCrsActual = Types.required(BINARY)
1558+
.as(LogicalTypeAnnotation.geographyType("EPSG:4326", null))
1559+
.named("aGeography");
1560+
Assert.assertEquals(customCrsExpected, customCrsActual);
1561+
1562+
// Test with custom CRS and edge algorithm
1563+
PrimitiveType customCrsWithEdgeAlgorithmExpected = new PrimitiveType(
1564+
REQUIRED, BINARY, "aGeography",
1565+
LogicalTypeAnnotation.geographyType("EPSG:4326", null));
1566+
PrimitiveType customCrsWithEdgeAlgorithmActual = Types.required(BINARY)
1567+
.as(LogicalTypeAnnotation.geographyType("EPSG:4326", null))
1568+
.named("aGeography");
1569+
Assert.assertEquals(customCrsWithEdgeAlgorithmExpected, customCrsWithEdgeAlgorithmActual);
1570+
1571+
// Test with optional repetition
1572+
PrimitiveType optionalGeographyExpected = new PrimitiveType(
1573+
OPTIONAL, BINARY, "aGeography", LogicalTypeAnnotation.geographyType());
1574+
PrimitiveType optionalGeographyActual = Types.optional(BINARY)
1575+
.as(LogicalTypeAnnotation.geographyType())
1576+
.named("aGeography");
1577+
Assert.assertEquals(optionalGeographyExpected, optionalGeographyActual);
1578+
}
1579+
14801580
/**
14811581
* A convenience method to avoid a large number of @Test(expected=...) tests
14821582
*

0 commit comments

Comments
 (0)