Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-32756][SQL] Fix CaseInsensitiveMap usage for Scala 2.13 #29584

Closed
wants to merge 4 commits into from

Conversation

karolchmist
Copy link
Contributor

What changes were proposed in this pull request?

This is a follow-up of #29160. This allows Spark SQL project to compile for Scala 2.13.

Why are the changes needed?

It's needed for #28545

Does this PR introduce any user-facing change?

No

How was this patch tested?

I compiled with Scala 2.13. It fails in Spark REPL project, which will be fixed by #28545

@maropu
Copy link
Member

maropu commented Aug 30, 2020

ok to test

@maropu
Copy link
Member

maropu commented Aug 30, 2020

How about filing a new jira ticket as a sub-ticket of https://issues.apache.org/jira/browse/SPARK-25075 ?

@SparkQA
Copy link

SparkQA commented Aug 30, 2020

Test build #128046 has finished for PR 29584 at commit 02e9e2b.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution, @karolchmist .
Please use a different JIRA issue for Scala 2.13. For now, we are trying our best, but we don't know we can achieve Scala 2.13 in Apache Spark 3.1. It depends on the Scala community's next release.

@dongjoon-hyun
Copy link
Member

+1 for @maropu 's advice.

How about filing a new jira ticket as a sub-ticket of https://issues.apache.org/jira/browse/SPARK-25075 ?

@maropu
Copy link
Member

maropu commented Aug 30, 2020

Ah, one more comment; please fill the PR description about what kind of compilers errors happens. I think that the information is useful to developers when writing code with scala v2.13. Anyway, thanks for the work, @karolchmist.

@@ -42,7 +42,10 @@ class CaseInsensitiveMap[T] private (val originalMap: Map[String, T]) extends Ma
override def +[B1 >: T](kv: (String, B1)): CaseInsensitiveMap[B1] = {
new CaseInsensitiveMap(originalMap.filter(!_._1.equalsIgnoreCase(kv._1)) + kv)
}


override def updated[B1 >: T](key: String, value: B1): CaseInsensitiveMap[B1] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we have two copy of this for Scala 2.13 compatibility. Are you sure this is the right place to fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced updated with +. So I removed this updated here.

I had to override + in 2.13 version of CaseInsensitiveMap, because a standard Map would be returned from +.

@@ -118,7 +118,7 @@ class DataFrameReader private[sql](sparkSession: SparkSession) extends Logging {
* @since 1.4.0
*/
def option(key: String, value: String): DataFrameReader = {
this.extraOptions += (key -> value)
this.extraOptions = this.extraOptions.updated(key, value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we already implement +, can you just write this.extraOptions = this.extraOptions.updated + (key -> value)? I think that is how Scala 2.12 desugared this already, but 2.13 won't. If so that's the most straightforward change, doesn't need a new method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I replaced updated with +.

I had to override it in 2.13 version of CaseInsensitiveMap, because a standard Map would be returned from +.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, it isn't needed in 2.12? OK fine. It could be OK to add it to 2.12 too for completeness

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already in 2.12, but not in 2.13

@SparkQA
Copy link

SparkQA commented Aug 31, 2020

Test build #128107 has finished for PR 29584 at commit c5228e1.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@karolchmist karolchmist changed the title [SPARK-32364][SQL][FOLLOWUP] Fix CaseInsensitiveMap usage for Scala 2.13 [SPARK-32756][SQL][FOLLOWUP] Fix CaseInsensitiveMap usage for Scala 2.13 Aug 31, 2020
@karolchmist
Copy link
Contributor Author

How about filing a new jira ticket as a sub-ticket of https://issues.apache.org/jira/browse/SPARK-25075 ?

Done: https://issues.apache.org/jira/browse/SPARK-32756

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-32756][SQL][FOLLOWUP] Fix CaseInsensitiveMap usage for Scala 2.13 [SPARK-32756][SQL] Fix CaseInsensitiveMap usage for Scala 2.13 Aug 31, 2020
@dongjoon-hyun
Copy link
Member

Thanks, @karolchmist .

@srowen
Copy link
Member

srowen commented Sep 1, 2020

Ah, it's just complaining about whitespace:

[error] /home/jenkins/workspace/SparkPullRequestBuilder@3/sql/catalyst/src/main/scala-2.12/org/apache/spark/sql/catalyst/util/CaseInsensitiveMap.scala:45:0: Whitespace at end of line
[error] /home/jenkins/workspace/SparkPullRequestBuilder@3/sql/catalyst/src/main/scala-2.12/org/apache/spark/sql/catalyst/util/CaseInsensitiveMap.scala:45:0: Whitespace at end of line

@SparkQA
Copy link

SparkQA commented Sep 2, 2020

Test build #128161 has finished for PR 29584 at commit a9561ea.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen srowen closed this in 7511e43 Sep 2, 2020
@srowen
Copy link
Member

srowen commented Sep 2, 2020

Merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants