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

    https://github.com/apache/spark/pull/4380#discussion_r24250954
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
    @@ -422,6 +422,40 @@ private[hive] class HiveMetastoreCatalog(hive: 
HiveContext) extends Catalog with
         }
       }
     
    +  object WriteToDirs extends Rule[LogicalPlan] with HiveInspectors {
    +    import org.apache.hadoop.hive.ql.Context
    +    import org.apache.hadoop.hive.ql.parse.{ASTNode, SemanticAnalyzer}
    +
    +    def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +      // Wait until children are resolved.
    +      case p: LogicalPlan if !p.childrenResolved => p
    +
    +      case WriteToDirectory(path, child, isLocal, extra: ASTNode) =>
    +        // use hive analyzer to analyze row format info and file format 
info
    +        val sa = new SemanticAnalyzer(hive.hiveconf) {
    +          override def analyzeInternal(ast: ASTNode) {
    +            val ctx_1 = this.initPhase1Ctx()
    +            this.doPhase1(ast, this.getQB, ctx_1)
    +            this.getMetaData(this.getQB)
    +          }
    +        }
    +        // analyze row format info
    +        sa.analyze(extra, new Context(hive.hiveconf))
    +        val localDesc = sa.getQB.getLLocalDirectoryDesc
    +
    +        // generate column name and related type info as hive style
    +        val Array(cols, types) = child.output.foldLeft(Array("", ""))((r, 
a) => {
    +          r(0) = r(0) + a.name + ","
    +          r(1) = r(1) + a.dataType.toTypeInfo.getTypeName + ":"
    +          r
    +        })
    +
    +        val tableDesc =
    +          PlanUtils.getDefaultTableDesc(localDesc, cols.dropRight(1), 
types.dropRight(1))
    +
    +        WriteToDirectory(path, child, isLocal, tableDesc)
    --- End diff --
    
    is there other method to get the tabledesc?


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