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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to