Coder Social home page Coder Social logo

Show Table about phoenix HOT 7 CLOSED

forcedotcom avatar forcedotcom commented on July 30, 2024
Show Table

from phoenix.

Comments (7)

jtaylor-sfdc avatar jtaylor-sfdc commented on July 30, 2024

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.

jtaylor-sfdc avatar jtaylor-sfdc commented on July 30, 2024

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.

testn avatar testn commented on July 30, 2024

I'm still waiting for my approval to contribute the code... I will submit it again once I get the green light.

from phoenix.

jtaylor-sfdc avatar jtaylor-sfdc commented on July 30, 2024

Ah, ok. Thanks for the heads up

from phoenix.

jtaylor-sfdc avatar jtaylor-sfdc commented on July 30, 2024

This has been added (thanks, @testn). Still needs to be added to the documentation (in docs/phoenix.csv)

from phoenix.

colorant avatar colorant commented on July 30, 2024

mark.

from phoenix.

jtaylor-sfdc avatar jtaylor-sfdc commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.