Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impalad-query-executor.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_TESTUTIL_IMPALAD_QUERY_EXECUTOR_H
17 #define IMPALA_TESTUTIL_IMPALAD_QUERY_EXECUTOR_H
18 
19 #include <string>
20 #include <vector>
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/shared_ptr.hpp>
23 #include <boost/thread/thread.hpp>
24 
25 #include "rpc/thrift-client.h"
26 #include "common/status.h"
27 #include "runtime/runtime-state.h"
28 #include "runtime/types.h"
29 #include "gen-cpp/Types_types.h"
30 #include "gen-cpp/ImpalaService.h"
31 #include "gen-cpp/ImpalaService_types.h"
32 
33 namespace impala {
34 
35 class RowBatch;
36 
39  public:
42 
43  Status Setup();
44 
47  Status Exec(const std::string& query_string,
48  std::vector<Apache::Hadoop::Hive::FieldSchema>* col_types);
49 
51  Status Explain(const std::string& query_string, std::string* explain_plan);
52 
60  Status FetchResult(RowBatch** batch);
61 
65  Status FetchResult(std::string* row);
66 
70  Status FetchResult(std::vector<void*>* row);
71 
74  std::string ErrorString() const;
75 
77  std::string FileErrors() const;
78 
81 
82  bool eos() { return eos_; }
83 
84  void setExecOptions(const std::vector<std::string>& exec_options) {
85  exec_options_ = exec_options;
86  }
87 
88  private:
90  boost::scoped_ptr<ThriftClient<ImpalaServiceClient> > client_;
91 
93  std::vector<std::string> exec_options_;
94 
96  beeswax::QueryHandle query_handle_;
97  beeswax::Results query_results_;
98  beeswax::QueryExplanation query_explanation_;
99 
102  bool eos_;
103 
105  Status Close();
106 };
107 
108 }
109 
110 #endif
Status Exec(const std::string &query_string, std::vector< Apache::Hadoop::Hive::FieldSchema > *col_types)
beeswax::QueryHandle query_handle_
Beeswax query handle and result.
Status Close()
call beeswax.close() for current query, if one in progress
boost::scoped_ptr< ThriftClient< ImpalaServiceClient > > client_
fe service-related
beeswax::QueryExplanation query_explanation_
std::vector< std::string > exec_options_
Execution options.
Query execution against running impalad process.
RuntimeProfile * query_profile()
Returns the counters for the entire query.
void setExecOptions(const std::vector< std::string > &exec_options)
std::string FileErrors() const
Returns a string representation of the file_errors_.
Status FetchResult(RowBatch **batch)
Status Explain(const std::string &query_string, std::string *explain_plan)
Return the explain plan for the query.