GitHub user gatorsmile opened a pull request:

    https://github.com/apache/spark/pull/11148

    [Spark-13263] [SQL] SQL Generation Support for Tablesample

    In the parser, tableSample clause is part of tableSource. 
    ```
    tableSource
    @init { gParent.pushMsg("table source", state); }
    @after { gParent.popMsg(state); }
        : tabname=tableName 
        ((tableProperties) => props=tableProperties)?
        ((tableSample) => ts=tableSample)? 
        ((KW_AS) => (KW_AS alias=Identifier) 
        |
        (Identifier) => (alias=Identifier))?
        -> ^(TOK_TABREF $tabname $props? $ts? $alias?)
        ;
    ```
    
    Two typical query samples using TABLESAMPLE are:
    ```
        "SELECT s.id FROM t0 TABLESAMPLE(10 PERCENT) s"
        "SELECT * FROM t0 TABLESAMPLE(0.1 PERCENT)"
    ```
    
    FYI, the logical plan of a TABLESAMPLE query: 
    ```
    sql("SELECT * FROM t0 TABLESAMPLE(0.1 PERCENT)").explain(true)
    
    == Analyzed Logical Plan ==
    id: bigint
    Project [id#16L]
    +- Sample 0.0, 0.001, false, 381
       +- Subquery t0
          +- Relation[id#16L] ParquetRelation
    ```
    
    Thanks! cc @liancheng 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gatorsmile/spark tablesplitsample

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/11148.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #11148
    
----
commit 58b60383486eaa174ca7c579c3f0f75e1f3d58d0
Author: gatorsmile <[email protected]>
Date:   2016-02-10T06:44:15Z

    support tablesample

----


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