|
55 | 55 | import java.util.ArrayList; |
56 | 56 | import java.util.List; |
57 | 57 | import java.util.concurrent.Callable; |
| 58 | +import org.apache.parquet.format.EdgeInterpolationAlgorithm; |
58 | 59 | import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName; |
59 | 60 | import org.apache.parquet.schema.Type.Repetition; |
60 | 61 | import org.junit.Assert; |
@@ -1101,7 +1102,7 @@ public void testMapWithPreBuiltKeyAndValueTypes() { |
1101 | 1102 |
|
1102 | 1103 | GroupType map = new GroupType( |
1103 | 1104 | REQUIRED, "myMap", OriginalType.MAP, new GroupType(REPEATED, "key_value", new Type[] {keyType, valueType |
1104 | | - })); |
| 1105 | + })); |
1105 | 1106 | MessageType expected = new MessageType("mapParent", map); |
1106 | 1107 |
|
1107 | 1108 | GroupType actual = Types.buildMessage() |
@@ -1477,6 +1478,105 @@ public void testDecimalLogicalTypeWithDeprecatedPrecisionMismatch() { |
1477 | 1478 | .named("aDecimal"); |
1478 | 1479 | } |
1479 | 1480 |
|
| 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 | + |
1480 | 1580 | /** |
1481 | 1581 | * A convenience method to avoid a large number of @Test(expected=...) tests |
1482 | 1582 | * |
|
0 commit comments