Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/21319#discussion_r187878368
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Relation.scala
---
@@ -150,111 +127,57 @@ case class StreamingDataSourceV2Relation(
}
object DataSourceV2Relation {
+
private implicit class SourceHelpers(source: DataSourceV2) {
- def asReadSupport: ReadSupport = {
- source match {
- case support: ReadSupport =>
- support
- case _: ReadSupportWithSchema =>
- // this method is only called if there is no user-supplied
schema. if there is no
- // user-supplied schema and ReadSupport was not implemented,
throw a helpful exception.
- throw new AnalysisException(s"Data source requires a
user-supplied schema: $name")
- case _ =>
- throw new AnalysisException(s"Data source is not readable:
$name")
- }
- }
- def asReadSupportWithSchema: ReadSupportWithSchema = {
- source match {
- case support: ReadSupportWithSchema =>
- support
- case _: ReadSupport =>
- throw new AnalysisException(
- s"Data source does not support user-supplied schema: $name")
- case _ =>
- throw new AnalysisException(s"Data source is not readable:
$name")
- }
+ private def asReadSupport: ReadSupport = source match {
--- End diff --
Since I'm touching the code around here, I removed the out-most `{ }` and
fixed the indentation here. I can revert it if people this is not worth.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]