spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rxin <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-8238][SPARK-8239][SPARK-8242][SPARK-824...
Date Thu, 18 Jun 2015 06:07:59 GMT
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6843#discussion_r32701290
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala
---
    @@ -313,3 +313,131 @@ case class StringLength(child: Expression) extends UnaryExpression
with ExpectsI
         defineCodeGen(ctx, ev, c => s"($c).length()")
       }
     }
    +
    +/**
    + * Returns the numeric value of the first character of str.
    + */
    +case class Ascii(child: Expression) extends UnaryExpression with ExpectsInputTypes {
    +  override def dataType: DataType = IntegerType
    +  override def expectedChildTypes: Seq[DataType] = Seq(StringType)
    +
    +  override def eval(input: InternalRow): Any = {
    +    val string = child.eval(input)
    +    if (string == null) {
    +      null
    +    } else {
    +      val bytes = string.asInstanceOf[UTF8String].getBytes
    +      if (bytes.length > 0) {
    --- End diff --
    
    what should the behavior be if it is a non-ascii utf8 string?


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