Comments (7)
Good idea. How/where/from what client would you invoke this? Is this something you'd like to put in a .sql file and run with our psql command line tool? Or are you using SQuirrel, an open source SQL client? If the latter, you can get at the list of tables through the "New Database Object Tree" button in the tool bar or through the "Objects" tab (next to the default "SQL" tab when you open a connection).
If the former, this would be a good, isolated contribution someone could make. Here's what would be required:
- Derive a new ShowTablesStatement in com.salesforce.phoenix.parse that implements SQLStatement. This is the AST node class that captures any state at parse time. In this case, unless the SHOW TABLES has other options, you may not have any state.
- Add to ParseNodeFactory a showTables() method that instantiates your new ShowTablesStatement.
- Modify PhoenixSQL.g to include a SHOW TABLES command. Use the drop_table rule/action as a guide - this will be more or less the same:
- Add SHOW and TABLES to the list of tokens at the top of the file.
- Add a SHOW TABLES rule to oneStatement rule where all the other top level commands start.
- Use the factory.showTables() to instantiate the ShowTablesStatement as the action of the rule.
- In PhoenixStatement:
- create an ExecutableShowTablesStatement that extends your ShowTablesStatement and implements ExecutableStatement (just copy/paste from ExecutableAddColumnStatement).
- modify ExecutableNodeFactory to override the showTables method to instantiate and return your ExecutableShowTablesStatement.
- In your ExecutableShowTablesStatement implement the executeUpdate method and use the standard JDBC way to access table metadata:
// TODO: if SHOW TABLES allows one to specify a schema pattern,
// then pass that info through here in the second argument to getTables
ResultSet rs = connection.getMetaData().getTables(null,null,null,null);
while (rs.next()) {
String schema = rs.getString(2);
String table = rs.getString(3);
String name = SchemaUtil.getTableDisplayName(schema,table);
System.out.println(name);
}
- Create a few unit tests to verify it's working correctly. You could add these to QueryDatabaseMetaDataTest.
from phoenix.
Christopher,
Anything I can do to help? Should I just pull in your original request - there were only a couple of minor items to fix up.
Thanks!
James
from phoenix.
I'm still waiting for my approval to contribute the code... I will submit it again once I get the green light.
from phoenix.
Ah, ok. Thanks for the heads up
from phoenix.
This has been added (thanks, @testn). Still needs to be added to the documentation (in docs/phoenix.csv)
from phoenix.
mark.
from phoenix.
With SQLLine support plus JDBC driver support of the metadata APIs, I don't think we need this any longer.
from phoenix.
Related Issues (20)
- Got TableNotFoundException when upgrading from Phoenix 2.2.x HOT 1
- Not able to see the table in hbase
- java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
- encounter Error: (state=08000,code=101), when we create index on bigtable HOT 19
- Creating Empty Column Families with CREATE Table HOT 1
- why am i select data slow? HOT 2
- Add REGEXP_LIKE buit-in function HOT 2
- When I run the Phoenix over my hbase cluster I meet the warning below HOT 2
- phoenix map hbase table , phoenix data content is not correct HOT 1
- ERROR 1012 (42M03): Table undefined HOT 6
- How to use phoenuix to map to an Existing HBase Table
- what situation does index works? HOT 1
- how can i use UPSERT VALUES? HOT 1
- Exception on upserting data on table with using upsert select
- Query a Secure HBase cluster through Phoenix In Java code HOT 2
- Offtopic Question: Bloom Filter Implementation In Apex
- Phoenix View for HBase is not updating
- Operations on table throw exception: ArrayIndexOutOfBoundsException & DoNotRetryIOException
- Phoenix issue-Distribution-IBM BigInsights- Hbase(1.1.1)-Phoenix 4.7 HOT 1
- Phoenix View on pre-existing HBase namespace table? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phoenix.