Search code examples
jdbcapache-drill

Apache Drill and databaseMetadata.getColumns: Values for catalog / schema?


I am trying to use drill via JDBC, but I have problems using the databasemeta-interface.

I am accessing a mongodb database (called HR) and a collection called EMPLOYEES (we copied Oracle’s HR schema into mongo to test if our code is portable to NoSQL and other non-RDBMS-sources via Apache drill)

Querying the table like Select * from mongo.HR.EMPLOYEES works fine, but how can I access the databasemetadata?

When I try to use the method getColumns() (catalog=null, Schema = „mongo.HR“, table=“EMPLOYEES“), I only receive an empty resultset.

I also tried to set catalog=mongo, Schema=HR, table=EMPLOYEES, but had no success?

Any idea, who I could get the column metadata?


Solution

  • If you check the documentation of DatabaseMetaData.getColumns, it says:

    catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
    schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search

    Or, in other words, if you don't know what to use, then use null for catalog and schemaPattern. A compliant JDBC driver should then drop (ignore) the condition. You can then check the values of TABLE_CAT and TABLE_SCHEM to see what values catalog and schema actually have for columns.