GitHub user xwu0226 opened a pull request:
https://github.com/apache/spark/pull/12132
Show create table
## What changes were proposed in this pull request?
1. add `SHOW CREATE TABLE tableIdentifier` in SqlBase.g4 file
2. create a `RunnableCommand ` class for `ShowCreateTableCommand`, that
invokes `SessionCatalog.generateTableDDL`
3. add `generateTableDDL ` method in `SessionCatalog `and override it in
`HiveSessionCatalog`.
4. `HiveSessionCatalog.generateTableDDL` is to create DDL for metastore
tables. and for tempTables in Spark, it may not be quite practical. For now, we
throw exception in `SessionCatalog.generateTableDDL`. If the community thinks
it is also necessary, we can implement this later.
5. `HiveSessionCatalog.generateTableDDL` branches out to generate Hive
syntax DDL for hive tables, while it is also supposed to branch out to generate
DataSource syntax DDL for datasource tables.
TODO:
1. implement generate DDL for DataSource table with DataSource syntax DDL
like "**USING**... **OPTIONS**..."
2. Currently for hive table DDL syntax, there are also a few potential gaps
like sortBucketSpec, skewSpec, storageHandler case, etc. that are not quite
supported in `CatalogTable`.. we may need to discuss whether we need to
complete this.
3. complete the unit testcase with checkAnswer.. Right now, it put the
show() to display what it generates.
## How was this patch tested?
unite tests with manual observation so far. Testcases will be completed as
TODO
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/xwu0226/spark show_create_table_1
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12132.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 #12132
----
commit efff74e90548ff8b2d031ac03d88e61677c73b78
Author: xin Wu <[email protected]>
Date: 2016-04-02T01:46:16Z
show create table DDL -- hive metastore table
commit c7ae9f434725a97d1beb0c2d3e4e781b6df12f61
Author: xin Wu <[email protected]>
Date: 2016-04-02T06:01:46Z
update upon review
commit 850edbe4654c10d0c95689447121b7686229dbf3
Author: xin Wu <[email protected]>
Date: 2016-04-02T18:19:26Z
ignoring sqlContext temp table and considering datasource table ddl
----
---
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]