Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adding options to Reader
  • Loading branch information
MaxGekk committed Sep 20, 2018
commit f8b5aa6b3d1fc9e953bcfef8f23aeb6f3ab7818d
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ class DataSourceV2Suite extends QueryTest with SharedSQLContext {
.option(optionName, false)
.format(classOf[DataSourceV2WithSessionConfig].getName).load()
val options = df.queryExecution.optimizedPlan.collectFirst {
case d: DataSourceV2Relation => d.options
case DataSourceV2Relation(_, SimpleDataSourceV2Reader(options)) => options
}
assert(options.get.get(optionName) == Some("false"))
assert(options.get.getBoolean(optionName, true) == false)
}
}

Expand All @@ -350,17 +350,18 @@ class DataSourceV2Suite extends QueryTest with SharedSQLContext {
}
}

class SimpleDataSourceV2 extends DataSourceV2 with ReadSupport {

class Reader extends DataSourceReader {
override def readSchema(): StructType = new StructType().add("i", "int").add("j", "int")
case class SimpleDataSourceV2Reader(options: DataSourceOptions) extends DataSourceReader {
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for this non-trivial backporting, @MaxGekk !

override def readSchema(): StructType = new StructType().add("i", "int").add("j", "int")

override def createDataReaderFactories(): JList[DataReaderFactory[Row]] = {
java.util.Arrays.asList(new SimpleDataReaderFactory(0, 5), new SimpleDataReaderFactory(5, 10))
}
override def createDataReaderFactories(): JList[DataReaderFactory[Row]] = {
java.util.Arrays.asList(new SimpleDataReaderFactory(0, 5), new SimpleDataReaderFactory(5, 10))
}
}

override def createReader(options: DataSourceOptions): DataSourceReader = new Reader
class SimpleDataSourceV2 extends DataSourceV2 with ReadSupport {
override def createReader(options: DataSourceOptions): DataSourceReader = {
SimpleDataSourceV2Reader(options)
}
}

class SimpleDataReaderFactory(start: Int, end: Int)
Expand Down