drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [12/15] drill git commit: DRILL-4420: C++ API for metadata access and prepared statements
Date Tue, 01 Nov 2016 20:29:57 GMT
http://git-wip-us.apache.org/repos/asf/drill/blob/166c4ce7/contrib/native/client/src/clientlib/drillClientImpl.hpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/drillClientImpl.hpp b/contrib/native/client/src/clientlib/drillClientImpl.hpp
index 06f37e0..f9d0779 100644
--- a/contrib/native/client/src/clientlib/drillClientImpl.hpp
+++ b/contrib/native/client/src/clientlib/drillClientImpl.hpp
@@ -21,7 +21,6 @@
 #define DRILL_CLIENT_IMPL_H
 
 #include "drill/common.hpp"
-
 // Define some BOOST defines
 // WIN32_SHUTDOWN_ON_TIMEOUT is defined in "drill/common.hpp" for Windows 32 bit platform
 #ifndef WIN32_SHUTDOWN_ON_TIMEOUT
@@ -29,27 +28,25 @@
 #endif //WIN32_SHUTDOWN_ON_TIMEOUT
 
 #include <algorithm>
-#include <stdlib.h>
-#include <time.h>
 #include <queue>
 #include <vector>
-#include <boost/asio.hpp>
 
+#include <boost/asio.hpp>
 #if defined _WIN32  || defined _WIN64
-#include <zookeeper.h>
 //Windows header files redefine 'random'
 #ifdef random
 #undef random
 #endif
-#else
-#include <zookeeper/zookeeper.h>
 #endif
 #include <boost/asio/deadline_timer.hpp>
+#include <boost/function.hpp>
 #include <boost/thread.hpp>
 
 #include "drill/drillClient.hpp"
-#include "rpcEncoder.hpp"
-#include "rpcDecoder.hpp"
+#include "drill/preparedStatement.hpp"
+#include "collectionsImpl.hpp"
+#include "metadata.hpp"
+#include "rpcMessage.hpp"
 #include "utils.hpp"
 #include "User.pb.h"
 #include "UserBitShared.pb.h"
