-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-28810][DOC][SQL] Document SHOW TABLES in SQL Reference. #25561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
77e753a
5178160
19f39fc
55ea2cf
0dd4efb
1d08b22
847fb8e
05a2e60
fed9431
83cff5d
f3e1c31
8e1e114
e26f55b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -18,5 +18,83 @@ license: | | |||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| --- | ||||
| ### Description | ||||
|
|
||||
| **This page is under construction** | ||||
| List all the `tables` from the database with `database-name` and `is temporary table`. | ||||
|
|
||||
| ### Syntax | ||||
| {% highlight sql %} | ||||
| SHOW TABLES [{FROM|IN} database_name] [LIKE 'regex_pattern'] | ||||
| {% endhighlight %} | ||||
|
|
||||
| ### Parameters | ||||
| <dl> | ||||
| <dt><code><em>{FROM|IN} database_name</em></code></dt> | ||||
| <dd> | ||||
| Specifies the `database` name from which tables are listed. | ||||
| </dd> | ||||
| <dt><code><em>LIKE 'regex_pattern'</em></code></dt> | ||||
| <dd> | ||||
| Specifies the regex pattern that is used to filter out unwanted tables. | ||||
| <br> - Only `*` and `|` are allowed as wildcard pattern. | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shivusondur Can you please include the example with output using the 'I' as wildcard ? From the code its not clear to me if this is supported.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dilipbiswal
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srowen Thats a very good point Sean. How about we name the pattern 'identifier_with_wildcards' (and describe as such) as mentioned in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a SQL-like pattern that supports wildcards like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srowen I quickly tried in my env. It does not support SQL-like pattern like
@shivusondur Can you please confirm ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dilipbiswal @srowen spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala Line 88 in e1ea806
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, your comment is consistent with the docs then. Hm, but isn't it more accurate to say that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srowen @dilipbiswal I updated according to your suggestion and screenshot also I updated. |
||||
| <br> - Excluding `*` and `|` the remaining pattern follows the regex semantics. | ||||
| <br> - The leading and trailing blanks are trimmed in the input pattern before processing. | ||||
| </dd> | ||||
| </dl> | ||||
|
|
||||
| ### Example | ||||
| {% highlight sql %} | ||||
| -- List all tables in default database | ||||
| SHOW TABLES; | ||||
| +-----------+------------+--------------+--+ | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please lets fix the formatting. Did we construct this output by hand ? Can we paste the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dilipbiswal In the UI it looks like below, i think it is normal Only in the git file editor, it shows inconsistent. |
||||
| | database | tableName | isTemporary | | ||||
| +-----------+------------+--------------+--+ | ||||
| | default | sam | false | | ||||
| | default | sam1 | false | | ||||
| | default | suj | false | | ||||
| +-----------+------------+--------------+--+ | ||||
|
|
||||
| -- List all tables from userdb database | ||||
| SHOW TABLES FROM userdb; | ||||
| +-----------+------------+--------------+--+ | ||||
| | database | tableName | isTemporary | | ||||
| +-----------+------------+--------------+--+ | ||||
| | userdb | user1 | false | | ||||
| | userdb | user2 | false | | ||||
| +-----------+------------+--------------+--+ | ||||
|
|
||||
| -- List all tables in userdb database | ||||
| SHOW TABLES IN userdb; | ||||
| +-----------+------------+--------------+--+ | ||||
| | database | tableName | isTemporary | | ||||
| +-----------+------------+--------------+--+ | ||||
| | userdb | user1 | false | | ||||
| | userdb | user2 | false | | ||||
| +-----------+------------+--------------+--+ | ||||
|
|
||||
| -- List all tables from default database matching the pattern `sam*` | ||||
| SHOW TABLES FROM default LIKE 'sam*'; | ||||
| +-----------+------------+--------------+--+ | ||||
| | database | tableName | isTemporary | | ||||
| +-----------+------------+--------------+--+ | ||||
| | default | sam | false | | ||||
| | default | sam1 | false | | ||||
| +-----------+------------+--------------+--+ | ||||
|
|
||||
| -- List all tables matching the pattern `sam*|suj` | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: can we have a line between previous test and this one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dilipbiswal |
||||
| SHOW TABLES LIKE 'sam*|suj'; | ||||
| +-----------+------------+--------------+--+ | ||||
| | database | tableName | isTemporary | | ||||
| +-----------+------------+--------------+--+ | ||||
| | default | sam | false | | ||||
| | default | sam1 | false | | ||||
| | default | suj | false | | ||||
| +-----------+------------+--------------+--+ | ||||
|
|
||||
| {% endhighlight %} | ||||
|
shivusondur marked this conversation as resolved.
Outdated
|
||||
|
|
||||
| ### Related statements | ||||
| - [CREATE TABLE](sql-ref-syntax-ddl-create-table.html) | ||||
| - [DROP TABLE](sql-ref-syntax-ddl-drop-table.html) | ||||
| - [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html) | ||||
| - [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html) | ||||



There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shivusondur Sorry.. re-reading this one last time :-)
SHOW TABLESstatement returns all the tables for an optionally specified database. Additionally, the outputof this statement may be filtered via an optional matching pattern. If no database is specified then the tables
are returned from the current database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOne