southernriver commented on a change in pull request #23506: [SPARK-26577][SQL] 
Add input optimizer when reading Hive table by SparkSQL
URL: https://github.com/apache/spark/pull/23506#discussion_r274376153
 
 

 ##########
 File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/TableReader.scala
 ##########
 @@ -311,6 +309,32 @@ class HadoopTableReader(
     // Only take the value (skip the key) because Hive works only with values.
     rdd.map(_._2)
   }
+
+  /**
+   * If `spark.sql.hive.fileInputFormat.enabled` is true, this function will 
optimize the input
+   * method(including format and the size of splits) while reading Hive tables.
+   */
+  private def getAndOptimizeInput(
+    inputClassName: String): Class[InputFormat[Writable, Writable]] = {
+
+    var ifc = Utils.classForName(inputClassName)
+      .asInstanceOf[java.lang.Class[InputFormat[Writable, Writable]]]
+    if (conf.getConf(HiveUtils.HIVE_INPUT_FORMAT_OPTIMIZER_ENABLED)) {
+      if ("org.apache.hadoop.mapreduce.lib.input.TextInputFormat"
+        .equals(inputClassName)) {
+        ifc = Utils.classForName(
+          "org.apache.hadoop.mapreduce.lib.input.CombineTextInputFormat")
+          .asInstanceOf[java.lang.Class[InputFormat[Writable, Writable]]]
+      }
+      if ("org.apache.hadoop.mapred.TextInputFormat"
 
 Review comment:
   @Deegue Some other inputformat  like parquet or orc would also have the same 
issue, have you support that.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to