Skip to content

Commit 63ea117

Browse files
committed
fix: Throws an exception when struct type has duplicate keys
1 parent 5560450 commit 63ea117

File tree

1 file changed

+7
-1
lines changed
  • common/src/main/scala/org/apache/spark/sql/comet/util

1 file changed

+7
-1
lines changed

common/src/main/scala/org/apache/spark/sql/comet/util/Utils.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ object Utils extends CometTypeShim {
154154
name,
155155
fieldType,
156156
Seq(toArrowField("element", elementType, containsNull, timeZoneId)).asJava)
157-
case StructType(fields) =>
157+
case st @ StructType(fields) =>
158+
if (st.names.toSet.size != fields.length) {
159+
throw new SparkException(
160+
"Duplicated field names in Arrow Struct are not allowed," +
161+
s" got ${st.names.mkString("[", ", ", "]")}.")
162+
}
163+
158164
val fieldType = new FieldType(nullable, ArrowType.Struct.INSTANCE, null)
159165
new Field(
160166
name,

0 commit comments

Comments
 (0)