amogh-jahagirdar commented on code in PR #12925:
URL: https://github.com/apache/iceberg/pull/12925#discussion_r2064377681
##########
data/src/test/java/org/apache/iceberg/data/RandomGenericData.java:
##########
@@ -155,11 +175,19 @@ protected Object randomValue(Type.PrimitiveType
primitive, Random rand) {
public abstract static class RandomDataGenerator<T>
extends TypeUtil.CustomOrderSchemaVisitor<Object> {
- private final Random random;
private static final int MAX_ENTRIES = 20;
+ private static final float DEFAULT_NULL_PERCENTAGE = 0.05f;
+
+ private final Random random;
+ private final float nullPercentage;
protected RandomDataGenerator(long seed) {
+ this(seed, DEFAULT_NULL_PERCENTAGE);
+ }
+
+ protected RandomDataGenerator(long seed, float nullPercentage) {
this.random = new Random(seed);
+ this.nullPercentage = nullPercentage;
Review Comment:
Precondition that it's a valid float percentage
##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/data/GenericsHelpers.java:
##########
@@ -289,11 +317,27 @@ private static void assertEqualsUnsafe(Type type, Object
expected, Object actual
}
switch (type.typeId()) {
+ case LONG:
+ assertThat(actual).as("Should be a long").isInstanceOf(Long.class);
+ if (expected instanceof Integer) {
+ assertThat(actual).as("Values didn't match").isEqualTo(((Number)
expected).longValue());
+ } else {
+ assertThat(actual).as("Primitive value should be equal to
expected").isEqualTo(expected);
+ }
+ break;
+ case DOUBLE:
+ assertThat(actual).as("Should be a double").isInstanceOf(Double.class);
+ if (expected instanceof Float) {
+ assertThat(Double.doubleToLongBits((double) actual))
+ .as("Values didn't match")
+ .isEqualTo(Double.doubleToLongBits(((Number)
expected).doubleValue()));
+ } else {
+ assertThat(actual).as("Primitive value should be equal to
expected").isEqualTo(expected);
+ }
+ break;
Review Comment:
This is needed because of the int to long, float to double type promotion
tests. This is the same as what exists in TestHelpers#assertEqualsUnsafe
--
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]