Skip to content

PHOENIX-5543: Implement SHOW TABLES/SCHEMAS sql commands - #1278

Merged
richardantal merged 1 commit into
apache:4.16from
richardantal:PHOENIX-5543-4.16
Aug 2, 2021
Merged

PHOENIX-5543: Implement SHOW TABLES/SCHEMAS sql commands#1278
richardantal merged 1 commit into
apache:4.16from
richardantal:PHOENIX-5543-4.16

Conversation

@richardantal

Copy link
Copy Markdown
Contributor

This patch adds new SQL grammar like following

  • SHOW SCHEMAS [like '']
  • SHOW TABLES [IN ] [like '<pattern']

Example invocations:

  • show schemas
  • show scemas like 'SYS%'
  • show tables
  • show tables in SYSTEM
  • show tables in SYSTEM like 'CAT%'

The current way of fetching this information is by using
!tables and !schemas via sqlline JDBC support but that is
not flexible enough for the end users to add more fitlers.
This approach is more inline with what other databases do.

Added test coverage in parser tests and core e2e tests.

This patch adds new SQL grammar like following
- SHOW SCHEMAS [like '<pattern>']
- SHOW TABLES [IN <schema>] [like '<pattern']
Example invocations:
- show schemas
- show scemas like 'SYS%'
- show tables
- show tables in SYSTEM
- show tables in SYSTEM like 'CAT%'
The current way of fetching this information is by using
!tables and !schemas via sqlline JDBC support but that is
not flexible enough for the end users to add more fitlers.
This approach is more inline with what other databases do.
Added test coverage in parser tests and core e2e tests.
Change-Id: Iafc5cc8122e88501f0a5595ee51ba2dc7556ec4a
@richardantalrichardantal added the backport Backport PR label Jul 30, 2021
@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 35sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚test4tests0m 0sThe patch appears to include 1 new or modified test files.
_ 4.16 Compile Tests _
+0 🆗mvndep5m 17sMaven dependency ordering for branch
+1 💚mvninstall13m 40s4.16 passed
+1 💚compile1m 39s4.16 passed
+1 💚checkstyle1m 27s4.16 passed
+1 💚javadoc1m 3s4.16 passed
+0 🆗spotbugs3m 9sphoenix-core in 4.16 has 948 extant spotbugs warnings.
+0 🆗spotbugs0m 55sphoenix-pherf in 4.16 has 42 extant spotbugs warnings.
_ Patch Compile Tests _
+0 🆗mvndep0m 11sMaven dependency ordering for patch
+1 💚mvninstall12m 45sthe patch passed
+1 💚compile2m 19sthe patch passed
+1 💚javac2m 19sthe patch passed
-1 ❌checkstyle1m 38sphoenix-core: The patch generated 142 new + 1080 unchanged - 103 fixed = 1222 total (was 1183)
-1 ❌checkstyle0m 17sphoenix-pherf: The patch generated 1 new + 68 unchanged - 6 fixed = 69 total (was 74)
-1 ❌whitespace0m 0sThe patch 1 line(s) with tabs.
+1 💚javadoc1m 25sthe patch passed
-1 ❌spotbugs4m 50sphoenix-core generated 5 new + 943 unchanged - 5 fixed = 948 total (was 948)
_ Other Tests _
+1 💚unit143m 17sphoenix-core in the patch passed.
-1 ❌unit7m 36sphoenix-pherf in the patch failed.
+1 💚asflicense0m 19sThe patch does not generate ASF License warnings.
205m 20s
ReasonTests
FindBugsmodule:phoenix-core
org.apache.phoenix.util.QueryUtil.getCatalogsStmt(PhoenixConnection) may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:[line 528] is not discharged
org.apache.phoenix.util.QueryUtil.getIndexInfoStmt(PhoenixConnection, String, String, String, boolean, boolean) may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:boolean) may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:[line 635] is not discharged
org.apache.phoenix.util.QueryUtil.getSchemasStmt(PhoenixConnection, String, String) may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:[line 560] is not discharged
org.apache.phoenix.util.QueryUtil.getSuperTablesStmt(PhoenixConnection, String, String, String) may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:[line 590] is not discharged
org.apache.phoenix.util.QueryUtil.getTablesStmt(PhoenixConnection, String, String, String, String[]) may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:may fail to clean up java.sql.Statement on checked exception Obligation to clean up resource created at QueryUtil.java:[line 765] is not discharged
Failed junit testsphoenix.pherf.PherfMainIT
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1278
JIRA IssuePHOENIX-5543
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile
unameLinux e37a2dc1b998 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev/phoenix-personality.sh
git revision4.16 / 3a4339e
Default JavaPrivate Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/artifact/yetus-general-check/output/diff-checkstyle-phoenix-pherf.txt
whitespacehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/artifact/yetus-general-check/output/whitespace-tabs.txt
spotbugshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/artifact/yetus-general-check/output/patch-unit-phoenix-pherf.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/testReport/
Max. process+thread count5703 (vs. ulimit of 30000)
modulesC: phoenix-core phoenix-pherf U: .
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1278/2/console
versionsgit=2.7.4 maven=3.3.9 spotbugs=4.1.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@dbwong

Copy link
Copy Markdown
Contributor

One thing that wasn't entirely clear to me was were we considering views in the base JIRA or only tables for the initial scope?

@dbwongdbwong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above for question on views but what is the expected output when we call show on an index table?

assertEquals("SYSTEM", rs.getString("TABLE_SCHEM"));
}
assertEquals(8, tables.size());
assertTrue(tables.contains("CATALOG"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a user facing feature i think we should probably test against exact string we expect as people may end up relying on the message.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 396 we add what is in the TABLE_NAME column to the set called tables, here we assert that CATALOG and FUNCTION is in that set of tables.

@richardantal

richardantal commented Aug 2, 2021

Copy link
Copy Markdown
ContributorAuthor

Hey @dbwong
This is a backport PR, we already have this in the 4.x, master and 5.1 branches, 4.16 just got forgotten.

I'll try to answer your questions but I am not the original owner of the ticket.
It will list tables, views and indexes as well.
The output is the same as the output for !tables and !schemas command, here it is possible to filter those results.

jdbc:phoenix:localhost:65205> show tables like 'foo%';
+-----------+-------------+------------+------------+---------+-----------+---------------------------+----------------+-------------+----------------+--------------+--------------+----------------+-----------+------------+---------------+---------------------+-------------------+---------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE | IMMUTABLE_ROWS | SALT_BUCKETS | MULTI_TENANT | VIEW_STATEMENT | VIEW_TYPE | INDEX_TYPE | TRANSACTIONAL | IS_NAMESPACE_MAPPED | GUIDE_POSTS_WIDTH | TRANSAC |
+-----------+-------------+------------+------------+---------+-----------+---------------------------+----------------+-------------+----------------+--------------+--------------+----------------+-----------+------------+---------------+---------------------+-------------------+---------+
| | | foo_ind | INDEX | | | | | ACTIVE | false | null | false | | | GLOBAL | false | false | null | |
| | | foo_1 | TABLE | | | | | | false | null | false | | | | false | false | null | |
| | | foo_view | VIEW | | | | | | false | null | false | | UPDATABLE | | false | false | null | |
+-----------+-------------+------------+------------+---------+-----------+---------------------------+----------------+-------------+----------------+--------------+--------------+----------------+-----------+------------+---------------+---------------------+-------------------+---------+
3 rows selected (0.023 seconds)

@richardantal
richardantal merged commit 152c157 into apache:4.16Aug 2, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backportBackport PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@richardantal@stoty@dbwong@bharathv