Skip to content

Commit b2b8273

Browse files
author
zhangxiaotian13
committed
fix comments, update the assertions
1 parent 9ed6de3 commit b2b8273

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.apache.iceberg.spark;
2121

22-
import java.nio.ByteBuffer;
2322
import java.util.Arrays;
2423
import java.util.Collections;
2524
import java.util.List;
@@ -597,9 +596,6 @@ private static <T> String sqlString(List<org.apache.iceberg.expressions.Literal<
597596
private static String sqlString(org.apache.iceberg.expressions.Literal<?> lit) {
598597
if (lit.value() instanceof String) {
599598
return "'" + lit.value() + "'";
600-
} else if (lit.value() instanceof ByteBuffer) {
601-
// produce a literal value that Spark can parse
602-
return lit.toString();
603599
} else {
604600
return lit.value().toString();
605601
}

spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/SparkTestBase.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.apache.iceberg.spark;
2121

22-
import java.lang.reflect.Array;
2322
import java.util.List;
2423
import java.util.Map;
2524
import java.util.stream.Collectors;
@@ -119,8 +118,6 @@ private Object[] toJava(Row row) {
119118
return row.getList(pos);
120119
} else if (value instanceof scala.collection.Map) {
121120
return row.getJavaMap(pos);
122-
} else if (value instanceof byte[]) {
123-
return IntStream.range(0, Array.getLength(value)).mapToObj(i -> Array.get(value, i)).toArray();
124121
} else {
125122
return value;
126123
}
@@ -160,7 +157,11 @@ private void assertEquals(String context, Object[] expectedRow, Object[] actualR
160157
Object actualValue = actualRow[col];
161158
if (expectedValue != null && expectedValue.getClass().isArray()) {
162159
String newContext = String.format("%s (nested col %d)", context, col + 1);
163-
assertEquals(newContext, (Object[]) expectedValue, (Object[]) actualValue);
160+
if (expectedValue instanceof byte[]) {
161+
Assert.assertArrayEquals(newContext, (byte[]) expectedValue, (byte[]) actualValue);
162+
} else {
163+
assertEquals(newContext, (Object[]) expectedValue, (Object[]) actualValue);
164+
}
164165
} else if (expectedValue != ANY) {
165166
Assert.assertEquals(context + " contents should match", expectedValue, actualValue);
166167
}

spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestSelect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void testSpecifySnapshotAndTimestamp() {
210210
public void testBinaryInFilter() {
211211
sql("CREATE TABLE %s (id bigint, binary binary) USING iceberg", binaryTableName);
212212
sql("INSERT INTO %s VALUES (1, X''), (2, X'1111'), (3, X'11')", binaryTableName);
213-
List<Object[]> expected = ImmutableList.of(row(2L, new Byte[]{0x11, 0x11}));
213+
List<Object[]> expected = ImmutableList.of(row(2L, new byte[]{0x11, 0x11}));
214214

215215
assertEquals("Should return all expected rows", expected,
216216
sql("SELECT id, binary FROM %s where binary > X'11'", binaryTableName));

0 commit comments

Comments
 (0)