@@ -57,11 +54,11 @@
 namespace Drill {
 
 class DrillClientImpl;
-class InBoundRpcMessage;
-class OutBoundRpcMessage;
+
+class DrillClientQueryHandle;
+
+class DrillClientPrepareHandle;
 class RecordBatch;
-class RpcEncoder;
-class RpcDecoder;
 
 /*
  * Defines the interface used by DrillClient and implemented by DrillClientImpl and PooledDrillClientImpl
@@ -89,6 +86,8 @@ class DrillClientImplBase{
 
         // Submits a query to a drillbit. 
         virtual DrillClientQueryResult* SubmitQuery(::exec::shared::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx)=0;
+        virtual DrillClientPrepareHandle* PrepareQuery(const std::string& plan, pfnPreparedStatementListener listener, void* listenerCtx)=0;
+        virtual DrillClientQueryResult* ExecuteQuery(const PreparedStatement& pstmt, pfnQueryResultsListener listener, void* listenerCtx)=0;
 
         //Waits as a connection has results pending
         virtual void waitForResults()=0;
@@ -96,31 +95,109 @@ class DrillClientImplBase{
         //Validates handshake at connect time.
         virtual connectionStatus_t validateHandshake(DrillUserProperties* props)=0;
 
-        virtual void freeQueryResources(DrillClientQueryResult* pQryResult)=0;
+        virtual void freeQueryResources(DrillClientQueryHandle* pQryHandle)=0;
+
+        virtual meta::DrillMetadata* getMetadata() = 0;
 
+        virtual void freeMetadata(meta::DrillMetadata* metadata) = 0;
 };
 
-class DrillClientQueryResult{
+/**
+ * Base type for query handles
+ */
+class DrillClientQueryHandle{
     friend class DrillClientImpl;
     public:
-    DrillClientQueryResult(DrillClientImpl * pClient, uint64_t coordId, const std::string& query):
-        m_pClient(pClient),
+    DrillClientQueryHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, void* context):
+        m_client(client),
         m_coordinationId(coordId),
         m_query(query),
+		m_status(QRY_SUCCESS),
+        m_bCancel(false),
+        m_bHasError(false),
+        m_pError(NULL),
+		m_pApplicationContext(context){
+    };
+
+    virtual ~DrillClientQueryHandle(){
+        clearAndDestroy();
+    };
+
+    virtual void cancel();
+    bool isCancelled() const {return m_bCancel;};
+    int32_t getCoordinationId() const { return m_coordinationId;}
+    const std::string&  getQuery() const { return m_query;}
+
+    bool hasError() const { return m_bHasError;}
+    void resetError() { m_bHasError = false; }
+
+    status_t getErrorStatus() const { return m_pError!=NULL?(status_t)m_pError->status:QRY_SUCCESS;}
+    const DrillClientError* getError() const { return m_pError;}
+    void setQueryStatus(status_t s){ m_status = s;}
+    status_t getQueryStatus() const { return m_status;}
+    inline DrillClientImpl& client() const { return m_client; };
+
+    inline void* getApplicationContext() const { return m_pApplicationContext; }
+
+    protected:
+
+    virtual void signalError(DrillClientError* pErr);
+    virtual void clearAndDestroy();
+
+    private:
+    DrillClientImpl& m_client;
+
+    int32_t m_coordinationId;
+    std::string m_query;
+    status_t m_status;
+    bool m_bCancel;
+    bool m_bHasError;
+
+    const DrillClientError* m_pError;
+
+    void* m_pApplicationContext;
+};
+
+template<typename Listener, typename ListenerValue>
+class DrillClientBaseHandle: public DrillClientQueryHandle {
+    friend class DrillClientImpl;
+    public:
+    DrillClientBaseHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, Listener listener, void* context):
+    	DrillClientQueryHandle(client, coordId, query, context),
+		m_pApplicationListener(listener){
+    };
+
+    virtual ~DrillClientBaseHandle(){
+        clearAndDestroy();
+    };
+
+    inline Listener getApplicationListener() const { return m_pApplicationListener; }
+
+
+    protected:
+    virtual status_t notifyListener(ListenerValue v, DrillClientError* pErr);
+
+    virtual void signalError(DrillClientError* pErr);
+    void setHasError(bool hasError) { m_bHasError = hasError; }
+
+    private:
+    Listener m_pApplicationListener;
+};
+
+class DrillClientQueryResult: public DrillClientBaseHandle<pfnQueryResultsListener, RecordBatch*>{
+    friend class DrillClientImpl;
+    public:
+    DrillClientQueryResult(DrillClientImpl& client, int32_t coordId, const std::string& query, pfnQueryResultsListener listener, void* listenerCtx):
+    	DrillClientBaseHandle<pfnQueryResultsListener, RecordBatch*>(client, coordId, query, listener, listenerCtx),
         m_numBatches(0),
         m_columnDefs(new std::vector<Drill::FieldMetadata*>),
         m_bIsQueryPending(true),
         m_bIsLastChunk(false),
-        m_bCancel(false),
         m_bHasSchemaChanged(false),
         m_bHasData(false),
-        m_bHasError(false),
         m_queryState(exec::shared::QueryResult_QueryState_STARTING),
-        m_pError(NULL),
         m_pQueryId(NULL),
-        m_pSchemaListener(NULL),
-        m_pResultsListener(NULL),
-        m_pListenerCtx(NULL) {
+        m_pSchemaListener(NULL) {
     };
 
     ~DrillClientQueryResult(){
@@ -128,20 +205,15 @@ class DrillClientQueryResult{
     };
 
     // get data asynchronously
-    void registerListener(pfnQueryResultsListener listener, void* listenerCtx){
-        this->m_pResultsListener=listener;
-        this->m_pListenerCtx = listenerCtx;
-    }
-
     void registerSchemaChangeListener(pfnSchemaListener l){
         m_pSchemaListener=l;
     }
 
-    // Synchronous call to get data. Caller assumes ownership of the recod batch
+    // Synchronous call to get data. Caller assumes ownership of the record batch
     // returned and it is assumed to have been consumed.
     RecordBatch*  getNext();
     // Synchronous call to get a look at the next Record Batch. This
-    // call does not move the current pointer forward. Repeatied calls
+    // call does not move the current pointer forward. Repeated calls
     // to peekNext return the same value until getNext is called.
     RecordBatch*  peekNext();
     // Blocks until data is available.
@@ -150,32 +222,26 @@ class DrillClientQueryResult{
     // placeholder to return an empty col def vector when calls are made out of order.
     static FieldDefPtr s_emptyColDefs;
 
-    FieldDefPtr getColumnDefs(){
+    FieldDefPtr getColumnDefs() {
         boost::lock_guard<boost::mutex> bufferLock(this->m_schemaMutex);
         return this->m_columnDefs;
     }
 
-    void cancel();
-    bool isCancelled(){return this->m_bCancel;};
-    bool hasSchemaChanged(){return this->m_bHasSchemaChanged;};
-    int32_t getCoordinationId(){ return this->m_coordinationId;}
-    const std::string&  getQuery(){ return this->m_query;}
+    bool hasSchemaChanged() const {return this->m_bHasSchemaChanged;};
 
     void setQueryId(exec::shared::QueryId* q){this->m_pQueryId=q;}
-    void* getListenerContext() {return this->m_pListenerCtx;}
-    exec::shared::QueryId& getQueryId(){ return *(this->m_pQueryId); }
-    bool hasError(){ return m_bHasError;}
-    status_t getErrorStatus(){ return m_pError!=NULL?(status_t)m_pError->status:QRY_SUCCESS;}
-    const DrillClientError* getError(){ return m_pError;}
-    void setQueryStatus(status_t s){ m_status = s;}
-    status_t getQueryStatus(){ return m_status;}
+    exec::shared::QueryId& getQueryId() const { return *(this->m_pQueryId); }
 
     void setQueryState(exec::shared::QueryResult_QueryState s){ m_queryState = s;}
-    exec::shared::QueryResult_QueryState getQueryState(){ return m_queryState;}
+    exec::shared::QueryResult_QueryState getQueryState() const { return m_queryState;}
     void setIsQueryPending(bool isPending){
         boost::lock_guard<boost::mutex> cvLock(this->m_cvMutex);
         m_bIsQueryPending=isPending;
     }
+    protected:
+    virtual status_t notifyListener(RecordBatch* batch, DrillClientError* pErr);
+    virtual void signalError(DrillClientError* pErr);
+    virtual void clearAndDestroy();
 
     private:
     status_t setupColumnDefs(exec::shared::QueryData* pQueryData);
@@ -183,15 +249,7 @@ class DrillClientQueryResult{
     // Construct a DrillClientError object, set the appropriate state and signal any listeners, condition variables.
     // Also used when a query is cancelled or when a query completed response is received.
     // Error object is now owned by the DrillClientQueryResult object.
-    void signalError(DrillClientError* pErr);
     void signalComplete();
-    void clearAndDestroy();
-
-
-    DrillClientImpl* m_pClient;
-
-    int32_t m_coordinationId;
-    const std::string& m_query;
 
     size_t m_numBatches; // number of record batches received so far
 
@@ -213,28 +271,90 @@ class DrillClientQueryResult{
     // if m_bIsQueryPending is true, we continue to wait for results
     bool m_bIsQueryPending;
     bool m_bIsLastChunk;
-    bool m_bCancel;
     bool m_bHasSchemaChanged;
     bool m_bHasData;
-    bool m_bHasError;
 
     // state in the last query result received from the server.
     exec::shared::QueryResult_QueryState m_queryState;
 
-    const DrillClientError* m_pError;
-
     exec::shared::QueryId* m_pQueryId;
-    status_t m_status;
 
     // Schema change listener
     pfnSchemaListener m_pSchemaListener;
-    // Results callback
-    pfnQueryResultsListener m_pResultsListener;
+};
+
+class DrillClientPrepareHandle: public DrillClientBaseHandle<pfnPreparedStatementListener, PreparedStatement*>, public PreparedStatement {
+    public:
+    DrillClientPrepareHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, pfnPreparedStatementListener listener, void* listenerCtx):
+    	DrillClientBaseHandle<pfnPreparedStatementListener, PreparedStatement*>(client, coordId, query, listener, listenerCtx),
+		PreparedStatement(),
+        m_columnDefs(new std::vector<Drill::FieldMetadata*>) {
+    };
+
+    // PreparedStatement overrides
+	virtual std::size_t getNumFields() const { return m_columnDefs->size(); }
+	virtual const Drill::FieldMetadata& getFieldMetadata(std::size_t index) const { return *m_columnDefs->at(index);}
+
+    protected:
+    virtual void clearAndDestroy();
+
+    private:
+    friend class DrillClientImpl;
+    status_t setupPreparedStatement(const exec::user::PreparedStatement& pstmt);
+
+    FieldDefPtr m_columnDefs;
+    ::exec::user::PreparedStatementHandle m_preparedStatementHandle;
+};
+
+template<typename Listener, typename MetaType, typename MetaImpl, typename MetadataResult>
+class DrillClientMetadataResult: public DrillClientBaseHandle<Listener, const DrillCollection<MetaType>*> {
+public:
+    DrillClientMetadataResult(DrillClientImpl& client, int32_t coordId, const std::string& query, Listener listener, void* listenerCtx):
+    	DrillClientBaseHandle<Listener, const DrillCollection<MetaType>*>(client, coordId, query, listener, listenerCtx) {}
+
+    void attachMetadataResult(MetadataResult* result) { this->m_pMetadata.reset(result); }
+
+private:
+    friend class DrillClientImpl;
+
+    // Meta informations returned to the user, linked to the handle
+    DrillVector<MetaType, MetaImpl> m_meta;
+
+    // to keep a reference on the underlying metadata object, and
+    // make sure it's clean when this handle is destroyed
+    boost::shared_ptr<MetadataResult> m_pMetadata;
+
+};
+
+class DrillClientCatalogResult: public DrillClientMetadataResult<Metadata::pfnCatalogMetadataListener, meta::CatalogMetadata, meta::DrillCatalogMetadata, exec::user::GetCatalogsResp> {
+    friend class DrillClientImpl;
+public:
+    DrillClientCatalogResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnCatalogMetadataListener listener, void* listenerCtx):
+    	DrillClientMetadataResult<Metadata::pfnCatalogMetadataListener, meta::CatalogMetadata, meta::DrillCatalogMetadata, exec::user::GetCatalogsResp>(client, coordId, "getCatalog", listener, listenerCtx) {}
+};
+
+class DrillClientSchemaResult: public DrillClientMetadataResult<Metadata::pfnSchemaMetadataListener, meta::SchemaMetadata, meta::DrillSchemaMetadata, exec::user::GetSchemasResp> {
+    friend class DrillClientImpl;
+public:
+    DrillClientSchemaResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnSchemaMetadataListener listener, void* listenerCtx):
+    	DrillClientMetadataResult<Metadata::pfnSchemaMetadataListener, meta::SchemaMetadata, meta::DrillSchemaMetadata, exec::user::GetSchemasResp>(client, coordId, "getSchemas", listener, listenerCtx) {}
+};
+
+class DrillClientTableResult: public DrillClientMetadataResult<Metadata::pfnTableMetadataListener, meta::TableMetadata, meta::DrillTableMetadata, exec::user::GetTablesResp> {
+    friend class DrillClientImpl;
+public:
+    DrillClientTableResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnTableMetadataListener listener, void* listenerCtx):
+    	DrillClientMetadataResult<Metadata::pfnTableMetadataListener, meta::TableMetadata, meta::DrillTableMetadata, exec::user::GetTablesResp>(client, coordId, "getTables", listener, listenerCtx) {}
+};
 
-    // Listener context
-    void * m_pListenerCtx;
+class DrillClientColumnResult: public DrillClientMetadataResult<Metadata::pfnColumnMetadataListener, meta::ColumnMetadata, meta::DrillColumnMetadata, exec::user::GetColumnsResp> {
+    friend class DrillClientImpl;
+    public:
+    DrillClientColumnResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnColumnMetadataListener listener, void* listenerCtx):
+    	DrillClientMetadataResult<Metadata::pfnColumnMetadataListener, meta::ColumnMetadata, meta::DrillColumnMetadata, exec::user::GetColumnsResp>(client, coordId, "getColumns", listener, listenerCtx) {}
 };
 
+
 class DrillClientImpl : public DrillClientImplBase{
     public:
         DrillClientImpl():
@@ -250,7 +370,8 @@ class DrillClientImpl : public DrillClientImplBase{
             m_deadlineTimer(m_io_service),
             m_heartbeatTimer(m_io_service),
             m_rbuf(NULL),
-            m_wbuf(MAX_SOCK_RD_BUFSIZE)
+            m_wbuf(MAX_SOCK_RD_BUFSIZE),
+			m_bIsDirectConnection(false)
     {
         m_coordinationId=rand()%1729+1;
     };
@@ -300,14 +421,24 @@ class DrillClientImpl : public DrillClientImplBase{
         void Close() ;
         DrillClientError* getError(){ return m_pError;}
         DrillClientQueryResult* SubmitQuery(::exec::shared::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx);
+        DrillClientPrepareHandle* PrepareQuery(const std::string& plan, pfnPreparedStatementListener listener, void* listenerCtx);
+        DrillClientQueryResult* ExecuteQuery(const PreparedStatement& pstmt, pfnQueryResultsListener listener, void* listenerCtx);
+
         void waitForResults();
         connectionStatus_t validateHandshake(DrillUserProperties* props);
-        void freeQueryResources(DrillClientQueryResult* pQryResult){
-            // Doesn't need to do anything
-            return;
+        void freeQueryResources(DrillClientQueryHandle* pQryHandle){
+            delete pQryHandle;
         };
+        
+        const exec::user::RpcEndpointInfos& getServerInfos() const { return m_serverInfos; }
+
+        meta::DrillMetadata* getMetadata();
+
+        void freeMetadata(meta::DrillMetadata* metadata);
 
     private:
+        friend class meta::DrillMetadata;
+        friend class DrillClientQueryHandle;
         friend class DrillClientQueryResult;
         friend class PooledDrillClientImpl;
 
@@ -327,8 +458,8 @@ class DrillClientImpl : public DrillClientImplBase{
 
         int32_t getNextCoordinationId(){ return ++m_coordinationId; };
         // send synchronous messages
-        //connectionStatus_t recvSync(InBoundRpcMessage& msg);
-        connectionStatus_t sendSync(OutBoundRpcMessage& msg);
+        //connectionStatus_t recvSync(rpc::InBoundRpcMessage& msg);
+        connectionStatus_t sendSync(rpc::OutBoundRpcMessage& msg);
         // handshake
         connectionStatus_t recvHandshake();
         void handleHandshake(ByteBuf_t b, const boost::system::error_code& err, std::size_t bytes_transferred );
@@ -340,45 +471,54 @@ class DrillClientImpl : public DrillClientImplBase{
         status_t readMsg(
                 ByteBuf_t _buf,
                 AllocatedBufferPtr* allocatedBuffer,
-                InBoundRpcMessage& msg,
-                boost::system::error_code& error);
-        status_t processQueryResult(AllocatedBufferPtr allocatedBuffer, InBoundRpcMessage& msg);
-        status_t processQueryData(AllocatedBufferPtr allocatedBuffer, InBoundRpcMessage& msg);
+                rpc::InBoundRpcMessage& msg);
+        status_t processQueryResult(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg);
+        status_t processQueryData(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg);
         status_t processCancelledQueryResult( exec::shared::QueryId& qid, exec::shared::QueryResult* qr);
-        status_t processQueryId(AllocatedBufferPtr allocatedBuffer, InBoundRpcMessage& msg );
-        DrillClientQueryResult* findQueryResult(exec::shared::QueryId& qid);
+        status_t processQueryId(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg );
+        status_t processPreparedStatement(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg );
+        status_t processCatalogsResult(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg );
+        status_t processSchemasResult(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg );
+        status_t processTablesResult(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg );
+        status_t processColumnsResult(AllocatedBufferPtr allocatedBuffer, const rpc::InBoundRpcMessage& msg );
+        DrillClientQueryResult* findQueryResult(const exec::shared::QueryId& qid);
         status_t processQueryStatusResult( exec::shared::QueryResult* qr,
                 DrillClientQueryResult* pDrillClientQueryResult);
         void handleReadTimeout(const boost::system::error_code & err);
         void handleRead(ByteBuf_t _buf, const boost::system::error_code & err, size_t bytes_transferred) ;
-        status_t validateDataMessage(InBoundRpcMessage& msg, exec::shared::QueryData& qd, std::string& valError);
-        status_t validateResultMessage(InBoundRpcMessage& msg, exec::shared::QueryResult& qr, std::string& valError);
-        connectionStatus_t handleConnError(connectionStatus_t status, std::string msg);
-        status_t handleQryError(status_t status, std::string msg, DrillClientQueryResult* pQueryResult);
-        status_t handleQryError(status_t status,
-                const exec::shared::DrillPBError& e,
-                DrillClientQueryResult* pQueryResult);
-        // handle query state indicating query is COMPELTED or CANCELED
-        // (i.e., COMPELTED or CANCELED)
+        status_t validateDataMessage(const rpc::InBoundRpcMessage& msg, const exec::shared::QueryData& qd, std::string& valError);
+        status_t validateResultMessage(const rpc::InBoundRpcMessage& msg, const exec::shared::QueryResult& qr, std::string& valError);
+        connectionStatus_t handleConnError(connectionStatus_t status, const std::string& msg);
+        status_t handleQryError(status_t status, const std::string& msg, DrillClientQueryHandle* pQueryHandle);
+        status_t handleQryError(status_t status, const exec::shared::DrillPBError& e, DrillClientQueryHandle* pQueryHandle);
+        // handle query state indicating query is COMPLETED or CANCELED
+        // (i.e., COMPLETED or CANCELED)
         status_t handleTerminatedQryState(status_t status,
-                std::string msg,
+                const std::string& msg,
                 DrillClientQueryResult* pQueryResult);
         void broadcastError(DrillClientError* pErr);
-        void clearMapEntries(DrillClientQueryResult* pQueryResult);
-        void sendAck(InBoundRpcMessage& msg, bool isOk);
-        void sendCancel(exec::shared::QueryId* pQueryId);
+        void removeQueryHandle(DrillClientQueryHandle* pQueryHandle);
+        void removeQueryResult(DrillClientQueryResult* pQueryResult);
+        void sendAck(const rpc::InBoundRpcMessage& msg, bool isOk);
+        void sendCancel(const exec::shared::QueryId* pQueryId);
 
-        void shutdownSocket();
+        template<typename Handle>
+        Handle* sendMsg(boost::function<Handle*(int32_t)> handleFactory, ::exec::user::RpcType type, const ::google::protobuf::Message& msg);
 
+        // metadata requests
+        DrillClientCatalogResult* getCatalogs(const std::string& catalogPattern, Metadata::pfnCatalogMetadataListener listener, void* listenerCtx);
+        DrillClientSchemaResult* getSchemas(const std::string& catalogPattern, const std::string& schemaPattern, Metadata::pfnSchemaMetadataListener listener, void* listenerCtx);
+        DrillClientTableResult* getTables(const std::string& catalogPattern, const std::string& schemaPattern, const std::string& tablePattern, const std::vector<std::string>* tableTypes, Metadata::pfnTableMetadataListener listener, void* listenerCtx);
+        DrillClientColumnResult* getColumns(const std::string& catalogPattern, const std::string& schemaPattern, const std::string& tablePattern, const std::string& columnPattern, Metadata::pfnColumnMetadataListener listener, void* listenerCtx);
 
-        static RpcEncoder s_encoder;
-        static RpcDecoder s_decoder;
+        void shutdownSocket();
 
         int32_t m_coordinationId;
         int32_t m_handshakeVersion;
         exec::user::HandshakeStatus m_handshakeStatus;
         std::string m_handshakeErrorId;
         std::string m_handshakeErrorMsg;
+        exec::user::RpcEndpointInfos m_serverInfos;
         bool m_bIsConnected;
 
         std::string m_connectStr; 
@@ -418,8 +558,8 @@ class DrillClientImpl : public DrillClientImplBase{
         // Mutex to protect drill client operations
         boost::mutex m_dcMutex;
 
-        // Map of coordination id to  Query Ids.
-        std::map<int, DrillClientQueryResult*> m_queryIds;
+        // Map of coordination id to Query handles.
+        std::map<int, DrillClientQueryHandle*> m_queryHandles;
 
         // Map of query id to query result for currently executing queries
         std::map<exec::shared::QueryId*, DrillClientQueryResult*, compareQueryId> m_queryResults;
@@ -431,7 +571,7 @@ class DrillClientImpl : public DrillClientImplBase{
 };
 
 inline bool DrillClientImpl::Active() {
-    return this->m_bIsConnected;;
+    return this->m_bIsConnected;
 }
 
 
@@ -442,17 +582,17 @@ inline bool DrillClientImpl::Active() {
  * */
 class PooledDrillClientImpl : public DrillClientImplBase{
     public:
-        PooledDrillClientImpl(){
-            m_bIsDirectConnection=false;
-            m_maxConcurrentConnections = DEFAULT_MAX_CONCURRENT_CONNECTIONS;
+        PooledDrillClientImpl():
+        	m_lastConnection(-1),
+			m_queriesExecuted(0),
+			m_maxConcurrentConnections(DEFAULT_MAX_CONCURRENT_CONNECTIONS),
+			m_bIsDirectConnection(false),
+			m_pError(NULL),
+			m_pUserProperties() {
             char* maxConn=std::getenv(MAX_CONCURRENT_CONNECTIONS_ENV);
             if(maxConn!=NULL){
                 m_maxConcurrentConnections=atoi(maxConn);
             }
-            m_lastConnection=-1;
-            m_pError=NULL;
-            m_queriesExecuted=0;
-            m_pUserProperties=NULL;
         }
 
         ~PooledDrillClientImpl(){
@@ -460,7 +600,6 @@ class PooledDrillClientImpl : public DrillClientImplBase{
                 delete *it;
             }
             m_clientConnections.clear();
-            if(m_pUserProperties!=NULL){ delete m_pUserProperties; m_pUserProperties=NULL;}
             if(m_pError!=NULL){ delete m_pError; m_pError=NULL;}
         }
 
@@ -482,15 +621,22 @@ class PooledDrillClientImpl : public DrillClientImplBase{
         // Connections once added to the pool will be removed only when the DrillClient is closed.
         DrillClientQueryResult* SubmitQuery(::exec::shared::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx);
 
+        DrillClientPrepareHandle* PrepareQuery(const std::string& plan, pfnPreparedStatementListener listener, void* listenerCtx);
+        DrillClientQueryResult* ExecuteQuery(const PreparedStatement& pstmt, pfnQueryResultsListener listener, void* listenerCtx);
+
         //Waits as long as any one drillbit connection has results pending
         void waitForResults();
 
         //Validates handshake only against the first drillbit connected to.
         connectionStatus_t validateHandshake(DrillUserProperties* props);
 
-        void freeQueryResources(DrillClientQueryResult* pQryResult);
+        void freeQueryResources(DrillClientQueryHandle* pQueryHandle);
+
+        int getDrillbitCount() const { return m_drillbits.size();};
+        
+        meta::DrillMetadata* getMetadata();
 
-        int getDrillbitCount(){ return m_drillbits.size();};
+        void freeMetadata(meta::DrillMetadata* metadata);
 
     private:
         
@@ -502,9 +648,6 @@ class PooledDrillClientImpl : public DrillClientImplBase{
         // is currently executing. If none,  
         std::vector<DrillClientImpl*> m_clientConnections; 
 		boost::mutex m_poolMutex; // protect access to the vector
-        
-        //ZookeeperImpl zook;
-        
         // Use this to decide which drillbit to select next from the list of drillbits.
         size_t m_lastConnection;
 		boost::mutex m_cMutex;
@@ -524,44 +667,7 @@ class PooledDrillClientImpl : public DrillClientImplBase{
 
         std::vector<std::string> m_drillbits;
 
-        DrillUserProperties* m_pUserProperties;//Keep a copy of user properties
-};
-
-class ZookeeperImpl{
-    public:
-        ZookeeperImpl();
-        ~ZookeeperImpl();
-        static ZooLogLevel getZkLogLevel();
-        // comma separated host:port pairs, each corresponding to a zk
-        // server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002
-        DEPRECATED int connectToZookeeper(const char* connectStr, const char* pathToDrill);
-        void close();
-        static void watcher(zhandle_t *zzh, int type, int state, const char *path, void* context);
-        void debugPrint();
-        std::string& getError(){return m_err;}
-        const exec::DrillbitEndpoint& getEndPoint(){ return m_drillServiceInstance.endpoint();}
-        // return unshuffled list of drillbits
-        int getAllDrillbits(const char* connectStr, const char* pathToDrill, std::vector<std::string>& drillbits);
-        // picks the index drillbit and returns the corresponding endpoint object
-        int getEndPoint(std::vector<std::string>& drillbits, size_t index, exec::DrillbitEndpoint& endpoint);
-        
-
-    private:
-        static char s_drillRoot[];
-        static char s_defaultCluster[];
-        zhandle_t* m_zh;
-        clientid_t m_id;
-        int m_state;
-        std::string m_err;
-
-        struct String_vector* m_pDrillbits;
-
-        boost::mutex m_cvMutex;
-        // Condition variable to signal connection callback has been processed
-        boost::condition_variable m_cv;
-        bool m_bConnecting;
-        exec::DrillServiceInstance m_drillServiceInstance;
-        std::string m_rootDir;
+        boost::shared_ptr<DrillUserProperties> m_pUserProperties;//Keep a copy of user properties
 };
 
 } // namespace Drill

http://git-wip-us.apache.org/repos/asf/drill/blob/166c4ce7/contrib/native/client/src/clientlib/env.h.in
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/env.h.in b/contrib/native/client/src/clientlib/env.h.in
index a32f152..746a500 100644
--- a/contrib/native/client/src/clientlib/env.h.in
+++ b/contrib/native/client/src/clientlib/env.h.in
@@ -19,6 +19,15 @@
 #ifndef ENV_H
 #define ENV_H
 
+#define DRILL_NAME              "Apache Drill"
+#define DRILL_CONNECTOR_NAME    "Apache Drill C++ client"
+#define DRILL_VERSION_STRING    "@PROJECT_VERSION@"
+
+#define DRILL_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+#define DRILL_VERSION_MINOR @PROJECT_VERSION_MINOR@
+#define DRILL_VERSION_PATCH @PROJECT_VERSION_PATCH@
+
+#define GIT_SHA_PROP  @GIT_SHA_PROP@
 #define GIT_COMMIT_PROP @GIT_COMMIT_PROP@
 
 #endif

http://git-wip-us.apache.org/repos/asf/drill/blob/166c4ce7/contrib/native/client/src/clientlib/errmsgs.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/errmsgs.cpp b/contrib/native/client/src/clientlib/errmsgs.cpp
index 47d165f..56510ec 100644
--- a/contrib/native/client/src/clientlib/errmsgs.cpp
+++ b/contrib/native/client/src/clientlib/errmsgs.cpp
@@ -74,7 +74,7 @@ static Drill::ErrorMessages errorMessages[]={
 std::string getMessage(uint32_t msgId, ...){
     char str[10240];
     std::string s;
-    assert(msgId <= ERR_QRY_MAX);
+    assert((ERR_NONE <= msgId) && (msgId < ERR_QRY_MAX));
     va_list args;
     va_start (args, msgId);
     vsprintf (str, errorMessages[msgId-DRILL_ERR_START].msgFormatStr, args);

http://git-wip-us.apache.org/repos/asf/drill/blob/166c4ce7/contrib/native/client/src/clientlib/fieldmeta.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/fieldmeta.cpp b/contrib/native/client/src/clientlib/fieldmeta.cpp
new file mode 100644
index 0000000..d9d6bd1
--- /dev/null
+++ b/contrib/native/client/src/clientlib/fieldmeta.cpp
@@ -0,0 +1,406 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "drill/common.hpp"
+#include "drill/fieldmeta.hpp"
+#include "../protobuf/UserBitShared.pb.h"
+#include "../protobuf/User.pb.h"
+
+namespace {
+// List of SQL types as string constants
+static std::string SQLAny("ANY");
+static std::string SQLArray("ARRAY");
+static std::string SQLBigint("BIGINT");
+static std::string SQLBinary("BINARY");
+static std::string SQLBoolean("BOOLEAN");
+static std::string SQLChar("CHARACTER");
+static std::string SQLDate("DATE");
+static std::string SQLDecimal("DECIMAL");
+static std::string SQLDouble("DOUBLE");
+static std::string SQLFloat("FLOAT");
+static std::string SQLInteger("INTEGER");
+static std::string SQLInterval("INTERVAL");
+static std::string SQLIntervalYearMonth("INTERVAL YEAR TO MONTH");
+static std::string SQLIntervalDaySecond("INTERVAL DAY TO SECOND");
+static std::string SQLNChar("NATIONAL CHARACTER");
+static std::string SQLNull("NULL");
+static std::string SQLMap("MAP");
+static std::string SQLSmallint("SMALLINT");
+static std::string SQLTime("TIME");
+static std::string SQLTimestamp("TIMESTAMP");
+static std::string SQLTimestampTZ("TIMESTAMP WITH TIME ZONE");
+static std::string SQLTimeTZ("TIME WITH TIME ZONE");
+static std::string SQLTinyint("TINYINT");
+static std::string SQLUnion("UNION");
+static std::string SQLVarbinary("BINARY VARYING");
+static std::string SQLVarchar("CHARACTER VARYING");
+static std::string SQLVarnchar("NATIONAL CHARACTER VARYING");
+static std::string SQLUnknown("__unknown__");
+
+static const std::string& getSQLType(common::MinorType type, common::DataMode mode) {
+  if (mode == common::DM_REPEATED || type == common::LIST) {
+    return SQLArray;
+  }
+
+  switch(type) {
+    case common::BIT:             return SQLBoolean;
+
+    case common::TINYINT:         return SQLTinyint;
+    case common::SMALLINT:        return SQLSmallint;
+    case common::INT:             return SQLInteger;
+    case common::BIGINT:          return SQLBigint;
+    case common::FLOAT4:          return SQLFloat;
+    case common::FLOAT8:          return SQLDouble;
+
+    case common::DECIMAL9:
+    case common::DECIMAL18:
+    case common::DECIMAL28DENSE:
+    case common::DECIMAL28SPARSE:
+    case common::DECIMAL38DENSE:
+    case common::DECIMAL38SPARSE: return SQLDecimal;
+
+    case common::VARCHAR:         return SQLVarchar;
+    case common::FIXEDCHAR:       return SQLChar;
+
+    case common::VAR16CHAR:       return SQLVarnchar;
+    case common::FIXED16CHAR:     return SQLNChar;
+
+    case common::VARBINARY:       return SQLVarbinary;
+    case common::FIXEDBINARY:     return SQLBinary;
+
+    case common::DATE:            return SQLDate;
+    case common::TIME:            return SQLTime;
+    case common::TIMETZ:          return SQLTimeTZ;
+    case common::TIMESTAMP:       return SQLTimestamp;
+    case common::TIMESTAMPTZ:     return SQLTimestampTZ;
+
+    case common::INTERVALYEAR:    return SQLIntervalYearMonth;
+    case common::INTERVALDAY:     return SQLIntervalDaySecond;
+    case common::INTERVAL:        return SQLInterval;
+    case common::MONEY:           return SQLDecimal;
+
+    case common::MAP:             return SQLMap;
+    case common::LATE:            return SQLAny;
+    case common::DM_UNKNOWN:      return SQLNull;
+    case common::UNION:           return SQLUnion;
+
+    case common::UINT1:           return SQLTinyint;
+    case common::UINT2:           return SQLSmallint;
+    case common::UINT4:           return SQLInteger;
+    case common::UINT8:           return SQLBigint;
+
+    default:
+      return SQLUnknown;
+  }
+}
+
+static bool isSortable(common::MinorType type) {
+  return type != common::MAP && type != common::LIST;
+}
+
+static bool isNullable(common::DataMode mode) {
+  return mode == common::DM_OPTIONAL; // Same behaviour as JDBC
+}
+
+static bool isSigned(common::MinorType type, common::DataMode mode) {
+  if (mode == common::DM_REPEATED) {
+    return false;// SQL ARRAY
+  }
+
+  switch(type) {
+    case common::SMALLINT:
+    case common::INT:
+    case common::BIGINT:
+    case common::FLOAT4:
+    case common::FLOAT8:
+
+    case common::DECIMAL9:
+    case common::DECIMAL18:
+    case common::DECIMAL28DENSE:
+    case common::DECIMAL38DENSE:
+    case common::DECIMAL38SPARSE:
+
+    case common::INTERVALYEAR:
+    case common::INTERVALDAY:
+    case common::INTERVAL:
+    case common::MONEY:
+    case common::TINYINT:
+      return true;
+
+    case common::BIT:
+    case common::VARCHAR:
+    case common::FIXEDCHAR:
+
+    case common::VAR16CHAR:
+    case common::FIXED16CHAR:
+
+    case common::VARBINARY:
+    case common::FIXEDBINARY:
+
+    case common::DATE:
+    case common::TIME:
+    case common::TIMETZ:
+    case common::TIMESTAMP:
+    case common::TIMESTAMPTZ:
+
+    case common::MAP:
+    case common::LATE:
+    case common::DM_UNKNOWN:
+    case common::UNION:
+
+    case common::UINT1:
+    case common::UINT2:
+    case common::UINT4:
+    case common::UINT8:
+      return false;
+
+    default:
+      return false;
+  }
+}
+
+static Drill::FieldMetadata::ColumnSearchability getSearchability(exec::user::ColumnSearchability s) {
+  switch(s) {
+    case exec::user::UNKNOWN_SEARCHABILITY: return Drill::FieldMetadata::UNKNOWN_SEARCHABILITY;
+    case exec::user::NONE:                  return Drill::FieldMetadata::NONE;
+    case exec::user::CHAR:                  return Drill::FieldMetadata::CHAR;
+    case exec::user::NUMBER:                return Drill::FieldMetadata::NUMBER;
+    case exec::user::ALL:                   return Drill::FieldMetadata::ALL;
+
+    default:
+      return Drill::FieldMetadata::UNKNOWN_SEARCHABILITY;
+  }
+}
+
+static Drill::FieldMetadata::ColumnUpdatability getUpdatability(exec::user::ColumnUpdatability u) {
+  switch(u) {
+    case exec::user::UNKNOWN_UPDATABILITY: return Drill::FieldMetadata::UNKNOWN_UPDATABILITY;
+    case exec::user::READ_ONLY:            return Drill::FieldMetadata::READ_ONLY;
+    case exec::user::WRITABLE:             return Drill::FieldMetadata::WRITABLE;
+
+    default:
+      return Drill::FieldMetadata::UNKNOWN_UPDATABILITY;
+  }
+}
+
+// Based on ODBC spec
+// https://msdn.microsoft.com/en-us/library/ms711786(v=vs.85).aspx
+static uint32_t getColumnSize(const std::string& type, uint32_t precision) {
+	if (type == SQLBoolean) {
+		return 1;
+	}
+	else if (type == SQLTinyint) {
+		return 3;
+	}
+	else if (type == SQLSmallint) {
+		return 5;
+	}
+	else if (type == SQLInteger) {
+		return 10;
+	}
+	else if (type == SQLBigint) {
+		return 19;
+	}
+	else if (type == SQLFloat) {
+		return 7;
+	}
+	else if (type == SQLDouble) {
+		return 15;
+	}
+	else if (type == SQLDecimal) {
+		return precision;
+	}
+	else if (type == SQLBinary || type == SQLVarbinary
+			|| type == SQLChar || type == SQLVarchar
+			|| type == SQLNChar || type == SQLVarnchar) {
+		return precision;
+	}
+	else if (type == SQLDate) {
+		return 10; // 'yyyy-MM-dd' format
+	}
+	else if (type == SQLTime) {
+		if (precision > 0) {
+			return 9 + precision;
+		}
+		else return 8; // 'hh-mm-ss' format
+	}
+	else if (type == SQLTimestamp) {
+		return (precision > 0)
+			? 20 + precision
+			: 19; // 'yyyy-MM-ddThh-mm-ss' format
+	}
+	else if (type == SQLIntervalYearMonth) {
+		return (precision > 0)
+				? 5 + precision // P..M31
+				: 0; // if precision is not set, return 0 because there's not enough info
+	}
+	else if (type == SQLIntervalDaySecond) {
+		return (precision > 0)
+			? 12 + precision // P..DT12H60M60....S
+			: 0; // if precision is not set, return 0 because there's not enough info
+	}
+	else {
+		return 0;
+	}
+}
+
+static uint32_t getPrecision(const ::common::MajorType& type) {
+	const ::common::MinorType& minor_type = type.minor_type();
+
+	if (type.has_precision()) {
+		return type.precision();
+	}
+
+	if (minor_type == ::common::VARBINARY || minor_type == ::common::VARCHAR) {
+		return 65536;
+	}
+
+	return 0;
+}
+
+// From Types.java
+// Based on ODBC spec:
+// https://msdn.microsoft.com/en-us/library/ms713974(v=vs.85).aspx
+static uint32_t getDisplaySize(const ::common::MajorType& type) {
+    if (type.mode() == ::common::DM_REPEATED || type.minor_type() == ::common::LIST) {
+      return 0;
+    }
+
+    uint32_t precision = getPrecision(type);
+
+    switch(type.minor_type()) {
+    case ::common::BIT:             return 1; // 1 digit
+
+    case ::common::TINYINT:         return 4; // sign + 3 digit
+    case ::common::SMALLINT:        return 6; // sign + 5 digits
+    case ::common::INT:             return 11; // sign + 10 digits
+    case ::common::BIGINT:          return 20; // sign + 19 digits
+
+    case ::common::UINT1:          return 3; // 3 digits
+    case ::common::UINT2:          return 5; // 5 digits
+    case ::common::UINT4:          return 10; // 10 digits
+    case ::common::UINT8:          return 19; // 19 digits
+
+    case ::common::FLOAT4:          return 14; // sign + 7 digits + decimal point + E + 2 digits
+    case ::common::FLOAT8:          return 24; // sign + 15 digits + decimal point + E + 3 digits
+
+    case ::common::DECIMAL9:
+    case ::common::DECIMAL18:
+    case ::common::DECIMAL28DENSE:
+    case ::common::DECIMAL28SPARSE:
+    case ::common::DECIMAL38DENSE:
+    case ::common::DECIMAL38SPARSE:
+    case ::common::MONEY:           return 2 + precision; // precision of the column plus a sign and a decimal point
+
+    case ::common::VARCHAR:
+    case ::common::FIXEDCHAR:
+    case ::common::VAR16CHAR:
+    case ::common::FIXED16CHAR:     return precision; // number of characters
+
+    case ::common::VARBINARY:
+    case ::common::FIXEDBINARY:     return 2 * precision; // each binary byte is represented as a 2digit hex number
+
+    case ::common::DATE:            return 10; // yyyy-mm-dd
+    case ::common::TIME:
+      return precision > 0
+        ? 9 + precision // hh-mm-ss.SSS
+        : 8; // hh-mm-ss
+    case ::common::TIMETZ:
+      return precision > 0
+        ? 15 + precision // hh-mm-ss.SSS-zz:zz
+        : 14; // hh-mm-ss-zz:zz
+    case ::common::TIMESTAMP:
+      return precision > 0
+         ? 20 + precision // yyyy-mm-ddThh:mm:ss.SSS
+         : 19; // yyyy-mm-ddThh:mm:ss
+    case ::common::TIMESTAMPTZ:
+      return precision > 0
+        ? 26 + precision // yyyy-mm-ddThh:mm:ss.SSS:ZZ-ZZ
+        : 25; // yyyy-mm-ddThh:mm:ss-ZZ:ZZ
+
+    case ::common::INTERVALYEAR:
+      return precision > 0
+          ? 5 + precision // P..Y12M
+          : 0; // if precision is not set, return 0 because there's not enough info
+
+    case ::common::INTERVALDAY:
+      return precision > 0
+          ? 12 + precision // P..DT12H60M60S assuming fractional seconds precision is not supported
+          : 0; // if precision is not set, return 0 because there's not enough info
+
+    default:
+    	// We don't know how to compute a display size, let's return 0 (unknown)
+    	return 0;
+}
+}
+} // namespace
+
+namespace Drill{
+
+void FieldMetadata::set(const exec::shared::SerializedField& f){
+    m_name=f.name_part().name();
+    m_minorType=f.major_type().minor_type();
+    m_dataMode=f.major_type().mode();
+    m_valueCount=f.value_count();
+    m_scale=f.major_type().scale();
+    m_precision=f.major_type().precision();
+    m_bufferLength=f.buffer_length();
+    m_catalogName="DRILL";
+    m_schemaName=""; // unknown
+    m_tableName=""; // unknown;
+    m_label=m_name;
+    m_sqlType=::getSQLType(m_minorType, m_dataMode);
+    m_nullable=::isNullable(m_dataMode);
+    m_signed=::isSigned(m_minorType, m_dataMode);
+    m_displaySize=::getDisplaySize(f.major_type());
+    m_searchability=ALL;
+    m_updatability=READ_ONLY;
+    m_autoIncremented=false;
+    m_caseSensitive=false;
+    m_sortable=::isSortable(m_minorType);
+    m_currency=false;
+    m_columnSize = ::getColumnSize(m_sqlType, m_precision);
+}
+
+void FieldMetadata::set(const exec::user::ResultColumnMetadata& m){
+    m_name=m.column_name();
+    m_minorType=static_cast<common::MinorType>(-1);
+    m_dataMode=static_cast<common::DataMode>(-1);
+    m_valueCount=0;
+    m_scale=m.scale();
+    m_precision=m.precision();
+    m_bufferLength=0;
+    m_catalogName=m.catalog_name();
+    m_schemaName=m.schema_name();
+    m_tableName=m.table_name();
+    m_label=m.label();
+    m_sqlType=m.data_type();
+    m_nullable=m.is_nullable();
+    m_displaySize=m.display_size();
+    m_signed=m.signed_();
+    m_searchability=::getSearchability(m.searchability());
+    m_updatability=::getUpdatability(m.updatability());
+    m_autoIncremented=m.auto_increment();
+    m_caseSensitive=m.case_sensitivity();
+    m_sortable=m.sortable();
+    m_currency=m.is_currency();
+    m_columnSize =::getColumnSize(m_sqlType, m_precision);
+}
+
+}// namespace Drill
+

http://git-wip-us.apache.org/repos/asf/drill/blob/166c4ce7/contrib/native/client/src/clientlib/metadata.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/metadata.cpp b/contrib/native/client/src/clientlib/metadata.cpp
new file mode 100644
index 0000000..0364c7d
--- /dev/null
+++ b/contrib/native/client/src/clientlib/metadata.cpp
@@ -0,0 +1,748 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <boost/assign.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/unordered_set.hpp>
+#include "drillClientImpl.hpp"
+
+#include "metadata.hpp"
+
+const std::string Drill::meta::DrillMetadata::s_connectorName(DRILL_CONNECTOR_NAME);
+const std::string Drill::meta::DrillMetadata::s_connectorVersion(DRILL_VERSION_STRING);
+
+const std::string Drill::meta::DrillMetadata::s_catalogSeparator(".");
+const std::string Drill::meta::DrillMetadata::s_catalogTerm("catalog");
+const std::string Drill::meta::DrillMetadata::s_identifierQuoteString("`");
+
+const std::vector<std::string> Drill::meta::DrillMetadata::s_sqlKeywords = boost::assign::list_of
+		("ABS")("ALLOW")("ARRAY")("ASENSITIVE")("ASYMMETRIC")("ATOMIC")("BIGINT")("BINARY")("BLOB")
+		("BOOLEAN")("CALL")("CALLED")("CARDINALITY")("CEIL")("CEILING")("CLOB")("COLLECT")("CONDITION")
+		("CORR")("COVAR_POP")("COVAR_SAMP")("CUBE")("CUME_DIST")("CURRENT_CATALOG")
+		("CURRENT_DEFAULT_TRANSFORM_GROUP")("CURRENT_PATH")("CURRENT_ROLE")("CURRENT_SCHEMA")
+		("CURRENT_TRANSFORM_GROUP_FOR_TYPE")("CYCLE")("DATABASE")("DATABASES")("DENSE_RANK")("DEREF")
+		("DETERMINISTIC")("DISALLOW")("DYNAMIC")("EACH")("ELEMENT")("EVERY")("EXP")("EXPLAIN")
+		("EXTEND")("FILES")("FILTER")("FIRST_VALUE")("FLOOR")("FREE")("FUNCTION")("FUSION")("GROUPING")
+		("HOLD")("IF")("IMPORT")("INOUT")("INTERSECTION")("LARGE")("LAST_VALUE")("LATERAL")("LIMIT")("LN")
+		("LOCALTIME")("LOCALTIMESTAMP")("MEMBER")("MERGE")("METADATA")("METHOD")("MOD")("MODIFIES")
+		("MULTISET")("NCLOB")("NEW")("NONE")("NORMALIZE")("OFFSET")("OLD")("OUT")("OVER")("OVERLAY")
+		("PARAMETER")("PARTITION")("PERCENTILE_CONT")("PERCENTILE_DISC")("PERCENT_RANK")("POWER")
+		("RANGE")("RANK")("READS")("RECURSIVE")("REF")("REFERENCING")("REFRESH")("REGR_AVGX")("REGR_AVGY")
+		("REGR_COUNT")("REGR_INTERCEPT")("REGR_R2")("REGR_SLOPE")("REGR_SXX")("REGR_SXY")("REGR_SYY")
+		("RELEASE")("REPLACE")("RESET")("RESULT")("RETURN")("RETURNS")("ROLLUP")("ROW")("ROW_NUMBER")
+		("SAVEPOINT")("SCHEMAS")("SCOPE")("SEARCH")("SENSITIVE")("SHOW")("SIMILAR")("SPECIFIC")("SPECIFICTYPE")
+		("SQLEXCEPTION")("SQLWARNING")("SQRT")("START")("STATIC")("STDDEV_POP")("STDDEV_SAMP")("STREAM")
+		("SUBMULTISET")("SYMMETRIC")("SYSTEM")("TABLES")("TABLESAMPLE")("TINYINT")("TREAT")("TRIGGER")
+		("UESCAPE")("UNNEST")("UPSERT")("USE")("VARBINARY")("VAR_POP")("VAR_SAMP")("WIDTH_BUCKET")
+		("WINDOW")("WITHIN")("WITHOUT");
+
+const std::vector<std::string> Drill::meta::DrillMetadata::s_numericFunctions = boost::assign::list_of
+		("ABS")("ACOS")("ASIN")("ATAN")("ATAN2")("CEILING")("COS")("COT")
+		("DEGREES")("EXP")("FLOOR")("LOG")("LOG10")("MOD")("PI")
+		("POWER")("RADIANS")("RAND")("ROUND")("SIGN")("SIN")("SQRT")
+		("TAN")("TRUNCATE");
+
+const std::string Drill::meta::DrillMetadata::s_schemaTerm("schema");
+const std::string Drill::meta::DrillMetadata::s_searchEscapeString("\\");
+const std::string Drill::meta::DrillMetadata::s_specialCharacters;
+
+const std::vector<std::string> Drill::meta::DrillMetadata::s_stringFunctions = boost::assign::list_of
+		("ASCII")("CHAR")("CONCAT")("DIFFERENCE")("INSERT")("LCASE")
+		("LEFT")("LENGTH")("LOCATE")("LTRIM")("REPEAT")("REPLACE")
+		("RIGHT")("RTRIM")("SOUNDEX")("SPACE")("SUBSTRING")("UCASE");
+
+const std::vector<std::string> Drill::meta::DrillMetadata::s_systemFunctions = boost::assign::list_of
+		("DATABASE")("IFNULL")("USER");
+
+const std::string Drill::meta::DrillMetadata::s_tableTerm("table");
+
+const std::vector<std::string> Drill::meta::DrillMetadata::s_dateTimeFunctions = boost::assign::list_of
+		("CURDATE")("CURTIME")("DAYNAME")("DAYOFMONTH")("DAYOFWEEK")
+		("DAYOFYEAR")("HOUR")("MINUTE")("MONTH")("MONTHNAME")("NOW")
+		("QUARTER")("SECOND")("TIMESTAMPADD")("TIMESTAMPDIFF")("WEEK")("YEAR");
+
+namespace Drill {
+namespace meta {
+namespace {
+using boost::assign::list_of;
+
+struct FromTo {
+	FromTo(common::MinorType from, common::MinorType to): m_from(from), m_to(to) {}
+
+	common::MinorType m_from;
+	common::MinorType m_to;
+};
+
+bool operator==(FromTo const& ft1, FromTo const& ft2) {
+	return ft1.m_from == ft2.m_from && ft1.m_to == ft2.m_to;
+}
+
+std::size_t hash_value(FromTo const& ft) {
+	std::size_t hash = 0;
+	boost::hash_combine(hash, ft.m_from);
+	boost::hash_combine(hash, ft.m_to);
+
+	return hash;
+}
+
+static boost::unordered_set<FromTo> s_convertMap = boost::assign::list_of
+		(FromTo(common::TINYINT, common::INT))
+		(FromTo(common::TINYINT, common::BIGINT))
+		(FromTo(common::TINYINT, common::DECIMAL9))
+		(FromTo(common::TINYINT, common::DECIMAL18))
+		(FromTo(common::TINYINT, common::DECIMAL28SPARSE))
+		(FromTo(common::TINYINT, common::DECIMAL38SPARSE))
+		(FromTo(common::TINYINT, common::DATE))
+		(FromTo(common::TINYINT, common::TIME))
+		(FromTo(common::TINYINT, common::TIMESTAMP))
+		(FromTo(common::TINYINT, common::INTERVAL))
+		(FromTo(common::TINYINT, common::FLOAT4))
+		(FromTo(common::TINYINT, common::FLOAT8))
+		(FromTo(common::TINYINT, common::BIT))
+		(FromTo(common::TINYINT, common::VARCHAR))
+		(FromTo(common::TINYINT, common::VAR16CHAR))
+		(FromTo(common::TINYINT, common::VARBINARY))
+		(FromTo(common::TINYINT, common::INTERVALYEAR))
+		(FromTo(common::TINYINT, common::INTERVALDAY))
+		(FromTo(common::SMALLINT, common::INT))
+		(FromTo(common::SMALLINT, common::BIGINT))
+		(FromTo(common::SMALLINT, common::DECIMAL9))
+		(FromTo(common::SMALLINT, common::DECIMAL18))
+		(FromTo(common::SMALLINT, common::DECIMAL28SPARSE))
+		(FromTo(common::SMALLINT, common::DECIMAL38SPARSE))
+		(FromTo(common::SMALLINT, common::DATE))
+		(FromTo(common::SMALLINT, common::TIME))
+		(FromTo(common::SMALLINT, common::TIMESTAMP))
+		(FromTo(common::SMALLINT, common::INTERVAL))
+		(FromTo(common::SMALLINT, common::FLOAT4))
+		(FromTo(common::SMALLINT, common::FLOAT8))
+		(FromTo(common::SMALLINT, common::BIT))
+		(FromTo(common::SMALLINT, common::VARCHAR))
+		(FromTo(common::SMALLINT, common::VAR16CHAR))
+		(FromTo(common::SMALLINT, common::VARBINARY))
+		(FromTo(common::SMALLINT, common::INTERVALYEAR))
+		(FromTo(common::SMALLINT, common::INTERVALDAY))
+		(FromTo(common::INT, common::INT))
+		(FromTo(common::INT, common::BIGINT))
+		(FromTo(common::INT, common::DECIMAL9))
+		(FromTo(common::INT, common::DECIMAL18))
+		(FromTo(common::INT, common::DECIMAL28SPARSE))
+		(FromTo(common::INT, common::DECIMAL38SPARSE))
+		(FromTo(common::INT, common::DATE))
+		(FromTo(common::INT, common::TIME))
+		(FromTo(common::INT, common::TIMESTAMP))
+		(FromTo(common::INT, common::INTERVAL))
+		(FromTo(common::INT, common::FLOAT4))
+		(FromTo(common::INT, common::FLOAT8))
+		(FromTo(common::INT, common::BIT))
+		(FromTo(common::INT, common::VARCHAR))
+		(FromTo(common::INT, common::VAR16CHAR))
+		(FromTo(common::INT, common::VARBINARY))
+		(FromTo(common::INT, common::INTERVALYEAR))
+		(FromTo(common::INT, common::INTERVALDAY))
+		(FromTo(common::BIGINT, common::INT))
+		(FromTo(common::BIGINT, common::BIGINT))
+		(FromTo(common::BIGINT, common::DECIMAL9))
+		(FromTo(common::BIGINT, common::DECIMAL18))
+		(FromTo(common::BIGINT, common::DECIMAL28SPARSE))
+		(FromTo(common::BIGINT, common::DECIMAL38SPARSE))
+		(FromTo(common::BIGINT, common::DATE))
+		(FromTo(common::BIGINT, common::TIME))
+		(FromTo(common::BIGINT, common::TIMESTAMP))
+		(FromTo(common::BIGINT, common::INTERVAL))
+		(FromTo(common::BIGINT, common::FLOAT4))
+		(FromTo(common::BIGINT, common::FLOAT8))
+		(FromTo(common::BIGINT, common::BIT))
+		(FromTo(common::BIGINT, common::VARCHAR))
+		(FromTo(common::BIGINT, common::VAR16CHAR))
+		(FromTo(common::BIGINT, common::VARBINARY))
+		(FromTo(common::BIGINT, common::INTERVALYEAR))
+		(FromTo(common::BIGINT, common::INTERVALDAY))
+		(FromTo(common::DECIMAL9, common::INT))
+		(FromTo(common::DECIMAL9, common::BIGINT))
+		(FromTo(common::DECIMAL9, common::DECIMAL9))
+		(FromTo(common::DECIMAL9, common::DECIMAL18))
+		(FromTo(common::DECIMAL9, common::DECIMAL28SPARSE))
+		(FromTo(common::DECIMAL9, common::DECIMAL38SPARSE))
+		(FromTo(common::DECIMAL9, common::DATE))
+		(FromTo(common::DECIMAL9, common::TIME))
+		(FromTo(common::DECIMAL9, common::TIMESTAMP))
+		(FromTo(common::DECIMAL9, common::INTERVAL))
+		(FromTo(common::DECIMAL9, common::FLOAT4))
+		(FromTo(common::DECIMAL9, common::FLOAT8))
+		(FromTo(common::DECIMAL9, common::BIT))
+		(FromTo(common::DECIMAL9, common::VARCHAR))
+		(FromTo(common::DECIMAL9, common::VAR16CHAR))
+		(FromTo(common::DECIMAL9, common::VARBINARY))
+		(FromTo(common::DECIMAL9, common::INTERVALYEAR))
+		(FromTo(common::DECIMAL9, common::INTERVALDAY))
+		(FromTo(common::DECIMAL18, common::INT))
+		(FromTo(common::DECIMAL18, common::BIGINT))
+		(FromTo(common::DECIMAL18, common::DECIMAL9))
+		(FromTo(common::DECIMAL18, common::DECIMAL18))
+		(FromTo(common::DECIMAL18, common::DECIMAL28SPARSE))
+		(FromTo(common::DECIMAL18, common::DECIMAL38SPARSE))
+		(FromTo(common::DECIMAL18, common::DATE))
+		(FromTo(common::DECIMAL18, common::TIME))
+		(FromTo(common::DECIMAL18, common::TIMESTAMP))
+		(FromTo(common::DECIMAL18, common::INTERVAL))
+		(FromTo(common::DECIMAL18, common::FLOAT4))
+		(FromTo(common::DECIMAL18, common::FLOAT8))
+		(FromTo(common::DECIMAL18, common::BIT))
+		(FromTo(common::DECIMAL18, common::VARCHAR))
+		(FromTo(common::DECIMAL18, common::VAR16CHAR))
+		(FromTo(common::DECIMAL18, common::VARBINARY))
+		(FromTo(common::DECIMAL18, common::INTERVALYEAR))
+		(FromTo(common::DECIMAL18, common::INTERVALDAY))
+		(FromTo(common::DECIMAL28SPARSE, common::INT))
+		(FromTo(common::DECIMAL28SPARSE, common::BIGINT))
+		(FromTo(common::DECIMAL28SPARSE, common::DECIMAL9))
+		(FromTo(common::DECIMAL28SPARSE, common::DECIMAL18))
+		(FromTo(common::DECIMAL28SPARSE, common::DECIMAL28SPARSE))
+		(FromTo(common::DECIMAL28SPARSE, common::DECIMAL38SPARSE))
+		(FromTo(common::DECIMAL28SPARSE, common::DATE))
+		(FromTo(common::DECIMAL28SPARSE, common::TIME))
+		(FromTo(common::DECIMAL28SPARSE, common::TIMESTAMP))
+		(FromTo(common::DECIMAL28SPARSE, common::INTERVAL))
+		(FromTo(common::DECIMAL28SPARSE, common::FLOAT4))
+		(FromTo(common::DECIMAL28SPARSE, common::FLOAT8))
+		(FromTo(common::DECIMAL28SPARSE, common::BIT))
+		(FromTo(common::DECIMAL28SPARSE, common::VARCHAR))
+		(FromTo(common::DECIMAL28SPARSE, common::VAR16CHAR))
+		(FromTo(common::DECIMAL28SPARSE, common::VARBINARY))
+		(FromTo(common::DECIMAL28SPARSE, common::INTERVALYEAR))
+		(FromTo(common::DECIMAL28SPARSE, common::INTERVALDAY))
+		(FromTo(common::DECIMAL38SPARSE, common::INT))
+		(FromTo(common::DECIMAL38SPARSE, common::BIGINT))
+		(FromTo(common::DECIMAL38SPARSE, common::DECIMAL9))
+		(FromTo(common::DECIMAL38SPARSE, common::DECIMAL18))
+		(FromTo(common::DECIMAL38SPARSE, common::DECIMAL28SPARSE))
+		(FromTo(common::DECIMAL38SPARSE, common::DECIMAL38SPARSE))
+		(FromTo(common::DECIMAL38SPARSE, common::DATE))
+		(FromTo(common::DECIMAL38SPARSE, common::TIME))
+		(FromTo(common::DECIMAL38SPARSE, common::TIMESTAMP))
+		(FromTo(common::DECIMAL38SPARSE, common::INTERVAL))
+		(FromTo(common::DECIMAL38SPARSE, common::FLOAT4))
+		(FromTo(common::DECIMAL38SPARSE, common::FLOAT8))
+		(FromTo(common::DECIMAL38SPARSE, common::BIT))
+		(FromTo(common::DECIMAL38SPARSE, common::VARCHAR))
+		(FromTo(common::DECIMAL38SPARSE, common::VAR16CHAR))
+		(FromTo(common::DECIMAL38SPARSE, common::VARBINARY))
+		(FromTo(common::DECIMAL38SPARSE, common::INTERVALYEAR))
+		(FromTo(common::DECIMAL38SPARSE, common::INTERVALDAY))
+		(FromTo(common::MONEY, common::INT))
+		(FromTo(common::MONEY, common::BIGINT))
+		(FromTo(common::MONEY, common::DECIMAL9))
+		(FromTo(common::MONEY, common::DECIMAL18))
+		(FromTo(common::MONEY, common::DECIMAL28SPARSE))
+		(FromTo(common::MONEY, common::DECIMAL38SPARSE))
+		(FromTo(common::MONEY, common::DATE))
+		(FromTo(common::MONEY, common::TIME))
+		(FromTo(common::MONEY, common::TIMESTAMP))
+		(FromTo(common::MONEY, common::INTERVAL))
+		(FromTo(common::MONEY, common::FLOAT4))
+		(FromTo(common::MONEY, common::FLOAT8))
+		(FromTo(common::MONEY, common::BIT))
+		(FromTo(common::MONEY, common::VARCHAR))
+		(FromTo(common::MONEY, common::VAR16CHAR))
+		(FromTo(common::MONEY, common::VARBINARY))
+		(FromTo(common::MONEY, common::INTERVALYEAR))
+		(FromTo(common::MONEY, common::INTERVALDAY))
+		(FromTo(common::DATE, common::INT))
+		(FromTo(common::DATE, common::BIGINT))
+		(FromTo(common::DATE, common::DECIMAL9))
+		(FromTo(common::DATE, common::DECIMAL18))
+		(FromTo(common::DATE, common::DECIMAL28SPARSE))
+		(FromTo(common::DATE, common::DECIMAL38SPARSE))
+		(FromTo(common::DATE, common::DATE))
+		(FromTo(common::DATE, common::TIME))
+		(FromTo(common::DATE, common::TIMESTAMP))
+		(FromTo(common::DATE, common::INTERVAL))
+		(FromTo(common::DATE, common::FLOAT4))
+		(FromTo(common::DATE, common::FLOAT8))
+		(FromTo(common::DATE, common::BIT))
+		(FromTo(common::DATE, common::VARCHAR))
+		(FromTo(common::DATE, common::VAR16CHAR))
+		(FromTo(common::DATE, common::VARBINARY))
+		(FromTo(common::DATE, common::INTERVALYEAR))
+		(FromTo(common::DATE, common::INTERVALDAY))
+		(FromTo(common::TIME, common::INT))
+		(FromTo(common::TIME, common::BIGINT))
+		(FromTo(common::TIME, common::DECIMAL9))
+		(FromTo(common::TIME, common::DECIMAL18))
+		(FromTo(common::TIME, common::DECIMAL28SPARSE))
+		(FromTo(common::TIME, common::DECIMAL38SPARSE))
+		(FromTo(common::TIME, common::DATE))
+		(FromTo(common::TIME, common::TIME))
+		(FromTo(common::TIME, common::TIMESTAMP))
+		(FromTo(common::TIME, common::INTERVAL))
+		(FromTo(common::TIME, common::FLOAT4))
+		(FromTo(common::TIME, common::FLOAT8))
+		(FromTo(common::TIME, common::BIT))
+		(FromTo(common::TIME, common::VARCHAR))
+		(FromTo(common::TIME, common::VAR16CHAR))
+		(FromTo(common::TIME, common::VARBINARY))
+		(FromTo(common::TIME, common::INTERVALYEAR))
+		(FromTo(common::TIME, common::INTERVALDAY))
+		(FromTo(common::TIMESTAMPTZ, common::INT))
+		(FromTo(common::TIMESTAMPTZ, common::BIGINT))
+		(FromTo(common::TIMESTAMPTZ, common::DECIMAL9))
+		(FromTo(common::TIMESTAMPTZ, common::DECIMAL18))
+		(FromTo(common::TIMESTAMPTZ, common::DECIMAL28SPARSE))
+		(FromTo(common::TIMESTAMPTZ, common::DECIMAL38SPARSE))
+		(FromTo(common::TIMESTAMPTZ, common::DATE))
+		(FromTo(common::TIMESTAMPTZ, common::TIME))
+		(FromTo(common::TIMESTAMPTZ, common::TIMESTAMP))
+		(FromTo(common::TIMESTAMPTZ, common::INTERVAL))
+		(FromTo(common::TIMESTAMPTZ, common::FLOAT4))
+		(FromTo(common::TIMESTAMPTZ, common::FLOAT8))
+		(FromTo(common::TIMESTAMPTZ, common::BIT))
+		(FromTo(common::TIMESTAMPTZ, common::VARCHAR))
+		(FromTo(common::TIMESTAMPTZ, common::VAR16CHAR))
+		(FromTo(common::TIMESTAMPTZ, common::VARBINARY))
+		(FromTo(common::TIMESTAMPTZ, common::INTERVALYEAR))
+		(FromTo(common::TIMESTAMPTZ, common::INTERVALDAY))
+		(FromTo(common::TIMESTAMP, common::INT))
+		(FromTo(common::TIMESTAMP, common::BIGINT))
+		(FromTo(common::TIMESTAMP, common::DECIMAL9))
+		(FromTo(common::TIMESTAMP, common::DECIMAL18))
+		(FromTo(common::TIMESTAMP, common::DECIMAL28SPARSE))
+		(FromTo(common::TIMESTAMP, common::DECIMAL38SPARSE))
+		(FromTo(common::TIMESTAMP, common::DATE))
+		(FromTo(common::TIMESTAMP, common::TIME))
+		(FromTo(common::TIMESTAMP, common::TIMESTAMP))
+		(FromTo(common::TIMESTAMP, common::INTERVAL))
+		(FromTo(common::TIMESTAMP, common::FLOAT4))
+		(FromTo(common::TIMESTAMP, common::FLOAT8))
+		(FromTo(common::TIMESTAMP, common::BIT))
+		(FromTo(common::TIMESTAMP, common::VARCHAR))
+		(FromTo(common::TIMESTAMP, common::VAR16CHAR))
+		(FromTo(common::TIMESTAMP, common::VARBINARY))
+		(FromTo(common::TIMESTAMP, common::INTERVALYEAR))
+		(FromTo(common::TIMESTAMP, common::INTERVALDAY))
+		(FromTo(common::INTERVAL, common::INT))
+		(FromTo(common::INTERVAL, common::BIGINT))
+		(FromTo(common::INTERVAL, common::DECIMAL9))
+		(FromTo(common::INTERVAL, common::DECIMAL18))
+		(FromTo(common::INTERVAL, common::DECIMAL28SPARSE))
+		(FromTo(common::INTERVAL, common::DECIMAL38SPARSE))
+		(FromTo(common::INTERVAL, common::DATE))
+		(FromTo(common::INTERVAL, common::TIME))
+		(FromTo(common::INTERVAL, common::TIMESTAMP))
+		(FromTo(common::INTERVAL, common::INTERVAL))
+		(FromTo(common::INTERVAL, common::FLOAT4))
+		(FromTo(common::INTERVAL, common::FLOAT8))
+		(FromTo(common::INTERVAL, common::BIT))
+		(FromTo(common::INTERVAL, common::VARCHAR))
+		(FromTo(common::INTERVAL, common::VAR16CHAR))
+		(FromTo(common::INTERVAL, common::VARBINARY))
+		(FromTo(common::INTERVAL, common::INTERVALYEAR))
+		(FromTo(common::INTERVAL, common::INTERVALDAY))
+		(FromTo(common::FLOAT4, common::INT))
+		(FromTo(common::FLOAT4, common::BIGINT))
+		(FromTo(common::FLOAT4, common::DECIMAL9))
+		(FromTo(common::FLOAT4, common::DECIMAL18))
+		(FromTo(common::FLOAT4, common::DECIMAL28SPARSE))
+		(FromTo(common::FLOAT4, common::DECIMAL38SPARSE))
+		(FromTo(common::FLOAT4, common::DATE))
+		(FromTo(common::FLOAT4, common::TIME))
+		(FromTo(common::FLOAT4, common::TIMESTAMP))
+		(FromTo(common::FLOAT4, common::INTERVAL))
+		(FromTo(common::FLOAT4, common::FLOAT4))
+		(FromTo(common::FLOAT4, common::FLOAT8))
+		(FromTo(common::FLOAT4, common::BIT))
+		(FromTo(common::FLOAT4, common::VARCHAR))
+		(FromTo(common::FLOAT4, common::VAR16CHAR))
+		(FromTo(common::FLOAT4, common::VARBINARY))
+		(FromTo(common::FLOAT4, common::INTERVALYEAR))
+		(FromTo(common::FLOAT4, common::INTERVALDAY))
+		(FromTo(common::FLOAT8, common::INT))
+		(FromTo(common::FLOAT8, common::BIGINT))
+		(FromTo(common::FLOAT8, common::DECIMAL9))
+		(FromTo(common::FLOAT8, common::DECIMAL18))
+		(FromTo(common::FLOAT8, common::DECIMAL28SPARSE))
+		(FromTo(common::FLOAT8, common::DECIMAL38SPARSE))
+		(FromTo(common::FLOAT8, common::DATE))
+		(FromTo(common::FLOAT8, common::TIME))
+		(FromTo(common::FLOAT8, common::TIMESTAMP))
+		(FromTo(common::FLOAT8, common::INTERVAL))
+		(FromTo(common::FLOAT8, common::FLOAT4))
+		(FromTo(common::FLOAT8, common::FLOAT8))
+		(FromTo(common::FLOAT8, common::BIT))
+		(FromTo(common::FLOAT8, common::VARCHAR))
+		(FromTo(common::FLOAT8, common::VAR16CHAR))
+		(FromTo(common::FLOAT8, common::VARBINARY))
+		(FromTo(common::FLOAT8, common::INTERVALYEAR))
+		(FromTo(common::FLOAT8, common::INTERVALDAY))
+		(FromTo(common::BIT, common::TINYINT))
+		(FromTo(common::BIT, common::INT))
+		(FromTo(common::BIT, common::BIGINT))
+		(FromTo(common::BIT, common::DECIMAL9))
+		(FromTo(common::BIT, common::DECIMAL18))
+		(FromTo(common::BIT, common::DECIMAL28SPARSE))
+		(FromTo(common::BIT, common::DECIMAL38SPARSE))
+		(FromTo(common::BIT, common::DATE))
+		(FromTo(common::BIT, common::TIME))
+		(FromTo(common::BIT, common::TIMESTAMP))
+		(FromTo(common::BIT, common::INTERVAL))
+		(FromTo(common::BIT, common::FLOAT4))
+		(FromTo(common::BIT, common::FLOAT8))
+		(FromTo(common::BIT, common::BIT))
+		(FromTo(common::BIT, common::VARCHAR))
+		(FromTo(common::BIT, common::VAR16CHAR))
+		(FromTo(common::BIT, common::VARBINARY))
+		(FromTo(common::BIT, common::INTERVALYEAR))
+		(FromTo(common::BIT, common::INTERVALDAY))
+		(FromTo(common::FIXEDCHAR, common::TINYINT))
+		(FromTo(common::FIXEDCHAR, common::INT))
+		(FromTo(common::FIXEDCHAR, common::BIGINT))
+		(FromTo(common::FIXEDCHAR, common::DECIMAL9))
+		(FromTo(common::FIXEDCHAR, common::DECIMAL18))
+		(FromTo(common::FIXEDCHAR, common::DECIMAL28SPARSE))
+		(FromTo(common::FIXEDCHAR, common::DECIMAL38SPARSE))
+		(FromTo(common::FIXEDCHAR, common::DATE))
+		(FromTo(common::FIXEDCHAR, common::TIME))
+		(FromTo(common::FIXEDCHAR, common::TIMESTAMP))
+		(FromTo(common::FIXEDCHAR, common::INTERVAL))
+		(FromTo(common::FIXEDCHAR, common::FLOAT4))
+		(FromTo(common::FIXEDCHAR, common::FLOAT8))
+		(FromTo(common::FIXEDCHAR, common::BIT))
+		(FromTo(common::FIXEDCHAR, common::VARCHAR))
+		(FromTo(common::FIXEDCHAR, common::VAR16CHAR))
+		(FromTo(common::FIXEDCHAR, common::VARBINARY))
+		(FromTo(common::FIXEDCHAR, common::INTERVALYEAR))
+		(FromTo(common::FIXEDCHAR, common::INTERVALDAY))
+		(FromTo(common::FIXED16CHAR, common::TINYINT))
+		(FromTo(common::FIXED16CHAR, common::INT))
+		(FromTo(common::FIXED16CHAR, common::BIGINT))
+		(FromTo(common::FIXED16CHAR, common::DECIMAL9))
+		(FromTo(common::FIXED16CHAR, common::DECIMAL18))
+		(FromTo(common::FIXED16CHAR, common::DECIMAL28SPARSE))
+		(FromTo(common::FIXED16CHAR, common::DECIMAL38SPARSE))
+		(FromTo(common::FIXED16CHAR, common::DATE))
+		(FromTo(common::FIXED16CHAR, common::TIME))
+		(FromTo(common::FIXED16CHAR, common::TIMESTAMP))
+		(FromTo(common::FIXED16CHAR, common::INTERVAL))
+		(FromTo(common::FIXED16CHAR, common::FLOAT4))
+		(FromTo(common::FIXED16CHAR, common::FLOAT8))
+		(FromTo(common::FIXED16CHAR, common::BIT))
+		(FromTo(common::FIXED16CHAR, common::VARCHAR))
+		(FromTo(common::FIXED16CHAR, common::VAR16CHAR))
+		(FromTo(common::FIXED16CHAR, common::VARBINARY))
+		(FromTo(common::FIXED16CHAR, common::INTERVALYEAR))
+		(FromTo(common::FIXED16CHAR, common::INTERVALDAY))
+		(FromTo(common::FIXEDBINARY, common::INT))
+		(FromTo(common::FIXEDBINARY, common::BIGINT))
+		(FromTo(common::FIXEDBINARY, common::DECIMAL9))
+		(FromTo(common::FIXEDBINARY, common::DECIMAL18))
+		(FromTo(common::FIXEDBINARY, common::DECIMAL28SPARSE))
+		(FromTo(common::FIXEDBINARY, common::DECIMAL38SPARSE))
+		(FromTo(common::FIXEDBINARY, common::DATE))
+		(FromTo(common::FIXEDBINARY, common::TIME))
+		(FromTo(common::FIXEDBINARY, common::TIMESTAMP))
+		(FromTo(common::FIXEDBINARY, common::INTERVAL))
+		(FromTo(common::FIXEDBINARY, common::FLOAT4))
+		(FromTo(common::FIXEDBINARY, common::FLOAT8))
+		(FromTo(common::FIXEDBINARY, common::BIT))
+		(FromTo(common::FIXEDBINARY, common::VARCHAR))
+		(FromTo(common::FIXEDBINARY, common::VAR16CHAR))
+		(FromTo(common::FIXEDBINARY, common::VARBINARY))
+		(FromTo(common::FIXEDBINARY, common::INTERVALYEAR))
+		(FromTo(common::FIXEDBINARY, common::INTERVALDAY))
+		(FromTo(common::VARCHAR, common::TINYINT))
+		(FromTo(common::VARCHAR, common::INT))
+		(FromTo(common::VARCHAR, common::BIGINT))
+		(FromTo(common::VARCHAR, common::DECIMAL9))
+		(FromTo(common::VARCHAR, common::DECIMAL18))
+		(FromTo(common::VARCHAR, common::DECIMAL28SPARSE))
+		(FromTo(common::VARCHAR, common::DECIMAL38SPARSE))
+		(FromTo(common::VARCHAR, common::DATE))
+		(FromTo(common::VARCHAR, common::TIME))
+		(FromTo(common::VARCHAR, common::TIMESTAMP))
+		(FromTo(common::VARCHAR, common::INTERVAL))
+		(FromTo(common::VARCHAR, common::FLOAT4))
+		(FromTo(common::VARCHAR, common::FLOAT8))
+		(FromTo(common::VARCHAR, common::BIT))
+		(FromTo(common::VARCHAR, common::VARCHAR))
+		(FromTo(common::VARCHAR, common::VAR16CHAR))
+		(FromTo(common::VARCHAR, common::VARBINARY))
+		(FromTo(common::VARCHAR, common::INTERVALYEAR))
+		(FromTo(common::VARCHAR, common::INTERVALDAY))
+		(FromTo(common::VAR16CHAR, common::TINYINT))
+		(FromTo(common::VAR16CHAR, common::INT))
+		(FromTo(common::VAR16CHAR, common::BIGINT))
+		(FromTo(common::VAR16CHAR, common::DECIMAL9))
+		(FromTo(common::VAR16CHAR, common::DECIMAL18))
+		(FromTo(common::VAR16CHAR, common::DECIMAL28SPARSE))
+		(FromTo(common::VAR16CHAR, common::DECIMAL38SPARSE))
+		(FromTo(common::VAR16CHAR, common::DATE))
+		(FromTo(common::VAR16CHAR, common::TIME))
+		(FromTo(common::VAR16CHAR, common::TIMESTAMP))
+		(FromTo(common::VAR16CHAR, common::INTERVAL))
+		(FromTo(common::VAR16CHAR, common::FLOAT4))
+		(FromTo(common::VAR16CHAR, common::FLOAT8))
+		(FromTo(common::VAR16CHAR, common::BIT))
+		(FromTo(common::VAR16CHAR, common::VARCHAR))
+		(FromTo(common::VAR16CHAR, common::VARBINARY))
+		(FromTo(common::VAR16CHAR, common::INTERVALYEAR))
+		(FromTo(common::VAR16CHAR, common::INTERVALDAY))
+		(FromTo(common::VARBINARY, common::TINYINT))
+		(FromTo(common::VARBINARY, common::INT))
+		(FromTo(common::VARBINARY, common::BIGINT))
+		(FromTo(common::VARBINARY, common::DECIMAL9))
+		(FromTo(common::VARBINARY, common::DECIMAL18))
+		(FromTo(common::VARBINARY, common::DECIMAL28SPARSE))
+		(FromTo(common::VARBINARY, common::DECIMAL38SPARSE))
+		(FromTo(common::VARBINARY, common::DATE))
+		(FromTo(common::VARBINARY, common::TIME))
+		(FromTo(common::VARBINARY, common::TIMESTAMP))
+		(FromTo(common::VARBINARY, common::INTERVAL))
+		(FromTo(common::VARBINARY, common::FLOAT4))
+		(FromTo(common::VARBINARY, common::FLOAT8))
+		(FromTo(common::VARBINARY, common::BIT))
+		(FromTo(common::VARBINARY, common::VARCHAR))
+		(FromTo(common::VARBINARY, common::VAR16CHAR))
+		(FromTo(common::VARBINARY, common::VARBINARY))
+		(FromTo(common::VARBINARY, common::INTERVALYEAR))
+		(FromTo(common::VARBINARY, common::INTERVALDAY))
+		(FromTo(common::UINT1, common::INT))
+		(FromTo(common::UINT1, common::BIGINT))
+		(FromTo(common::UINT1, common::DECIMAL9))
+		(FromTo(common::UINT1, common::DECIMAL18))
+		(FromTo(common::UINT1, common::DECIMAL28SPARSE))
+		(FromTo(common::UINT1, common::DECIMAL38SPARSE))
+		(FromTo(common::UINT1, common::DATE))
+		(FromTo(common::UINT1, common::TIME))
+		(FromTo(common::UINT1, common::TIMESTAMP))
+		(FromTo(common::UINT1, common::INTERVAL))
+		(FromTo(common::UINT1, common::FLOAT4))
+		(FromTo(common::UINT1, common::FLOAT8))
+		(FromTo(common::UINT1, common::BIT))
+		(FromTo(common::UINT1, common::VARCHAR))
+		(FromTo(common::UINT1, common::VAR16CHAR))
+		(FromTo(common::UINT1, common::VARBINARY))
+		(FromTo(common::UINT1, common::INTERVALYEAR))
+		(FromTo(common::UINT1, common::INTERVALDAY))
+		(FromTo(common::UINT2, common::INT))
+		(FromTo(common::UINT2, common::BIGINT))
+		(FromTo(common::UINT2, common::DECIMAL9))
+		(FromTo(common::UINT2, common::DECIMAL18))
+		(FromTo(common::UINT2, common::DECIMAL28SPARSE))
+		(FromTo(common::UINT2, common::DECIMAL38SPARSE))
+		(FromTo(common::UINT2, common::DATE))
+		(FromTo(common::UINT2, common::TIME))
+		(FromTo(common::UINT2, common::TIMESTAMP))
+		(FromTo(common::UINT2, common::INTERVAL))
+		(FromTo(common::UINT2, common::FLOAT4))
+		(FromTo(common::UINT2, common::FLOAT8))
+		(FromTo(common::UINT2, common::BIT))
+		(FromTo(common::UINT2, common::VARCHAR))
+		(FromTo(common::UINT2, common::VAR16CHAR))
+		(FromTo(common::UINT2, common::VARBINARY))
+		(FromTo(common::UINT2, common::INTERVALYEAR))
+		(FromTo(common::UINT2, common::INTERVALDAY))
+		(FromTo(common::UINT4, common::INT))
+		(FromTo(common::UINT4, common::BIGINT))
+		(FromTo(common::UINT4, common::DECIMAL9))
+		(FromTo(common::UINT4, common::DECIMAL18))
+		(FromTo(common::UINT4, common::DECIMAL28SPARSE))
+		(FromTo(common::UINT4, common::DECIMAL38SPARSE))
+		(FromTo(common::UINT4, common::DATE))
+		(FromTo(common::UINT4, common::TIME))
+		(FromTo(common::UINT4, common::TIMESTAMP))
+		(FromTo(common::UINT4, common::INTERVAL))
+		(FromTo(common::UINT4, common::FLOAT4))
+		(FromTo(common::UINT4, common::FLOAT8))
+		(FromTo(common::UINT4, common::BIT))
+		(FromTo(common::UINT4, common::VARCHAR))
+		(FromTo(common::UINT4, common::VAR16CHAR))
+		(FromTo(common::UINT4, common::VARBINARY))
+		(FromTo(common::UINT4, common::INTERVALYEAR))
+		(FromTo(common::UINT4, common::INTERVALDAY))
+		(FromTo(common::UINT8, common::INT))
+		(FromTo(common::UINT8, common::BIGINT))
+		(FromTo(common::UINT8, common::DECIMAL9))
+		(FromTo(common::UINT8, common::DECIMAL18))
+		(FromTo(common::UINT8, common::DECIMAL28SPARSE))
+		(FromTo(common::UINT8, common::DECIMAL38SPARSE))
+		(FromTo(common::UINT8, common::DATE))
+		(FromTo(common::UINT8, common::TIME))
+		(FromTo(common::UINT8, common::TIMESTAMP))
+		(FromTo(common::UINT8, common::INTERVAL))
+		(FromTo(common::UINT8, common::FLOAT4))
+		(FromTo(common::UINT8, common::FLOAT8))
+		(FromTo(common::UINT8, common::BIT))
+		(FromTo(common::UINT8, common::VARCHAR))
+		(FromTo(common::UINT8, common::VAR16CHAR))
+		(FromTo(common::UINT8, common::VARBINARY))
+		(FromTo(common::UINT8, common::INTERVALYEAR))
+		(FromTo(common::UINT8, common::INTERVALDAY))
+		(FromTo(common::DECIMAL28DENSE, common::INT))
+		(FromTo(common::DECIMAL28DENSE, common::BIGINT))
+		(FromTo(common::DECIMAL28DENSE, common::DECIMAL9))
+		(FromTo(common::DECIMAL28DENSE, common::DECIMAL18))
+		(FromTo(common::DECIMAL28DENSE, common::DECIMAL28SPARSE))
+		(FromTo(common::DECIMAL28DENSE, common::DECIMAL38SPARSE))
+		(FromTo(common::DECIMAL28DENSE, common::DATE))
+		(FromTo(common::DECIMAL28DENSE, common::TIME))
+		(FromTo(common::DECIMAL28DENSE, common::TIMESTAMP))
+		(FromTo(common::DECIMAL28DENSE, common::INTERVAL))
+		(FromTo(common::DECIMAL28DENSE, common::FLOAT4))
+		(FromTo(common::DECIMAL28DENSE, common::FLOAT8))
+		(FromTo(common::DECIMAL28DENSE, common::BIT))
+		(FromTo(common::DECIMAL28DENSE, common::VARCHAR))
+		(FromTo(common::DECIMAL28DENSE, common::VAR16CHAR))
+		(FromTo(common::DECIMAL28DENSE, common::VARBINARY))
+		(FromTo(common::DECIMAL28DENSE, common::INTERVALYEAR))
+		(FromTo(common::DECIMAL28DENSE, common::INTERVALDAY))
+		(FromTo(common::DECIMAL38DENSE, common::INT))
+		(FromTo(common::DECIMAL38DENSE, common::BIGINT))
+		(FromTo(common::DECIMAL38DENSE, common::DECIMAL9))
+		(FromTo(common::DECIMAL38DENSE, common::DECIMAL18))
+		(FromTo(common::DECIMAL38DENSE, common::DECIMAL28SPARSE))
+		(FromTo(common::DECIMAL38DENSE, common::DECIMAL38SPARSE))
+		(FromTo(common::DECIMAL38DENSE, common::DATE))
+		(FromTo(common::DECIMAL38DENSE, common::TIME))
+		(FromTo(common::DECIMAL38DENSE, common::TIMESTAMP))
+		(FromTo(common::DECIMAL38DENSE, common::INTERVAL))
+		(FromTo(common::DECIMAL38DENSE, common::FLOAT4))
+		(FromTo(common::DECIMAL38DENSE, common::FLOAT8))
+		(FromTo(common::DECIMAL38DENSE, common::BIT))
+		(FromTo(common::DECIMAL38DENSE, common::VARCHAR))
+		(FromTo(common::DECIMAL38DENSE, common::VAR16CHAR))
+		(FromTo(common::DECIMAL38DENSE, common::VARBINARY))
+		(FromTo(common::DECIMAL38DENSE, common::INTERVALYEAR))
+		(FromTo(common::DECIMAL38DENSE, common::INTERVALDAY))
+		(FromTo(common::DM_UNKNOWN, common::TINYINT))
+		(FromTo(common::DM_UNKNOWN, common::INT))
+		(FromTo(common::DM_UNKNOWN, common::BIGINT))
+		(FromTo(common::DM_UNKNOWN, common::DECIMAL9))
+		(FromTo(common::DM_UNKNOWN, common::DECIMAL18))
+		(FromTo(common::DM_UNKNOWN, common::DECIMAL28SPARSE))
+		(FromTo(common::DM_UNKNOWN, common::DECIMAL38SPARSE))
+		(FromTo(common::DM_UNKNOWN, common::DATE))
+		(FromTo(common::DM_UNKNOWN, common::TIME))
+		(FromTo(common::DM_UNKNOWN, common::TIMESTAMP))
+		(FromTo(common::DM_UNKNOWN, common::INTERVAL))
+		(FromTo(common::DM_UNKNOWN, common::FLOAT4))
+		(FromTo(common::DM_UNKNOWN, common::FLOAT8))
+		(FromTo(common::DM_UNKNOWN, common::BIT))
+		(FromTo(common::DM_UNKNOWN, common::VARCHAR))
+		(FromTo(common::DM_UNKNOWN, common::VAR16CHAR))
+		(FromTo(common::DM_UNKNOWN, common::VARBINARY))
+		(FromTo(common::DM_UNKNOWN, common::INTERVALYEAR))
+		(FromTo(common::DM_UNKNOWN, common::INTERVALDAY))
+		(FromTo(common::INTERVALYEAR, common::INT))
+		(FromTo(common::INTERVALYEAR, common::BIGINT))
+		(FromTo(common::INTERVALYEAR, common::DECIMAL9))
+		(FromTo(common::INTERVALYEAR, common::DECIMAL18))
+		(FromTo(common::INTERVALYEAR, common::DECIMAL28SPARSE))
+		(FromTo(common::INTERVALYEAR, common::DECIMAL38SPARSE))
+		(FromTo(common::INTERVALYEAR, common::DATE))
+		(FromTo(common::INTERVALYEAR, common::TIME))
+		(FromTo(common::INTERVALYEAR, common::TIMESTAMP))
+		(FromTo(common::INTERVALYEAR, common::INTERVAL))
+		(FromTo(common::INTERVALYEAR, common::FLOAT4))
+		(FromTo(common::INTERVALYEAR, common::FLOAT8))
+		(FromTo(common::INTERVALYEAR, common::BIT))
+		(FromTo(common::INTERVALYEAR, common::VARCHAR))
+		(FromTo(common::INTERVALYEAR, common::VAR16CHAR))
+		(FromTo(common::INTERVALYEAR, common::VARBINARY))
+		(FromTo(common::INTERVALYEAR, common::INTERVALYEAR))
+		(FromTo(common::INTERVALYEAR, common::INTERVALDAY))
+		(FromTo(common::INTERVALDAY, common::INT))
+		(FromTo(common::INTERVALDAY, common::BIGINT))
+		(FromTo(common::INTERVALDAY, common::DECIMAL9))
+		(FromTo(common::INTERVALDAY, common::DECIMAL18))
+		(FromTo(common::INTERVALDAY, common::DECIMAL28SPARSE))
+		(FromTo(common::INTERVALDAY, common::DECIMAL38SPARSE))
+		(FromTo(common::INTERVALDAY, common::DATE))
+		(FromTo(common::INTERVALDAY, common::TIME))
+		(FromTo(common::INTERVALDAY, common::TIMESTAMP))
+		(FromTo(common::INTERVALDAY, common::INTERVAL))
+		(FromTo(common::INTERVALDAY, common::FLOAT4))
+		(FromTo(common::INTERVALDAY, common::FLOAT8))
+		(FromTo(common::INTERVALDAY, common::BIT))
+		(FromTo(common::INTERVALDAY, common::VARCHAR))
+		(FromTo(common::INTERVALDAY, common::VAR16CHAR))
+		(FromTo(common::INTERVALDAY, common::VARBINARY))
+		(FromTo(common::INTERVALDAY, common::INTERVALYEAR))
+		(FromTo(common::INTERVALDAY, common::INTERVALDAY));
+} // anonymous namespace
+
+// Conversion scalar function support
+bool DrillMetadata::isConvertSupported(common::MinorType from, common::MinorType to) const {
+	return s_convertMap.find(FromTo(from,to)) != s_convertMap.end();
+}
+
+const std::string& DrillMetadata::getServerName() const {
+	return m_client.getServerInfos().name();
+}
+const std::string& DrillMetadata::getServerVersion() const {
+	return m_client.getServerInfos().version();
+}
+uint32_t DrillMetadata::getServerMajorVersion() const {
+	return m_client.getServerInfos().majorversion();
+}
+
+uint32_t DrillMetadata::getServerMinorVersion() const {
+	return m_client.getServerInfos().minorversion();
+}
+
+uint32_t DrillMetadata::getServerPatchVersion() const {
+	return m_client.getServerInfos().patchversion();
+}
+
+status_t DrillMetadata::getCatalogs(const std::string& catalogPattern, Metadata::pfnCatalogMetadataListener listener, void* listenerCtx, QueryHandle_t* qHandle) {
+	DrillClientCatalogResult* result = m_client.getCatalogs(catalogPattern, listener, listenerCtx);
+	if(result==NULL){
+		*qHandle=NULL;
+		return static_cast<status_t>(m_client.getError()->status);
+	}
+	*qHandle=reinterpret_cast<QueryHandle_t>(result);
+	return QRY_SUCCESS;
+}
+status_t DrillMetadata::getSchemas(const std::string& catalogPattern, const std::string& schemaPattern, Metadata::pfnSchemaMetadataListener listener, void* listenerCtx, QueryHandle_t* qHandle) {
+	DrillClientSchemaResult* result = m_client.getSchemas(catalogPattern, schemaPattern, listener, listenerCtx);
+	if(result==NULL){
+		*qHandle=NULL;
+		return static_cast<status_t>(m_client.getError()->status);
+	}
+	*qHandle=reinterpret_cast<QueryHandle_t>(result);
+	return QRY_SUCCESS;
+}
+status_t DrillMetadata::getTables(const std::string& catalogPattern, const std::string& schemaPattern, const std::string& tablePattern, const std::vector<std::string>* tableTypes, Metadata::pfnTableMetadataListener listener, void* listenerCtx, QueryHandle_t* qHandle) {
+	DrillClientTableResult* result = m_client.getTables(catalogPattern, schemaPattern, tablePattern, tableTypes, listener, listenerCtx);
+	if(result==NULL){
+		*qHandle=NULL;
+		return static_cast<status_t>(m_client.getError()->status);
+	}
+	*qHandle=reinterpret_cast<QueryHandle_t>(result);
+	return QRY_SUCCESS;
+}
+status_t DrillMetadata::getColumns(const std::string& catalogPattern, const std::string& schemaPattern, const std:: string& tablePattern, const std::string& columnPattern, Metadata::pfnColumnMetadataListener listener, void* listenerCtx, QueryHandle_t* qHandle) {
+	DrillClientColumnResult* result = m_client.getColumns(catalogPattern, schemaPattern, tablePattern, columnPattern, listener, listenerCtx);
+	if(result==NULL){
+		*qHandle=NULL;
+		return static_cast<status_t>(m_client.getError()->status);
+	}
+	*qHandle=reinterpret_cast<QueryHandle_t>(result);
+	return QRY_SUCCESS;
+}
+} // namespace meta
+} // namespace Drill


Mime
View raw message