Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/15898#discussion_r88175031
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/orc/OrcQuerySuite.scala ---
@@ -577,4 +579,23 @@ class OrcQuerySuite extends QueryTest with
BeforeAndAfterAll with OrcTest {
assert(spark.table(tableName).schema == schema.copy(fields =
expectedFields))
}
}
+
+ test("Empty schema does not read data from ORC file") {
+ val data = (1 to 2).zip(1 to 2)
+ withOrcFile(data) { path =>
+ val requrestedSchema = StructType(Nil)
+ val conf = new Configuration()
+ val physicalSchema = OrcFileOperator.readSchema(Seq(path),
Some(conf)).get
+ OrcRelation.setRequiredColumns(conf, physicalSchema,
requrestedSchema)
+ val maybeOrcReader = OrcFileOperator.getFileReader(path, Some(conf))
+ assert(maybeOrcReader.isDefined)
+ val orcRecordReader = new SparkOrcNewRecordReader(
+ maybeOrcReader.get, conf, 0, maybeOrcReader.get.getContentLength)
+
+ val recordsIterator = new
RecordReaderIterator[OrcStruct](orcRecordReader)
+ assert(recordsIterator.next().toString == "{null, null}")
+
+ recordsIterator.close()
--- End diff --
Maybe, we should put some sugar on this something like `try {..} finally
{recordsIterator.close()}`. I just wanted to show that it might be able to be
tested :). if this test looks good to other guys as well.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]