From b45e3c01217af503735a735dabfc21c9b1e95126 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Mon, 2 Dec 2024 08:36:54 +0900 Subject: [PATCH] [MINOR] Use putAll to populate Properties ### What changes were proposed in this pull request? This PR uses the `putAll` method of `Properties` class in place of `put`. ### Why are the changes needed? In Scala 2.13, https://github.com/scala/bug/issues/10418 has been fixed. So we can avoid the workaround. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? There is no change in functionality. Existing tests suffice. ### Was this patch authored or co-authored using generative AI tooling? No Closes #48993 from tedyu/put-all. Authored-by: Zhihong Yu Signed-off-by: Hyukjin Kwon --- .../org/apache/spark/sql/kafka010/KafkaTestUtils.scala | 4 +--- .../sql/hive/execution/HiveScriptTransformationExec.scala | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala b/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala index 9e06b6c6ff4a2..60de3705636ec 100644 --- a/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala +++ b/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala @@ -504,9 +504,7 @@ class KafkaTestUtils( props.put("sasl.enabled.mechanisms", "GSSAPI,SCRAM-SHA-512") } - // Can not use properties.putAll(propsMap.asJava) in scala-2.12 - // See https://github.com/scala/bug/issues/10418 - withBrokerProps.foreach { case (k, v) => props.put(k, v) } + props.putAll(withBrokerProps.asJava) props } diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala index 0fcc43e5c3919..de2d15415837a 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala @@ -283,9 +283,7 @@ object HiveScriptIOSchema extends HiveInspectors { propsMap = propsMap + (serdeConstants.LIST_COLUMN_TYPES -> columnTypesNames) val properties = new Properties() - // Can not use properties.putAll(propsMap.asJava) in scala-2.12 - // See https://github.com/scala/bug/issues/10418 - propsMap.foreach { case (k, v) => properties.put(k, v) } + properties.putAll(propsMap.asJava) serde.initialize(null, properties) serde @@ -299,9 +297,7 @@ object HiveScriptIOSchema extends HiveInspectors { val instance = Utils.classForName[RecordReader](klass).getConstructor(). newInstance() val props = new Properties() - // Can not use props.putAll(outputSerdeProps.toMap.asJava) in scala-2.12 - // See https://github.com/scala/bug/issues/10418 - ioschema.outputSerdeProps.toMap.foreach { case (k, v) => props.put(k, v) } + props.putAll(ioschema.outputSerdeProps.toMap.asJava) instance.initialize(inputStream, conf, props) instance }