使用 java jdbc api 从 drill 查询 maprdb

Query maprdb from drill using the java jdbc api

我有一个 dfs.nwssot 的架构,在该架构下我有 "collection_details_hbase" 在 maprdb 之上创建 table 的视图。但是,当我查询 table 时,它没有被识别。我如何使用 drill jdbc.

查询 maprdb
try {
            Class.forName(JDBC_DRIVER);
            conn = DriverManager.getConnection(DB_URL, USER, PASS);

            stmt = conn.createStatement();
            /* Perform a select on data in the classpath storage plugin. */
            String sql = "use dfs.nwssot";
            stmt.executeQuery(sql);
            String sql2 = "select * from collection_details_hbase";
            ResultSet rs = stmt.executeQuery(sql2);
            rsmd = rs.getMetaData();
//          rs.setFetchSize(100);

//          while (rs.next()) {
//              
//          }

            for (int i=1; i<=rsmd.getColumnCount(); i++)
            {
                System.out.println(rsmd.getColumnLabel(i));
            }

            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException se) {
            se.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

异常

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.sql.SQLException: VALIDATION ERROR: From line 1, column 15 to line 1, column 38: Table 'collection_details_hbase' not found

SQL Query null

[Error Id: 5d73d746-215f-435a-9742-8137fad54e5e on hdstg-c01-r02-02:31010]
    at org.apache.drill.jdbc.impl.DrillCursor.nextRowInternally(DrillCursor.java:214)
    at org.apache.drill.jdbc.impl.DrillCursor.loadInitialSchema(DrillCursor.java:257)
    at org.apache.drill.jdbc.impl.DrillResultSetImpl.execute(DrillResultSetImpl.java:1362)
    at org.apache.drill.jdbc.impl.DrillResultSetImpl.execute(DrillResultSetImpl.java:72)
    at net.hydromatic.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:404)
    at net.hydromatic.avatica.AvaticaStatement.executeQueryInternal(AvaticaStatement.java:351)
    at net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:78)
    at org.apache.drill.jdbc.impl.DrillStatementImpl.executeQuery(DrillStatementImpl.java:96)
    at com.cisco.jdbc.drill.DrillClient.DrillClient.main(DrillClient.java:34)
Caused by: org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 15 to line 1, column 38: Table 'collection_details_hbase' not found

SQL Query null

[Error Id: 5d73d746-215f-435a-9742-8137fad54e5e on hdstg-c01-r02-02:31010]
    at org.apache.drill.exec.rpc.user.QueryResultHandler.resultArrived(QueryResultHandler.java:118)
    at org.apache.drill.exec.rpc.user.UserClient.handleReponse(UserClient.java:111)
    at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:47)
    at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:32)
    at org.apache.drill.exec.rpc.RpcBus.handle(RpcBus.java:61)
    at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:233)
    at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:205)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:111)
    at java.lang.Thread.run(Thread.java:745)

Pass your schema name in your database url

而不是运行:-

 String sql = "use dfs.nwssot";
 stmt.executeQuery(sql);

使用以下语法:-

 jdbc:drill:zk=<zookeeper_quorum>/<drill_directory_in_zookeeper>/<cluster_ID>;schema=<schema_to_use_as_default>

请参阅此 link 以获取有关如何创建数据库的进一步说明 url。