-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SQL][MINOR] Fix compiling for scala 2.12 #22260
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
Conversation
@@ -38,7 +38,7 @@ private[execution] case class ProjectionOverSchema(schema: StructType) { | |||
case GetArrayItem(child, arrayItemOrdinal) => | |||
getProjection(child).map { projection => GetArrayItem(projection, arrayItemOrdinal) } | |||
case a: GetArrayStructFields => | |||
getProjection(a.child).map(p => (p, p.dataType)).map { | |||
getProjection(a.child).map(p => (p, p.dataType)).collect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this? IMO .collect
can't catch illegal inputs?
getProjection(a.child).map(p => (p, p.dataType)).map {
case (projection, ArrayType(projSchema @ StructType(_), _)) =>
GetArrayStructFields(projection,
projSchema(a.field.name),
projSchema.fieldIndex(a.field.name),
projSchema.size,
a.containsNull)
case _ =>
sys.error("....")
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there is a semantic change using collect
. I will provide a unit test to verify the change or simply adopt sys.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this generate an error or just a warning in 2.12? It's an unmatched case error, right?
We had 'fixed' this elsewhere with case _ => throw new IllegalStateException(...)
or something. At runtime it would have caused a MatchError before, right? Because it didn't, I hope, or else tests would have failed, it matters a bit less what happens in this case. But it felt more conservative to preserve the error behavior; maybe I was wrong about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use collect
, one must dive into SPARK-4502
.
This PR is intended for #22264 .
I will preserve the error behavior.
Can you add |
ok to test |
Test build #95401 has finished for PR 22260 at commit
|
Test build #95406 has finished for PR 22260 at commit
|
@@ -19,7 +19,7 @@ package org.apache.spark.sql.hive | |||
|
|||
import java.io.{BufferedWriter, File, FileWriter} | |||
|
|||
import scala.tools.nsc.Properties | |||
import scala.util.Properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works in 2.11 and 2.12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. And
scala.util.Properties
is better than scala.tools.nsc.Properties
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scala.tools
is part of scala-compiler
@@ -38,7 +38,7 @@ private[execution] case class ProjectionOverSchema(schema: StructType) { | |||
case GetArrayItem(child, arrayItemOrdinal) => | |||
getProjection(child).map { projection => GetArrayItem(projection, arrayItemOrdinal) } | |||
case a: GetArrayStructFields => | |||
getProjection(a.child).map(p => (p, p.dataType)).map { | |||
getProjection(a.child).map(p => (p, p.dataType)).collect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this generate an error or just a warning in 2.12? It's an unmatched case error, right?
We had 'fixed' this elsewhere with case _ => throw new IllegalStateException(...)
or something. At runtime it would have caused a MatchError before, right? Because it didn't, I hope, or else tests would have failed, it matters a bit less what happens in this case. But it felt more conservative to preserve the error behavior; maybe I was wrong about that?
LGTM, too. |
Test build #95452 has finished for PR 22260 at commit
|
Merged to master. |
## What changes were proposed in this pull request? Introduced by apache#21320 and apache#11744 ``` $ sbt > ++2.12.6 > project sql > compile ... [error] [warn] spark/sql/core/src/main/scala/org/apache/spark/sql/execution/ProjectionOverSchema.scala:41: match may not be exhaustive. [error] It would fail on the following inputs: (_, ArrayType(_, _)), (_, _) [error] [warn] getProjection(a.child).map(p => (p, p.dataType)).map { [error] [warn] [error] [warn] spark/sql/core/src/main/scala/org/apache/spark/sql/execution/ProjectionOverSchema.scala:52: match may not be exhaustive. [error] It would fail on the following input: (_, _) [error] [warn] getProjection(child).map(p => (p, p.dataType)).map { [error] [warn] ... ``` And ``` $ sbt > ++2.12.6 > project hive > testOnly *ParquetMetastoreSuite ... [error] /Users/rendong/wdi/spark/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveSparkSubmitSuite.scala:22: object tools is not a member of package scala [error] import scala.tools.nsc.Properties [error] ^ [error] /Users/rendong/wdi/spark/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveSparkSubmitSuite.scala:146: not found: value Properties [error] val version = Properties.versionNumberString match { [error] ^ [error] two errors found ... ``` ## How was this patch tested? Existing tests. Closes apache#22260 from sadhen/fix_exhaustive_match. Authored-by: 忍冬 <rendong@wacai.com> Signed-off-by: hyukjinkwon <gurwls223@apache.org>
What changes were proposed in this pull request?
Introduced by #21320 and #11744
And
How was this patch tested?
Existing tests.