bodduv commented on code in PR #14500:
URL: https://github.com/apache/iceberg/pull/14500#discussion_r2533276404
##########
api/src/test/java/org/apache/iceberg/expressions/TestInclusiveMetricsEvaluator.java:
##########
@@ -970,4 +988,191 @@ public void testNotNullInNestedStruct() {
.as("Should not read: optional_address.optional_street2 is optional")
.isFalse();
}
+
+ @Test
+ public void testUuidEq() {
+ UUID belowMin = UUID.fromString("00000000-0000-0000-0000-000000000000");
+ boolean shouldRead = new InclusiveMetricsEvaluator(SCHEMA, equal("uuid",
belowMin)).eval(FILE);
+ assertThat(shouldRead).as("Should not read: uuid below lower
bound").isFalse();
+
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, equal("uuid",
UUID_MIN_VALUE)).eval(FILE);
+ assertThat(shouldRead).as("Should read: uuid equal to lower
bound").isTrue();
+
+ UUID between = UUID.fromString("7fffffff-ffff-ffff-7fff-ffffffffffff");
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, equal("uuid",
between)).eval(FILE);
+ assertThat(shouldRead).as("Should read: uuid between lower and upper
bounds").isTrue();
+
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, equal("uuid",
UUID_MAX_VALUE)).eval(FILE);
+ assertThat(shouldRead).as("Should read: uuid equal to upper
bound").isTrue();
+
+ UUID aboveMax = UUID.fromString("ffffffff-ffff-ffff-ffff-ffffffffffff");
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, equal("uuid",
aboveMax)).eval(FILE);
+ assertThat(shouldRead).as("Should not read: uuid above upper
bound").isFalse();
+ }
+
+ @Test
+ public void testUuidLt() {
+ UUID belowMin = UUID.fromString("00000000-0000-0000-0000-000000000000");
+ boolean shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, lessThan("uuid",
belowMin)).eval(FILE);
+ assertThat(shouldRead).as("Should not read: uuid range below lower
bound").isFalse();
+
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, lessThan("uuid",
UUID_MIN_VALUE)).eval(FILE);
+ assertThat(shouldRead)
+ .as("Should not read: uuid range below lower bound (UUID_MIN is not <
UUID_MIN)")
+ .isFalse();
+
+ UUID justAboveMin =
UUID.fromString("00000000-0000-0001-0000-000000000000");
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, lessThan("uuid",
justAboveMin)).eval(FILE);
+ assertThat(shouldRead).as("Should read: one possible uuid").isTrue();
+
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, lessThan("uuid",
UUID_MAX_VALUE)).eval(FILE);
+ assertThat(shouldRead).as("Should read: uuid between lower and upper
bounds").isTrue();
+
+ UUID aboveMax = UUID.fromString("ffffffff-ffff-ffff-ffff-ffffffffffff");
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, lessThan("uuid",
aboveMax)).eval(FILE);
+ assertThat(shouldRead).as("Should read: all uuids in range").isTrue();
+ }
+
+ @Test
+ public void testUuidLtEq() {
+ UUID belowMin = UUID.fromString("00000000-0000-0000-0000-000000000000");
+ boolean shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, lessThanOrEqual("uuid",
belowMin)).eval(FILE);
+ assertThat(shouldRead).as("Should not read: uuid range below lower
bound").isFalse();
+
+ shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, lessThanOrEqual("uuid",
UUID_MIN_VALUE)).eval(FILE);
+ assertThat(shouldRead).as("Should read: one possible uuid").isTrue();
+
+ shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, lessThanOrEqual("uuid",
UUID_MAX_VALUE)).eval(FILE);
+ assertThat(shouldRead).as("Should read: all uuids in range").isTrue();
+
+ UUID aboveMax = UUID.fromString("ffffffff-ffff-ffff-ffff-ffffffffffff");
+ shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, lessThanOrEqual("uuid",
aboveMax)).eval(FILE);
+ assertThat(shouldRead).as("Should read: all uuids in range").isTrue();
+ }
+
+ @Test
+ public void testUuidGt() {
+ UUID belowMin = UUID.fromString("00000000-0000-0000-0000-000000000000");
+ boolean shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, greaterThan("uuid",
belowMin)).eval(FILE);
+ assertThat(shouldRead).as("Should read: all uuids in range").isTrue();
+
+ shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, greaterThan("uuid",
UUID_MIN_VALUE)).eval(FILE);
+ assertThat(shouldRead).as("Should read: uuid between lower and upper
bounds").isTrue();
+
+ UUID justBelowMax =
UUID.fromString("ffffffff-ffff-fffe-ffff-ffffffffffff");
+ shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, greaterThan("uuid",
justBelowMax)).eval(FILE);
+ assertThat(shouldRead).as("Should read: one possible uuid").isTrue();
+
+ shouldRead =
+ new InclusiveMetricsEvaluator(SCHEMA, greaterThan("uuid",
UUID_MAX_VALUE)).eval(FILE);
+ assertThat(shouldRead)
+ .as("Should not read: uuid range above upper bound (UUID_MAX is not >
UUID_MAX)")
+ .isFalse();
+
+ UUID aboveMax = UUID.fromString("ffffffff-ffff-ffff-ffff-ffffffffffff");
+ shouldRead = new InclusiveMetricsEvaluator(SCHEMA, greaterThan("uuid",
aboveMax)).eval(FILE);
+ assertThat(shouldRead).as("Should not read: uuid range above upper
bound").isFalse();
+ }
+
+ /**
+ * Tests UUID greater-than-or-equal filter using byte-order comparison
against data file metrics.
Review Comment:
removed it
--
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]