Kontinuation commented on code in PR #14101:
URL: https://github.com/apache/iceberg/pull/14101#discussion_r2609042696


##########
api/src/main/java/org/apache/iceberg/expressions/Literals.java:
##########
@@ -719,4 +722,45 @@ public String toString() {
       return "X'" + BaseEncoding.base16().encode(bytes) + "'";
     }
   }
+
+  static class BoundingBoxLiteral extends BaseLiteral<ByteBuffer> {
+    private static final Comparator<ByteBuffer> CMP =
+        
Comparators.<ByteBuffer>nullsFirst().thenComparing(Comparators.unsignedBytes());
+
+    BoundingBoxLiteral(BoundingBox value) {
+      super(value.toByteBuffer());
+    }
+
+    BoundingBoxLiteral(ByteBuffer value) {
+      super(value);
+    }
+
+    @Override
+    protected Type.TypeID typeId() {
+      return Type.TypeID.GEOMETRY;

Review Comment:
   Yes, this is indeed strange, although this implementation works in this case 
since `typeId()` is only used by 
[`BaseLiteral.toByteBuffer`](https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L119-L129)
 for serializing the value of the literal.
   
   I found 2 ways to fix this weirdness:
   
   1. Making `BoundingBoxLiteral` directly implementing `interface Literal`, 
but not extends from `BaseLiteral`. The `Literal` interface does not have the 
`typeId` method we don't have to come up with a confusing implementation.
   2. Adding geo type to `BoundingBox`. Check that the arguments passed to 
spatial predicates must have the same geo type.
   
   I am working towards approach 2 and see if everything fits perfectly after 
revising the `BoundingBox` definition.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to