hivemall-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maropu <...@git.apache.org>
Subject [GitHub] incubator-hivemall pull request #61: [HIVEMALL-88][SPARK] Support a function...
Date Thu, 09 Mar 2017 06:11:58 GMT
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/incubator-hivemall/pull/61#discussion_r105093086
  
    --- Diff: spark/spark-2.1/src/main/scala/org/apache/spark/sql/hive/HivemallOps.scala ---
    @@ -805,6 +805,47 @@ final class HivemallOps(df: DataFrame) extends Logging {
         JoinTopK(kInt, df.logicalPlan, right.logicalPlan, Inner, Option(joinExprs.expr))(score.named)
       }
     
    +  private def doFlatten(schema: StructType, prefix: Option[String] = None) : Seq[Column]
= {
    +    schema.fields.flatMap { f =>
    +      val colName = prefix.map(p => s"$p.${f.name}").getOrElse(f.name)
    --- End diff --
    
    Actually, we can access this column like this;
    ```
    scala> val df = Seq((1, (1.0, "a"))).toDF()
    df: org.apache.spark.sql.DataFrame = [_1: int, _2: struct<_1: double, _2: string>]
    
    scala> val ds1 = df.flatten().select("`_2._1`").show
    +-----+
    |_2._1|
    +-----+
    |  1.0|
    +-----+
    
    ```


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

Mime
View raw message