spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liancheng <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-3007][SQL]Add "Dynamic Partition" suppo...
Date Mon, 18 Aug 2014 09:13:45 GMT
Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1919#discussion_r16343370
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
---
    @@ -201,17 +270,79 @@ case class InsertIntoHiveTable(
           }
         }
     
    -    // ORC stores compression information in table properties. While, there are other
formats
    -    // (e.g. RCFile) that rely on hadoop configurations to store compression information.
    -    val jobConf = new JobConf(sc.hiveconf)
    -    saveAsHiveFile(
    -      rdd,
    -      outputClass,
    -      fileSinkConf,
    -      jobConf,
    -      sc.hiveconf.getBoolean("hive.exec.compress.output", false))
    -
    -    // TODO: Handle dynamic partitioning.
    +    if (dynamicPartNum > 0) {
    +      if (outputClass == null) {
    +        throw new SparkException("Output value class not set")
    +      }
    +      jobConfSer.value.setOutputValueClass(outputClass)
    +      if (fileSinkConf.getTableInfo.getOutputFileFormatClassName == null) {
    +        throw new SparkException("Output format class not set")
    +      }
    +      // Doesn't work in Scala 2.9 due to what may be a generics bug
    +      // TODO: Should we uncomment this for Scala 2.10?
    +      // conf.setOutputFormat(outputFormatClass)
    +      jobConfSer.value.set("mapred.output.format.class", fileSinkConf.getTableInfo.getOutputFileFormatClassName)
    +      if (sc.hiveconf.getBoolean("hive.exec.compress.output", false)) {
    +        // Please note that isCompressed, "mapred.output.compress", "mapred.output.compression.codec",
    +        // and "mapred.output.compression.type" have no impact on ORC because it uses
table properties
    +        // to store compression information.
    +        jobConfSer.value.set("mapred.output.compress", "true")
    +        fileSinkConf.setCompressed(true)
    +        fileSinkConf.setCompressCodec(jobConfSer.value.get("mapred.output.compression.codec"))
    +        fileSinkConf.setCompressType(jobConfSer.value.get("mapred.output.compression.type"))
    +      }
    +      jobConfSer.value.setOutputCommitter(classOf[FileOutputCommitter])
    +
    +      FileOutputFormat.setOutputPath(
    +        jobConfSer.value,
    +        SparkHiveHadoopWriter.createPathFromString(fileSinkConf.getDirName, jobConfSer.value))
    +
    +      var writerMap =  new scala.collection.mutable.HashMap[String, SparkHiveHadoopWriter]
    +      def writeToFile2(context: TaskContext, iter: Iterator[Writable]) {
    +        // Hadoop wants a 32-bit task attempt ID, so if ours is bigger than Int.MaxValue,
roll it
    +        // around by taking a mod. We expect that no task will be attempted 2 billion
times.
    +        val attemptNumber = (context.attemptId % Int.MaxValue).toInt
    +        val serializer = newSerializer(fileSinkConf.getTableInfo)
    +        var count = 0
    +        var writer2:SparkHiveHadoopWriter = null
    +        while(iter.hasNext) {
    --- End diff --
    
    Space after `(`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message