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

    https://github.com/apache/spark/pull/4173#discussion_r23495024
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Column.scala ---
    @@ -0,0 +1,212 @@
    +/*
    +* Licensed to the Apache Software Foundation (ASF) under one or more
    +* contributor license agreements.  See the NOTICE file distributed with
    +* this work for additional information regarding copyright ownership.
    +* The ASF licenses this file to You under the Apache License, Version 2.0
    +* (the "License"); you may not use this file except in compliance with
    +* the License.  You may obtain a copy of the License at
    +*
    +*    http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing, software
    +* distributed under the License is distributed on an "AS IS" BASIS,
    +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +* See the License for the specific language governing permissions and
    +* limitations under the License.
    +*/
    +
    +package org.apache.spark.sql
    +
    +import org.apache.spark.sql.catalyst.analysis
    +import org.apache.spark.sql.catalyst.analysis.Star
    +
    +import scala.language.implicitConversions
    +
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.expressions.{Literal => LiteralExpr}
    +import org.apache.spark.sql.catalyst.plans.logical.{Project, LogicalPlan}
    +import org.apache.spark.sql.types._
    +
    +
    +object Literal {
    +  def apply(literal: Boolean): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: Byte): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: Short): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: Int): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: Long): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: Float): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: Double): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: String): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: BigDecimal): Column = new Column(LiteralExpr(literal))
    +  def apply(literal: java.math.BigDecimal): Column = new 
Column(LiteralExpr(literal))
    +  def apply(literal: java.sql.Timestamp): Column = new 
Column(LiteralExpr(literal))
    +  def apply(literal: java.sql.Date): Column = new 
Column(LiteralExpr(literal))
    +  def apply(literal: Array[Byte]): Column = new 
Column(LiteralExpr(literal))
    +  def apply(literal: Null): Column = new Column(LiteralExpr(null))
    +}
    +
    +
    +object Column {
    +  def unapply(col: Column): Option[Expression] = Some(col.expr)
    +
    +  def apply(colName: String): Column = new Column(colName)
    +}
    +
    +
    +class Column(
    +    sqlContext: Option[SQLContext],
    +    plan: Option[LogicalPlan],
    +    val expr: Expression)
    +  extends DataFrame(sqlContext, plan) with ExpressionApi[Column] {
    --- End diff --
    
    It's a tough call. The main use case is for some downstream library or 
application to consume them the same way.
    
    That's why I was thinking everything should just return a Row. I am also 
considering creating a simple local structure that contains the schema 
information and rows. Then downstream applications can just inspect or accept a 
DataFrame and then apply any operation they want.
    
    On the type side, again, we have the problem of runtime type vs compile 
time type. At compile, there is no type information for a column. If column is 
an RDD, then it has to be an RDD[Any], and all the closures will have to accept 
Any/Object.



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