You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/10/04 17:03:46 UTC

[GitHub] spark pull request #19392: [SPARK-22169][SQL] support byte length literal as...

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

    https://github.com/apache/spark/pull/19392#discussion_r142731310
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala ---
    @@ -699,20 +699,30 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging
           Sample(0.0, fraction, withReplacement = false, (math.random * 1000).toInt, query)
         }
     
    -    ctx.sampleType.getType match {
    -      case SqlBaseParser.ROWS =>
    +    if (ctx.sampleMethod() == null) {
    +      throw new ParseException("TABLESAMPLE does not accept empty inputs.", ctx)
    +    }
    +
    +    ctx.sampleMethod() match {
    +      case ctx: SampleByRowsContext =>
             Limit(expression(ctx.expression), query)
     
    -      case SqlBaseParser.PERCENTLIT =>
    +      case ctx: SampleByPercentileContext =>
             val fraction = ctx.percentage.getText.toDouble
             val sign = if (ctx.negativeSign == null) 1 else -1
             sample(sign * fraction / 100.0d)
     
    -      case SqlBaseParser.BYTELENGTH_LITERAL =>
    -        throw new ParseException(
    -          "TABLESAMPLE(byteLengthLiteral) is not supported", ctx)
    +      case ctx: SampleByBytesContext =>
    --- End diff --
    
    Add the syntax here?
    ```
    block_sample: TABLESAMPLE (ByteLengthLiteral)
     
    ByteLengthLiteral : (Digit)+ ('b' | 'B' | 'k' | 'K' | 'm' | 'M' | 'g' | 'G')
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org