diff --git service/if/TCLIService.thrift service/if/TCLIService.thrift index 4d7e89e..aa2f2a8 100644 --- service/if/TCLIService.thrift +++ service/if/TCLIService.thrift @@ -31,7 +31,7 @@ // Services // * Service names begin with the letter "T", use a capital letter for each // new word (with no underscores), and end with the word "Service". - +include "ql/if/queryplan.thrift" namespace java org.apache.hive.service.cli.thrift namespace cpp apache.hive.service.cli.thrift @@ -961,6 +961,14 @@ struct TFetchResultsResp { 3: optional TRowSet results } +// GetQueryPlan() +// Get query plan of a query +struct TGetQueryPlanResp { + 1: required TStatus status + // Queryplan + 2: required queryplan.Query plan +} + service TCLIService { TOpenSessionResp OpenSession(1:TOpenSessionReq req); @@ -994,4 +1002,6 @@ service TCLIService { TGetResultSetMetadataResp GetResultSetMetadata(1:TGetResultSetMetadataReq req); TFetchResultsResp FetchResults(1:TFetchResultsReq req); + + TGetQueryPlanResp GetQueryPlan(1:TExecuteStatementReq req); } diff --git service/src/gen/thrift/gen-cpp/TCLIService.cpp service/src/gen/thrift/gen-cpp/TCLIService.cpp index f8afc09..76f300b 100644 --- service/src/gen/thrift/gen-cpp/TCLIService.cpp +++ service/src/gen/thrift/gen-cpp/TCLIService.cpp @@ -2600,6 +2600,168 @@ uint32_t TCLIService_FetchResults_presult::read(::apache::thrift::protocol::TPro return xfer; } +uint32_t TCLIService_GetQueryPlan_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->req.read(iprot); + this->__isset.req = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t TCLIService_GetQueryPlan_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("TCLIService_GetQueryPlan_args"); + + xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->req.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t TCLIService_GetQueryPlan_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("TCLIService_GetQueryPlan_pargs"); + + xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += (*(this->req)).write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t TCLIService_GetQueryPlan_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->success.read(iprot); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t TCLIService_GetQueryPlan_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("TCLIService_GetQueryPlan_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); + xfer += this->success.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t TCLIService_GetQueryPlan_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += (*(this->success)).read(iprot); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + void TCLIServiceClient::OpenSession(TOpenSessionResp& _return, const TOpenSessionReq& req) { send_OpenSession(req); @@ -3528,6 +3690,64 @@ void TCLIServiceClient::recv_FetchResults(TFetchResultsResp& _return) throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "FetchResults failed: unknown result"); } +void TCLIServiceClient::GetQueryPlan(TGetQueryPlanResp& _return, const TExecuteStatementReq& req) +{ + send_GetQueryPlan(req); + recv_GetQueryPlan(_return); +} + +void TCLIServiceClient::send_GetQueryPlan(const TExecuteStatementReq& req) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("GetQueryPlan", ::apache::thrift::protocol::T_CALL, cseqid); + + TCLIService_GetQueryPlan_pargs args; + args.req = &req; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void TCLIServiceClient::recv_GetQueryPlan(TGetQueryPlanResp& _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("GetQueryPlan") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + TCLIService_GetQueryPlan_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "GetQueryPlan failed: unknown result"); +} + bool TCLIServiceProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { ProcessMap::iterator pfn; pfn = processMap_.find(fname); @@ -4411,6 +4631,60 @@ void TCLIServiceProcessor::process_FetchResults(int32_t seqid, ::apache::thrift: } } +void TCLIServiceProcessor::process_GetQueryPlan(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("TCLIService.GetQueryPlan", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "TCLIService.GetQueryPlan"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "TCLIService.GetQueryPlan"); + } + + TCLIService_GetQueryPlan_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "TCLIService.GetQueryPlan", bytes); + } + + TCLIService_GetQueryPlan_result result; + try { + iface_->GetQueryPlan(result.success, args.req); + result.__isset.success = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "TCLIService.GetQueryPlan"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("GetQueryPlan", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "TCLIService.GetQueryPlan"); + } + + oprot->writeMessageBegin("GetQueryPlan", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "TCLIService.GetQueryPlan", bytes); + } +} + ::boost::shared_ptr< ::apache::thrift::TProcessor > TCLIServiceProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { ::apache::thrift::ReleaseHandler< TCLIServiceIfFactory > cleanup(handlerFactory_); ::boost::shared_ptr< TCLIServiceIf > handler(handlerFactory_->getHandler(connInfo), cleanup); diff --git service/src/gen/thrift/gen-cpp/TCLIService.h service/src/gen/thrift/gen-cpp/TCLIService.h index 055cfa6..6b9e039 100644 --- service/src/gen/thrift/gen-cpp/TCLIService.h +++ service/src/gen/thrift/gen-cpp/TCLIService.h @@ -31,6 +31,7 @@ class TCLIServiceIf { virtual void CloseOperation(TCloseOperationResp& _return, const TCloseOperationReq& req) = 0; virtual void GetResultSetMetadata(TGetResultSetMetadataResp& _return, const TGetResultSetMetadataReq& req) = 0; virtual void FetchResults(TFetchResultsResp& _return, const TFetchResultsReq& req) = 0; + virtual void GetQueryPlan(TGetQueryPlanResp& _return, const TExecuteStatementReq& req) = 0; }; class TCLIServiceIfFactory { @@ -108,6 +109,9 @@ class TCLIServiceNull : virtual public TCLIServiceIf { void FetchResults(TFetchResultsResp& /* _return */, const TFetchResultsReq& /* req */) { return; } + void GetQueryPlan(TGetQueryPlanResp& /* _return */, const TExecuteStatementReq& /* req */) { + return; + } }; typedef struct _TCLIService_OpenSession_args__isset { @@ -1838,6 +1842,114 @@ class TCLIService_FetchResults_presult { }; +typedef struct _TCLIService_GetQueryPlan_args__isset { + _TCLIService_GetQueryPlan_args__isset() : req(false) {} + bool req; +} _TCLIService_GetQueryPlan_args__isset; + +class TCLIService_GetQueryPlan_args { + public: + + TCLIService_GetQueryPlan_args() { + } + + virtual ~TCLIService_GetQueryPlan_args() throw() {} + + TExecuteStatementReq req; + + _TCLIService_GetQueryPlan_args__isset __isset; + + void __set_req(const TExecuteStatementReq& val) { + req = val; + } + + bool operator == (const TCLIService_GetQueryPlan_args & rhs) const + { + if (!(req == rhs.req)) + return false; + return true; + } + bool operator != (const TCLIService_GetQueryPlan_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TCLIService_GetQueryPlan_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class TCLIService_GetQueryPlan_pargs { + public: + + + virtual ~TCLIService_GetQueryPlan_pargs() throw() {} + + const TExecuteStatementReq* req; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _TCLIService_GetQueryPlan_result__isset { + _TCLIService_GetQueryPlan_result__isset() : success(false) {} + bool success; +} _TCLIService_GetQueryPlan_result__isset; + +class TCLIService_GetQueryPlan_result { + public: + + TCLIService_GetQueryPlan_result() { + } + + virtual ~TCLIService_GetQueryPlan_result() throw() {} + + TGetQueryPlanResp success; + + _TCLIService_GetQueryPlan_result__isset __isset; + + void __set_success(const TGetQueryPlanResp& val) { + success = val; + } + + bool operator == (const TCLIService_GetQueryPlan_result & rhs) const + { + if (!(success == rhs.success)) + return false; + return true; + } + bool operator != (const TCLIService_GetQueryPlan_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TCLIService_GetQueryPlan_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _TCLIService_GetQueryPlan_presult__isset { + _TCLIService_GetQueryPlan_presult__isset() : success(false) {} + bool success; +} _TCLIService_GetQueryPlan_presult__isset; + +class TCLIService_GetQueryPlan_presult { + public: + + + virtual ~TCLIService_GetQueryPlan_presult() throw() {} + + TGetQueryPlanResp* success; + + _TCLIService_GetQueryPlan_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + class TCLIServiceClient : virtual public TCLIServiceIf { public: TCLIServiceClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) : @@ -1906,6 +2018,9 @@ class TCLIServiceClient : virtual public TCLIServiceIf { void FetchResults(TFetchResultsResp& _return, const TFetchResultsReq& req); void send_FetchResults(const TFetchResultsReq& req); void recv_FetchResults(TFetchResultsResp& _return); + void GetQueryPlan(TGetQueryPlanResp& _return, const TExecuteStatementReq& req); + void send_GetQueryPlan(const TExecuteStatementReq& req); + void recv_GetQueryPlan(TGetQueryPlanResp& _return); protected: boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; @@ -1937,6 +2052,7 @@ class TCLIServiceProcessor : public ::apache::thrift::TDispatchProcessor { void process_CloseOperation(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_GetResultSetMetadata(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_FetchResults(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_GetQueryPlan(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); public: TCLIServiceProcessor(boost::shared_ptr iface) : iface_(iface) { @@ -1956,6 +2072,7 @@ class TCLIServiceProcessor : public ::apache::thrift::TDispatchProcessor { processMap_["CloseOperation"] = &TCLIServiceProcessor::process_CloseOperation; processMap_["GetResultSetMetadata"] = &TCLIServiceProcessor::process_GetResultSetMetadata; processMap_["FetchResults"] = &TCLIServiceProcessor::process_FetchResults; + processMap_["GetQueryPlan"] = &TCLIServiceProcessor::process_GetQueryPlan; } virtual ~TCLIServiceProcessor() {} @@ -2144,6 +2261,16 @@ class TCLIServiceMultiface : virtual public TCLIServiceIf { return; } + void GetQueryPlan(TGetQueryPlanResp& _return, const TExecuteStatementReq& req) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->GetQueryPlan(_return, req); + } + ifaces_[i]->GetQueryPlan(_return, req); + return; + } + }; }}}}} // namespace diff --git service/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp service/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp index d1d31cb..fb34f47 100644 --- service/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp +++ service/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp @@ -102,6 +102,11 @@ class TCLIServiceHandler : virtual public TCLIServiceIf { printf("FetchResults\n"); } + void GetQueryPlan(TGetQueryPlanResp& _return, const TExecuteStatementReq& req) { + // Your implementation goes here + printf("GetQueryPlan\n"); + } + }; int main(int argc, char **argv) { diff --git service/src/gen/thrift/gen-cpp/TCLIService_types.cpp service/src/gen/thrift/gen-cpp/TCLIService_types.cpp index ef47f5c..c632d51 100644 --- service/src/gen/thrift/gen-cpp/TCLIService_types.cpp +++ service/src/gen/thrift/gen-cpp/TCLIService_types.cpp @@ -5397,4 +5397,84 @@ void swap(TFetchResultsResp &a, TFetchResultsResp &b) { swap(a.__isset, b.__isset); } +const char* TGetQueryPlanResp::ascii_fingerprint = "549F348DBF2ED15F40BCD1903A116564"; +const uint8_t TGetQueryPlanResp::binary_fingerprint[16] = {0x54,0x9F,0x34,0x8D,0xBF,0x2E,0xD1,0x5F,0x40,0xBC,0xD1,0x90,0x3A,0x11,0x65,0x64}; + +uint32_t TGetQueryPlanResp::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_status = false; + bool isset_plan = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->status.read(iprot); + isset_status = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->plan.read(iprot); + isset_plan = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_status) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_plan) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t TGetQueryPlanResp::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("TGetQueryPlanResp"); + + xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->status.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("plan", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += this->plan.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(TGetQueryPlanResp &a, TGetQueryPlanResp &b) { + using ::std::swap; + swap(a.status, b.status); + swap(a.plan, b.plan); +} + }}}}} // namespace diff --git service/src/gen/thrift/gen-cpp/TCLIService_types.h service/src/gen/thrift/gen-cpp/TCLIService_types.h index f1d846b..f2366b9 100644 --- service/src/gen/thrift/gen-cpp/TCLIService_types.h +++ service/src/gen/thrift/gen-cpp/TCLIService_types.h @@ -12,6 +12,7 @@ #include #include +#include "queryplan_types.h" namespace apache { namespace hive { namespace service { namespace cli { namespace thrift { @@ -3194,6 +3195,50 @@ class TFetchResultsResp { void swap(TFetchResultsResp &a, TFetchResultsResp &b); + +class TGetQueryPlanResp { + public: + + static const char* ascii_fingerprint; // = "549F348DBF2ED15F40BCD1903A116564"; + static const uint8_t binary_fingerprint[16]; // = {0x54,0x9F,0x34,0x8D,0xBF,0x2E,0xD1,0x5F,0x40,0xBC,0xD1,0x90,0x3A,0x11,0x65,0x64}; + + TGetQueryPlanResp() { + } + + virtual ~TGetQueryPlanResp() throw() {} + + TStatus status; + ::Apache::Hadoop::Hive::Query plan; + + void __set_status(const TStatus& val) { + status = val; + } + + void __set_plan(const ::Apache::Hadoop::Hive::Query& val) { + plan = val; + } + + bool operator == (const TGetQueryPlanResp & rhs) const + { + if (!(status == rhs.status)) + return false; + if (!(plan == rhs.plan)) + return false; + return true; + } + bool operator != (const TGetQueryPlanResp &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TGetQueryPlanResp & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +void swap(TGetQueryPlanResp &a, TGetQueryPlanResp &b); + }}}}} // namespace #endif diff --git service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TCLIService.java service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TCLIService.java index b296c66..2c93304 100644 --- service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TCLIService.java +++ service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TCLIService.java @@ -67,6 +67,8 @@ public TFetchResultsResp FetchResults(TFetchResultsReq req) throws org.apache.thrift.TException; + public TGetQueryPlanResp GetQueryPlan(TExecuteStatementReq req) throws org.apache.thrift.TException; + } public interface AsyncIface { @@ -103,6 +105,8 @@ public void FetchResults(TFetchResultsReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void GetQueryPlan(TExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + } public static class Client extends org.apache.thrift.TServiceClient implements Iface { @@ -493,6 +497,29 @@ public TFetchResultsResp recv_FetchResults() throws org.apache.thrift.TException throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "FetchResults failed: unknown result"); } + public TGetQueryPlanResp GetQueryPlan(TExecuteStatementReq req) throws org.apache.thrift.TException + { + send_GetQueryPlan(req); + return recv_GetQueryPlan(); + } + + public void send_GetQueryPlan(TExecuteStatementReq req) throws org.apache.thrift.TException + { + GetQueryPlan_args args = new GetQueryPlan_args(); + args.setReq(req); + sendBase("GetQueryPlan", args); + } + + public TGetQueryPlanResp recv_GetQueryPlan() throws org.apache.thrift.TException + { + GetQueryPlan_result result = new GetQueryPlan_result(); + receiveBase(result, "GetQueryPlan"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "GetQueryPlan failed: unknown result"); + } + } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { @@ -1023,6 +1050,38 @@ public TFetchResultsResp getResult() throws org.apache.thrift.TException { } } + public void GetQueryPlan(TExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + GetQueryPlan_call method_call = new GetQueryPlan_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class GetQueryPlan_call extends org.apache.thrift.async.TAsyncMethodCall { + private TExecuteStatementReq req; + public GetQueryPlan_call(TExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("GetQueryPlan", org.apache.thrift.protocol.TMessageType.CALL, 0)); + GetQueryPlan_args args = new GetQueryPlan_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TGetQueryPlanResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_GetQueryPlan(); + } + } + } public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { @@ -1052,6 +1111,7 @@ protected Processor(I iface, Map extends org.apache.thrift.ProcessFunction { + public GetQueryPlan() { + super("GetQueryPlan"); + } + + public GetQueryPlan_args getEmptyArgsInstance() { + return new GetQueryPlan_args(); + } + + protected boolean isOneway() { + return false; + } + + public GetQueryPlan_result getResult(I iface, GetQueryPlan_args args) throws org.apache.thrift.TException { + GetQueryPlan_result result = new GetQueryPlan_result(); + result.success = iface.GetQueryPlan(args.req); + return result; + } + } + } public static class OpenSession_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { @@ -12993,4 +13073,730 @@ public void read(org.apache.thrift.protocol.TProtocol prot, FetchResults_result } + public static class GetQueryPlan_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GetQueryPlan_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new GetQueryPlan_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new GetQueryPlan_argsTupleSchemeFactory()); + } + + private TExecuteStatementReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TExecuteStatementReq.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(GetQueryPlan_args.class, metaDataMap); + } + + public GetQueryPlan_args() { + } + + public GetQueryPlan_args( + TExecuteStatementReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public GetQueryPlan_args(GetQueryPlan_args other) { + if (other.isSetReq()) { + this.req = new TExecuteStatementReq(other.req); + } + } + + public GetQueryPlan_args deepCopy() { + return new GetQueryPlan_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TExecuteStatementReq getReq() { + return this.req; + } + + public void setReq(TExecuteStatementReq req) { + this.req = req; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TExecuteStatementReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof GetQueryPlan_args) + return this.equals((GetQueryPlan_args)that); + return false; + } + + public boolean equals(GetQueryPlan_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_req = true && (isSetReq()); + builder.append(present_req); + if (present_req) + builder.append(req); + + return builder.toHashCode(); + } + + public int compareTo(GetQueryPlan_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + GetQueryPlan_args typedOther = (GetQueryPlan_args)other; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(typedOther.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, typedOther.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("GetQueryPlan_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (req != null) { + req.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class GetQueryPlan_argsStandardSchemeFactory implements SchemeFactory { + public GetQueryPlan_argsStandardScheme getScheme() { + return new GetQueryPlan_argsStandardScheme(); + } + } + + private static class GetQueryPlan_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, GetQueryPlan_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, GetQueryPlan_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class GetQueryPlan_argsTupleSchemeFactory implements SchemeFactory { + public GetQueryPlan_argsTupleScheme getScheme() { + return new GetQueryPlan_argsTupleScheme(); + } + } + + private static class GetQueryPlan_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, GetQueryPlan_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, GetQueryPlan_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class GetQueryPlan_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GetQueryPlan_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new GetQueryPlan_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new GetQueryPlan_resultTupleSchemeFactory()); + } + + private TGetQueryPlanResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TGetQueryPlanResp.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(GetQueryPlan_result.class, metaDataMap); + } + + public GetQueryPlan_result() { + } + + public GetQueryPlan_result( + TGetQueryPlanResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public GetQueryPlan_result(GetQueryPlan_result other) { + if (other.isSetSuccess()) { + this.success = new TGetQueryPlanResp(other.success); + } + } + + public GetQueryPlan_result deepCopy() { + return new GetQueryPlan_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TGetQueryPlanResp getSuccess() { + return this.success; + } + + public void setSuccess(TGetQueryPlanResp success) { + this.success = success; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TGetQueryPlanResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof GetQueryPlan_result) + return this.equals((GetQueryPlan_result)that); + return false; + } + + public boolean equals(GetQueryPlan_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + return builder.toHashCode(); + } + + public int compareTo(GetQueryPlan_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + GetQueryPlan_result typedOther = (GetQueryPlan_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("GetQueryPlan_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class GetQueryPlan_resultStandardSchemeFactory implements SchemeFactory { + public GetQueryPlan_resultStandardScheme getScheme() { + return new GetQueryPlan_resultStandardScheme(); + } + } + + private static class GetQueryPlan_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, GetQueryPlan_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TGetQueryPlanResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, GetQueryPlan_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class GetQueryPlan_resultTupleSchemeFactory implements SchemeFactory { + public GetQueryPlan_resultTupleScheme getScheme() { + return new GetQueryPlan_resultTupleScheme(); + } + } + + private static class GetQueryPlan_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, GetQueryPlan_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, GetQueryPlan_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TGetQueryPlanResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + } diff --git service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TGetQueryPlanResp.java service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TGetQueryPlanResp.java new file mode 100644 index 0000000..f51b8fb --- /dev/null +++ service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TGetQueryPlanResp.java @@ -0,0 +1,496 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.hive.service.cli.thrift; + +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TGetQueryPlanResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TGetQueryPlanResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField PLAN_FIELD_DESC = new org.apache.thrift.protocol.TField("plan", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TGetQueryPlanRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TGetQueryPlanRespTupleSchemeFactory()); + } + + private TStatus status; // required + private org.apache.hadoop.hive.ql.plan.api.Query plan; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + PLAN((short)2, "plan"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // PLAN + return PLAN; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TStatus.class))); + tmpMap.put(_Fields.PLAN, new org.apache.thrift.meta_data.FieldMetaData("plan", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.hadoop.hive.ql.plan.api.Query.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TGetQueryPlanResp.class, metaDataMap); + } + + public TGetQueryPlanResp() { + } + + public TGetQueryPlanResp( + TStatus status, + org.apache.hadoop.hive.ql.plan.api.Query plan) + { + this(); + this.status = status; + this.plan = plan; + } + + /** + * Performs a deep copy on other. + */ + public TGetQueryPlanResp(TGetQueryPlanResp other) { + if (other.isSetStatus()) { + this.status = new TStatus(other.status); + } + if (other.isSetPlan()) { + this.plan = new org.apache.hadoop.hive.ql.plan.api.Query(other.plan); + } + } + + public TGetQueryPlanResp deepCopy() { + return new TGetQueryPlanResp(this); + } + + @Override + public void clear() { + this.status = null; + this.plan = null; + } + + public TStatus getStatus() { + return this.status; + } + + public void setStatus(TStatus status) { + this.status = status; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public org.apache.hadoop.hive.ql.plan.api.Query getPlan() { + return this.plan; + } + + public void setPlan(org.apache.hadoop.hive.ql.plan.api.Query plan) { + this.plan = plan; + } + + public void unsetPlan() { + this.plan = null; + } + + /** Returns true if field plan is set (has been assigned a value) and false otherwise */ + public boolean isSetPlan() { + return this.plan != null; + } + + public void setPlanIsSet(boolean value) { + if (!value) { + this.plan = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TStatus)value); + } + break; + + case PLAN: + if (value == null) { + unsetPlan(); + } else { + setPlan((org.apache.hadoop.hive.ql.plan.api.Query)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case PLAN: + return getPlan(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case PLAN: + return isSetPlan(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TGetQueryPlanResp) + return this.equals((TGetQueryPlanResp)that); + return false; + } + + public boolean equals(TGetQueryPlanResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_plan = true && this.isSetPlan(); + boolean that_present_plan = true && that.isSetPlan(); + if (this_present_plan || that_present_plan) { + if (!(this_present_plan && that_present_plan)) + return false; + if (!this.plan.equals(that.plan)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_status = true && (isSetStatus()); + builder.append(present_status); + if (present_status) + builder.append(status); + + boolean present_plan = true && (isSetPlan()); + builder.append(present_plan); + if (present_plan) + builder.append(plan); + + return builder.toHashCode(); + } + + public int compareTo(TGetQueryPlanResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + TGetQueryPlanResp typedOther = (TGetQueryPlanResp)other; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPlan()).compareTo(typedOther.isSetPlan()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPlan()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.plan, typedOther.plan); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TGetQueryPlanResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (!first) sb.append(", "); + sb.append("plan:"); + if (this.plan == null) { + sb.append("null"); + } else { + sb.append(this.plan); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetStatus()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString()); + } + + if (!isSetPlan()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'plan' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + if (status != null) { + status.validate(); + } + if (plan != null) { + plan.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TGetQueryPlanRespStandardSchemeFactory implements SchemeFactory { + public TGetQueryPlanRespStandardScheme getScheme() { + return new TGetQueryPlanRespStandardScheme(); + } + } + + private static class TGetQueryPlanRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TGetQueryPlanResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TStatus(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PLAN + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.plan = new org.apache.hadoop.hive.ql.plan.api.Query(); + struct.plan.read(iprot); + struct.setPlanIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TGetQueryPlanResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.plan != null) { + oprot.writeFieldBegin(PLAN_FIELD_DESC); + struct.plan.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TGetQueryPlanRespTupleSchemeFactory implements SchemeFactory { + public TGetQueryPlanRespTupleScheme getScheme() { + return new TGetQueryPlanRespTupleScheme(); + } + } + + private static class TGetQueryPlanRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TGetQueryPlanResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + struct.plan.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TGetQueryPlanResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TStatus(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + struct.plan = new org.apache.hadoop.hive.ql.plan.api.Query(); + struct.plan.read(iprot); + struct.setPlanIsSet(true); + } + } + +} + diff --git service/src/gen/thrift/gen-php/TCLIService.php service/src/gen/thrift/gen-php/TCLIService.php index bbb6b0f..1b7f320 100644 --- service/src/gen/thrift/gen-php/TCLIService.php +++ service/src/gen/thrift/gen-php/TCLIService.php @@ -32,6 +32,7 @@ interface TCLIServiceIf { public function CloseOperation(\TCloseOperationReq $req); public function GetResultSetMetadata(\TGetResultSetMetadataReq $req); public function FetchResults(\TFetchResultsReq $req); + public function GetQueryPlan(\TExecuteStatementReq $req); } class TCLIServiceClient implements \TCLIServiceIf { @@ -861,6 +862,57 @@ class TCLIServiceClient implements \TCLIServiceIf { throw new \Exception("FetchResults failed: unknown result"); } + public function GetQueryPlan(\TExecuteStatementReq $req) + { + $this->send_GetQueryPlan($req); + return $this->recv_GetQueryPlan(); + } + + public function send_GetQueryPlan(\TExecuteStatementReq $req) + { + $args = new \TCLIService_GetQueryPlan_args(); + $args->req = $req; + $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'GetQueryPlan', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('GetQueryPlan', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_GetQueryPlan() + { + $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\TCLIService_GetQueryPlan_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \TCLIService_GetQueryPlan_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("GetQueryPlan failed: unknown result"); + } + } // HELPER FUNCTIONS AND STRUCTURES @@ -3329,4 +3381,158 @@ class TCLIService_FetchResults_result { } +class TCLIService_GetQueryPlan_args { + static $_TSPEC; + + public $req = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'req', + 'type' => TType::STRUCT, + 'class' => '\TExecuteStatementReq', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['req'])) { + $this->req = $vals['req']; + } + } + } + + public function getName() { + return 'TCLIService_GetQueryPlan_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->req = new \TExecuteStatementReq(); + $xfer += $this->req->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TCLIService_GetQueryPlan_args'); + if ($this->req !== null) { + if (!is_object($this->req)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('req', TType::STRUCT, 1); + $xfer += $this->req->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class TCLIService_GetQueryPlan_result { + static $_TSPEC; + + public $success = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::STRUCT, + 'class' => '\TGetQueryPlanResp', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + } + } + + public function getName() { + return 'TCLIService_GetQueryPlan_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::STRUCT) { + $this->success = new \TGetQueryPlanResp(); + $xfer += $this->success->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TCLIService_GetQueryPlan_result'); + if ($this->success !== null) { + if (!is_object($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0); + $xfer += $this->success->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + diff --git service/src/gen/thrift/gen-py/TCLIService/TCLIService-remote service/src/gen/thrift/gen-py/TCLIService/TCLIService-remote old mode 100644 new mode 100755 index ab0d501..2dc6633 --- service/src/gen/thrift/gen-py/TCLIService/TCLIService-remote +++ service/src/gen/thrift/gen-py/TCLIService/TCLIService-remote @@ -39,6 +39,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print ' TCloseOperationResp CloseOperation(TCloseOperationReq req)' print ' TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req)' print ' TFetchResultsResp FetchResults(TFetchResultsReq req)' + print ' TGetQueryPlanResp GetQueryPlan(TExecuteStatementReq req)' print '' sys.exit(0) @@ -186,6 +187,12 @@ elif cmd == 'FetchResults': sys.exit(1) pp.pprint(client.FetchResults(eval(args[0]),)) +elif cmd == 'GetQueryPlan': + if len(args) != 1: + print 'GetQueryPlan requires 1 args' + sys.exit(1) + pp.pprint(client.GetQueryPlan(eval(args[0]),)) + else: print 'Unrecognized method %s' % cmd sys.exit(1) diff --git service/src/gen/thrift/gen-py/TCLIService/TCLIService.py service/src/gen/thrift/gen-py/TCLIService/TCLIService.py index 6d2255b..84d8d24 100644 --- service/src/gen/thrift/gen-py/TCLIService/TCLIService.py +++ service/src/gen/thrift/gen-py/TCLIService/TCLIService.py @@ -130,6 +130,13 @@ def FetchResults(self, req): """ pass + def GetQueryPlan(self, req): + """ + Parameters: + - req + """ + pass + class Client(Iface): def __init__(self, iprot, oprot=None): @@ -618,6 +625,36 @@ def recv_FetchResults(self, ): return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "FetchResults failed: unknown result"); + def GetQueryPlan(self, req): + """ + Parameters: + - req + """ + self.send_GetQueryPlan(req) + return self.recv_GetQueryPlan() + + def send_GetQueryPlan(self, req): + self._oprot.writeMessageBegin('GetQueryPlan', TMessageType.CALL, self._seqid) + args = GetQueryPlan_args() + args.req = req + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_GetQueryPlan(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = GetQueryPlan_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "GetQueryPlan failed: unknown result"); + class Processor(Iface, TProcessor): def __init__(self, handler): @@ -639,6 +676,7 @@ def __init__(self, handler): self._processMap["CloseOperation"] = Processor.process_CloseOperation self._processMap["GetResultSetMetadata"] = Processor.process_GetResultSetMetadata self._processMap["FetchResults"] = Processor.process_FetchResults + self._processMap["GetQueryPlan"] = Processor.process_GetQueryPlan def process(self, iprot, oprot): (name, type, seqid) = iprot.readMessageBegin() @@ -831,6 +869,17 @@ def process_FetchResults(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_GetQueryPlan(self, seqid, iprot, oprot): + args = GetQueryPlan_args() + args.read(iprot) + iprot.readMessageEnd() + result = GetQueryPlan_result() + result.success = self._handler.GetQueryPlan(args.req) + oprot.writeMessageBegin("GetQueryPlan", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + # HELPER FUNCTIONS AND STRUCTURES @@ -2769,3 +2818,124 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) + +class GetQueryPlan_args: + """ + Attributes: + - req + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'req', (TExecuteStatementReq, TExecuteStatementReq.thrift_spec), None, ), # 1 + ) + + def __init__(self, req=None,): + self.req = req + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.req = TExecuteStatementReq() + self.req.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('GetQueryPlan_args') + if self.req is not None: + oprot.writeFieldBegin('req', TType.STRUCT, 1) + self.req.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class GetQueryPlan_result: + """ + Attributes: + - success + """ + + thrift_spec = ( + (0, TType.STRUCT, 'success', (TGetQueryPlanResp, TGetQueryPlanResp.thrift_spec), None, ), # 0 + ) + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = TGetQueryPlanResp() + self.success.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('GetQueryPlan_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git service/src/gen/thrift/gen-py/TCLIService/ttypes.py service/src/gen/thrift/gen-py/TCLIService/ttypes.py index 171b8c1..00aeb6a 100644 --- service/src/gen/thrift/gen-py/TCLIService/ttypes.py +++ service/src/gen/thrift/gen-py/TCLIService/ttypes.py @@ -7,6 +7,8 @@ # from thrift.Thrift import TType, TMessageType, TException, TApplicationException +import queryplan.ttypes + from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol, TProtocol @@ -5056,3 +5058,81 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) + +class TGetQueryPlanResp: + """ + Attributes: + - status + - plan + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1 + (2, TType.STRUCT, 'plan', (queryplan.ttypes.Query, queryplan.ttypes.Query.thrift_spec), None, ), # 2 + ) + + def __init__(self, status=None, plan=None,): + self.status = status + self.plan = plan + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.status = TStatus() + self.status.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.plan = queryplan.ttypes.Query() + self.plan.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('TGetQueryPlanResp') + if self.status is not None: + oprot.writeFieldBegin('status', TType.STRUCT, 1) + self.status.write(oprot) + oprot.writeFieldEnd() + if self.plan is not None: + oprot.writeFieldBegin('plan', TType.STRUCT, 2) + self.plan.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.status is None: + raise TProtocol.TProtocolException(message='Required field status is unset!') + if self.plan is None: + raise TProtocol.TProtocolException(message='Required field plan is unset!') + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git service/src/gen/thrift/gen-py/hive_service/ThriftHive-remote service/src/gen/thrift/gen-py/hive_service/ThriftHive-remote old mode 100644 new mode 100755 diff --git service/src/gen/thrift/gen-rb/t_c_l_i_service.rb service/src/gen/thrift/gen-rb/t_c_l_i_service.rb index 2455e3b..1440ae0 100644 --- service/src/gen/thrift/gen-rb/t_c_l_i_service.rb +++ service/src/gen/thrift/gen-rb/t_c_l_i_service.rb @@ -251,6 +251,21 @@ module TCLIService raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'FetchResults failed: unknown result') end + def GetQueryPlan(req) + send_GetQueryPlan(req) + return recv_GetQueryPlan() + end + + def send_GetQueryPlan(req) + send_message('GetQueryPlan', GetQueryPlan_args, :req => req) + end + + def recv_GetQueryPlan() + result = receive_message(GetQueryPlan_result) + return result.success unless result.success.nil? + raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'GetQueryPlan failed: unknown result') + end + end class Processor @@ -368,6 +383,13 @@ module TCLIService write_result(result, oprot, 'FetchResults', seqid) end + def process_GetQueryPlan(seqid, iprot, oprot) + args = read_args(iprot, GetQueryPlan_args) + result = GetQueryPlan_result.new() + result.success = @handler.GetQueryPlan(args.req) + write_result(result, oprot, 'GetQueryPlan', seqid) + end + end # HELPER FUNCTIONS AND STRUCTURES @@ -884,5 +906,37 @@ module TCLIService ::Thrift::Struct.generate_accessors self end + class GetQueryPlan_args + include ::Thrift::Struct, ::Thrift::Struct_Union + REQ = 1 + + FIELDS = { + REQ => {:type => ::Thrift::Types::STRUCT, :name => 'req', :class => ::TExecuteStatementReq} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + + class GetQueryPlan_result + include ::Thrift::Struct, ::Thrift::Struct_Union + SUCCESS = 0 + + FIELDS = { + SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::TGetQueryPlanResp} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + end diff --git service/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb service/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb index 5336945..47260bc 100644 --- service/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb +++ service/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb @@ -5,6 +5,8 @@ # require 'thrift' +require 'queryplan_types' + module TProtocolVersion HIVE_CLI_SERVICE_PROTOCOL_V1 = 0 @@ -1407,3 +1409,23 @@ class TFetchResultsResp ::Thrift::Struct.generate_accessors self end +class TGetQueryPlanResp + include ::Thrift::Struct, ::Thrift::Struct_Union + STATUS = 1 + PLAN = 2 + + FIELDS = { + STATUS => {:type => ::Thrift::Types::STRUCT, :name => 'status', :class => ::TStatus}, + PLAN => {:type => ::Thrift::Types::STRUCT, :name => 'plan', :class => ::Query} + } + + def struct_fields; FIELDS; end + + def validate + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field status is unset!') unless @status + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field plan is unset!') unless @plan + end + + ::Thrift::Struct.generate_accessors self +end + diff --git service/src/java/org/apache/hive/service/cli/CLIService.java service/src/java/org/apache/hive/service/cli/CLIService.java index 035e689..0e60b93 100644 --- service/src/java/org/apache/hive/service/cli/CLIService.java +++ service/src/java/org/apache/hive/service/cli/CLIService.java @@ -31,10 +31,12 @@ import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.plan.api.Query; import org.apache.hadoop.hive.shims.ShimLoader; import org.apache.hive.service.CompositeService; import org.apache.hive.service.ServiceException; import org.apache.hive.service.auth.HiveAuthFactory; +import org.apache.hive.service.cli.session.HiveSession; import org.apache.hive.service.cli.session.SessionManager; /** @@ -305,6 +307,15 @@ public RowSet fetchResults(OperationHandle opHandle) return rowSet; } + @Override + public Query getQueryPlan(SessionHandle sessionHandle, String statement, + Map confOverlay) throws HiveSQLException { + HiveSession session = sessionManager.getSession(sessionHandle); + Query plan = session.getQueryPlan(statement, confOverlay); + LOG.info(sessionHandle + " :getQueryPlan()"); + return plan; + } + // obtain delegation token for the give user from metastore public synchronized String getDelegationTokenFromMetaStore(String owner) throws HiveSQLException, UnsupportedOperationException, LoginException, IOException { diff --git service/src/java/org/apache/hive/service/cli/CLIServiceClient.java service/src/java/org/apache/hive/service/cli/CLIServiceClient.java index fe49025..2a6c101 100644 --- service/src/java/org/apache/hive/service/cli/CLIServiceClient.java +++ service/src/java/org/apache/hive/service/cli/CLIServiceClient.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.Map; +import org.apache.hadoop.hive.ql.plan.api.Query; + /** * CLIServiceClient. @@ -149,4 +151,7 @@ public RowSet fetchResults(OperationHandle opHandle) throws HiveSQLException { return fetchResults(opHandle, FetchOrientation.FETCH_NEXT, 1000); } + @Override + public abstract Query getQueryPlan(SessionHandle sessionHandle, String statement, + Map confOverlay) throws HiveSQLException; } diff --git service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java index 38d64c8..d7afc19 100644 --- service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java +++ service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.Map; +import org.apache.hadoop.hive.ql.plan.api.Query; + /** * EmbeddedCLIServiceClient. @@ -176,4 +178,10 @@ public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientatio return cliService.fetchResults(opHandle, orientation, maxRows); } + @Override + public Query getQueryPlan(SessionHandle sessionHandle, String statement, + Map confOverlay) throws HiveSQLException { + return cliService.getQueryPlan(sessionHandle, statement, confOverlay); + } + } diff --git service/src/java/org/apache/hive/service/cli/ICLIService.java service/src/java/org/apache/hive/service/cli/ICLIService.java index 7e863b5..e0fe088 100644 --- service/src/java/org/apache/hive/service/cli/ICLIService.java +++ service/src/java/org/apache/hive/service/cli/ICLIService.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.Map; +import org.apache.hadoop.hive.ql.plan.api.Query; + @@ -87,4 +89,7 @@ public abstract RowSet fetchResults(OperationHandle opHandle, FetchOrientation o public abstract RowSet fetchResults(OperationHandle opHandle) throws HiveSQLException; + public abstract Query getQueryPlan(SessionHandle sessionHandle, String statement, Map confOverlay) + throws HiveSQLException; + } diff --git service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java index 2fee93e..d00655e 100644 --- service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java +++ service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java @@ -31,6 +31,7 @@ import org.apache.hadoop.hive.ql.CommandNeedRetryException; import org.apache.hadoop.hive.ql.Driver; import org.apache.hadoop.hive.ql.parse.VariableSubstitution; +import org.apache.hadoop.hive.ql.plan.api.Query; import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.hive.serde.serdeConstants; @@ -208,7 +209,7 @@ private static Object convertLazyToJava(Object o, ObjectInspector oi) { // for now, expose non-primitive as a string // TODO: expose non-primitive as a structured object while maintaining JDBC compliance if (oi.getCategory() != ObjectInspector.Category.PRIMITIVE) { - return SerDeUtils.getJSONString(o, oi); + return SerDeUtils.getJSONString(o, oi); } return obj; } @@ -259,4 +260,18 @@ private SerDe getSerDe() throws SQLException { return serde; } + public Query getQueryPlan() throws HiveSQLException { + try { + driver = new Driver(getParentSession().getHiveConf()); + int errorCode = driver.compile(statement); + if (errorCode != 0) { + throw new HiveSQLException("Error getting query plan: " + errorCode); + } else { + return driver.getQueryPlan(); + } + } catch (IOException e) { + throw new HiveSQLException(e); + } + } + } diff --git service/src/java/org/apache/hive/service/cli/session/HiveSession.java service/src/java/org/apache/hive/service/cli/session/HiveSession.java index 5fa8fa1..6f2ae8c 100644 --- service/src/java/org/apache/hive/service/cli/session/HiveSession.java +++ service/src/java/org/apache/hive/service/cli/session/HiveSession.java @@ -23,6 +23,7 @@ import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.IMetaStoreClient; +import org.apache.hadoop.hive.ql.plan.api.Query; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hive.service.cli.FetchOrientation; import org.apache.hive.service.cli.GetInfoType; @@ -164,4 +165,6 @@ public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientatio public String getUserName(); public void setUserName(String userName); + + public Query getQueryPlan(String statement, Map confOverlay) throws HiveSQLException; } diff --git service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java index 7254491..3046bbb 100644 --- service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java +++ service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java @@ -35,6 +33,7 @@ import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.ql.history.HiveHistory; +import org.apache.hadoop.hive.ql.plan.api.Query; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hive.common.util.HiveVersionInfo; import org.apache.hive.service.cli.FetchOrientation; @@ -54,6 +53,7 @@ import org.apache.hive.service.cli.operation.GetTypeInfoOperation; import org.apache.hive.service.cli.operation.MetadataOperation; import org.apache.hive.service.cli.operation.OperationManager; +import org.apache.hive.service.cli.operation.SQLOperation; /** * HiveSession @@ -385,4 +385,18 @@ public RowSet fetchResults(OperationHandle opHandle) throws HiveSQLException { protected HiveSession getSession() { return this; } + + @Override + public Query getQueryPlan(String statement, Map params) + throws HiveSQLException { + ExecuteStatementOperation operation = getOperationManager() + .newExecuteStatementOperation(getSession(), statement, params); + + if (operation instanceof SQLOperation) { + SQLOperation sqlOperation = (SQLOperation) operation; + return sqlOperation.getQueryPlan(); + } else { + throw new HiveSQLException("Not an SQL statement: " + statement); + } + } } diff --git service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java index 0788ead..daec2a7 100644 --- service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java +++ service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java @@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; +import org.apache.hadoop.hive.ql.plan.api.Query; import org.apache.hive.service.AbstractService; import org.apache.hive.service.auth.HiveAuthFactory; import org.apache.hive.service.cli.CLIService; @@ -392,6 +393,23 @@ public TFetchResultsResp FetchResults(TFetchResultsReq req) throws TException { return resp; } + @Override + public TGetQueryPlanResp GetQueryPlan(TExecuteStatementReq req) throws TException { + TGetQueryPlanResp resp = new TGetQueryPlanResp(); + + try { + SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle()); + String statement = req.getStatement(); + Map confOverlay = req.getConfOverlay(); + Query query = cliService.getQueryPlan(sessionHandle, statement, confOverlay); + resp.setPlan(query); + resp.setStatus(OK_STATUS); + } catch (Exception e) { + e.printStackTrace(); + resp.setStatus(HiveSQLException.toTStatus(e)); + } + return resp; + } @Override public void run() { diff --git service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java index 5eb6157..71c4a8b 100644 --- service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java +++ service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; +import org.apache.hadoop.hive.ql.plan.api.Query; import org.apache.hive.service.cli.CLIServiceClient; import org.apache.hive.service.cli.FetchOrientation; import org.apache.hive.service.cli.GetInfoType; @@ -370,4 +371,20 @@ public RowSet fetchResults(OperationHandle opHandle) throws HiveSQLException { // TODO: set the correct default fetch size return fetchResults(opHandle, FetchOrientation.FETCH_NEXT, 10000); } + + @Override + public Query getQueryPlan(SessionHandle sessionHandle, String statement, + Map confOverlay) throws HiveSQLException { + try { + TExecuteStatementReq req = new TExecuteStatementReq(sessionHandle.toTSessionHandle(), statement); + req.setConfOverlay(confOverlay); + TGetQueryPlanResp resp = cliService.GetQueryPlan(req); + checkStatus(resp.getStatus()); + return resp.getPlan(); + } catch (HiveSQLException e) { + throw e; + } catch (Exception e) { + throw new HiveSQLException(e); + } + } } diff --git service/src/test/org/apache/hive/service/cli/CLIServiceTest.java service/src/test/org/apache/hive/service/cli/CLIServiceTest.java index 6742f1a..e150ab5 100644 --- service/src/test/org/apache/hive/service/cli/CLIServiceTest.java +++ service/src/test/org/apache/hive/service/cli/CLIServiceTest.java @@ -23,7 +23,13 @@ import java.util.Collections; import java.util.HashMap; +import java.util.List; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.Driver; +import org.apache.hadoop.hive.ql.plan.api.Query; +import org.apache.hadoop.hive.ql.plan.api.Stage; +import org.apache.hadoop.hive.ql.plan.api.Task; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -113,4 +119,54 @@ public void getInfoTest() throws Exception { client.closeSession(sessionHandle); } + + @Test + public void getQueryPlanTest() throws Exception { + HashMap confOverlay = new HashMap(); + SessionHandle sessionHandle = client.openSession("tom", "password", + new HashMap()); + assertNotNull(sessionHandle); + + client.executeStatement(sessionHandle, + "CREATE TABLE TEST_QUERY_PLAN_TAB(ID STRING)", confOverlay); + + String testquery = "SELECT ID FROM TEST_QUERY_PLAN_TAB"; + Query plan = client.getQueryPlan(sessionHandle, testquery, confOverlay); + assertNotNull(plan); + List stgList = plan.getStageList(); + assertNotNull(stgList); + + Driver expDriver = null; + + try { + expDriver = new Driver(new HiveConf(this.getClass())); + expDriver.compile(testquery); + Query expPlan = expDriver.getQueryPlan(); + + assertEquals(expPlan.getStageList().size(), stgList.size()); + + for (int i = 0; i < stgList.size(); i++) { + Stage stg = stgList.get(i); + Stage expStg = expPlan.getStageList().get(i); + assertEquals(expStg.getStageType(), stg.getStageType()); + + List stgTaskList = stg.getTaskList(); + assertNotNull(stgTaskList); + List expStgTaskList = expStg.getTaskList(); + + assertEquals(expStg.getTaskListSize(), stg.getTaskListSize()); + + for (int j = 0; j < stgTaskList.size(); j++) { + Task stgTask = stgTaskList.get(j); + Task expTask = expStgTaskList.get(j); + assertEquals(expTask.getTaskType(), stgTask.getTaskType()); + } + } + } finally { + if (expDriver != null) { + expDriver.close(); + } + } + System.out.println("getQueryPlan():" + plan.toString()); + } }