Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5876#discussion_r29898324
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateTableAsSelect.scala
 ---
    @@ -39,17 +39,34 @@ import org.apache.spark.sql.hive.MetastoreRelation
      */
     private[hive]
     case class CreateTableAsSelect(
    -    database: String,
    -    tableName: String,
    +    tableDesc: HiveTable,
         query: LogicalPlan,
    -    allowExisting: Boolean,
    -    desc: Option[CreateTableDesc]) extends RunnableCommand {
    +    allowExisting: Boolean)
    +  extends RunnableCommand {
    +
    +  def database: String = tableDesc.database
    +  def tableName: String = tableDesc.name
     
       override def run(sqlContext: SQLContext): Seq[Row] = {
         val hiveContext = sqlContext.asInstanceOf[HiveContext]
         lazy val metastoreRelation: MetastoreRelation = {
    -      // Create Hive Table
    -      hiveContext.catalog.createTable(database, tableName, query.output, 
allowExisting, desc)
    +      import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
    +      import org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
    +      import org.apache.hadoop.io.Text
    +      import org.apache.hadoop.mapred.TextInputFormat
    +
    +      val withSchema =
    +        tableDesc.copy(
    +          schema =
    +            query.output.map(c =>
    +              HiveColumn(c.name, 
HiveMetastoreTypes.toMetastoreType(c.dataType), null)),
    +            inputFormat =
    --- End diff --
    
    indentation looks off here; shouldn't this be aligned with `schema =`?


---
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]

Reply via email to