delta icon indicating copy to clipboard operation
delta copied to clipboard

#1032 Changes to support SHOW CREATE TABLE

Open zpappa opened this issue 3 years ago • 3 comments

Description

This PR Resolves #1032 - Changes to support SHOW CREATE TABLE

  • Modification of antlr grammar
  • Additions to DeltaSqlParser to call a new command ShowCreateTableCommand
  • Creation of ShowCreateTableCommand based on attributed source
  • Addition of 10 tests to cover various permutations

How was this patch tested?

Added a new test suite to test various permutations across 10 tests.

[info] DeltaShowCreateTableSuite:
[info] - Test DDL Output for External Table SHOW CREATE TABLE (9 seconds, 109 milliseconds)
[info] - Test DDL Output for Managed Table SHOW CREATE TABLE (1 second, 147 milliseconds)
[info] - Test Recreate table using DDL SHOW CREATE TABLE (1 second, 819 milliseconds)
[info] - Test DDL Idempotency SHOW CREATE TABLE (1 second, 566 milliseconds)
[info] - Test DDL Comment SHOW CREATE TABLE (779 milliseconds)
[info] - Test DDL Partition SHOW CREATE TABLE (749 milliseconds)
[info] - Test DDL Random Table Property SHOW CREATE TABLE (692 milliseconds)
[info] - Test DDL with full variations SHOW CREATE TABLE (766 milliseconds)
[info] - Test Generated Column Results in Exception for SHOW CREATE TABLE (807 milliseconds)
[info] - Test DDL with full variations Recreate from DDL SHOW CREATE TABLE (1 second, 507 milliseconds)
[info] Run completed in 23 seconds, 813 milliseconds.
[info] Total number of tests run: 10
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 10, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.

Does this PR introduce any user-facing changes?

Yes. When running the command SHOW CREATE TABLE tablename. You will receive a DataFrame with a single column "ddl", which contains the CREATE TABLE script for the table in question.

zpappa avatar Jul 06 '22 22:07 zpappa

As discussed with @zsxwing there is no SQL support for generated columns, therefore I did not add support for it here. It is a minor change.

zpappa avatar Jul 07 '22 13:07 zpappa

I missed this case, before I re-request review I will add it.

zpappa avatar Jul 14 '22 18:07 zpappa

@zsxwing the ability to do this via file paths is now supported by this PR

zpappa avatar Aug 11 '22 14:08 zpappa

Hey everyone! Just wondering if there's any update on this and if I can help in any way. Thanks.

Silverlight42 avatar Jan 26 '23 03:01 Silverlight42

hey @zpappa did you still want to work on this? if not, @Silverlight42 could take over and address the pending comments

allisonport-db avatar Feb 10 '23 21:02 allisonport-db