ImpalaHiveServer2Service-remote 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #!/usr/bin/env python
  2. #
  3. # Autogenerated by Thrift Compiler (0.13.0)
  4. #
  5. # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  6. #
  7. # options string: py:new_style
  8. #
  9. import sys
  10. import pprint
  11. if sys.version_info[0] > 2:
  12. from urllib.parse import urlparse
  13. else:
  14. from urlparse import urlparse
  15. from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient
  16. from thrift.protocol.TBinaryProtocol import TBinaryProtocol
  17. from ImpalaService import ImpalaHiveServer2Service
  18. from ImpalaService.ttypes import *
  19. if len(sys.argv) <= 1 or sys.argv[1] == '--help':
  20. print('')
  21. print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]')
  22. print('')
  23. print('Functions:')
  24. print(' TGetExecSummaryResp GetExecSummary(TGetExecSummaryReq req)')
  25. print(' TGetRuntimeProfileResp GetRuntimeProfile(TGetRuntimeProfileReq req)')
  26. print(' TOpenSessionResp OpenSession(TOpenSessionReq req)')
  27. print(' TCloseSessionResp CloseSession(TCloseSessionReq req)')
  28. print(' TGetInfoResp GetInfo(TGetInfoReq req)')
  29. print(' TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req)')
  30. print(' TGetTypeInfoResp GetTypeInfo(TGetTypeInfoReq req)')
  31. print(' TGetCatalogsResp GetCatalogs(TGetCatalogsReq req)')
  32. print(' TGetSchemasResp GetSchemas(TGetSchemasReq req)')
  33. print(' TGetTablesResp GetTables(TGetTablesReq req)')
  34. print(' TGetTableTypesResp GetTableTypes(TGetTableTypesReq req)')
  35. print(' TGetColumnsResp GetColumns(TGetColumnsReq req)')
  36. print(' TGetFunctionsResp GetFunctions(TGetFunctionsReq req)')
  37. print(' TGetOperationStatusResp GetOperationStatus(TGetOperationStatusReq req)')
  38. print(' TCancelOperationResp CancelOperation(TCancelOperationReq req)')
  39. print(' TCloseOperationResp CloseOperation(TCloseOperationReq req)')
  40. print(' TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req)')
  41. print(' TFetchResultsResp FetchResults(TFetchResultsReq req)')
  42. print(' TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req)')
  43. print(' TCancelDelegationTokenResp CancelDelegationToken(TCancelDelegationTokenReq req)')
  44. print(' TRenewDelegationTokenResp RenewDelegationToken(TRenewDelegationTokenReq req)')
  45. print(' TGetLogResp GetLog(TGetLogReq req)')
  46. print('')
  47. sys.exit(0)
  48. pp = pprint.PrettyPrinter(indent=2)
  49. host = 'localhost'
  50. port = 9090
  51. uri = ''
  52. framed = False
  53. ssl = False
  54. validate = True
  55. ca_certs = None
  56. keyfile = None
  57. certfile = None
  58. http = False
  59. argi = 1
  60. if sys.argv[argi] == '-h':
  61. parts = sys.argv[argi + 1].split(':')
  62. host = parts[0]
  63. if len(parts) > 1:
  64. port = int(parts[1])
  65. argi += 2
  66. if sys.argv[argi] == '-u':
  67. url = urlparse(sys.argv[argi + 1])
  68. parts = url[1].split(':')
  69. host = parts[0]
  70. if len(parts) > 1:
  71. port = int(parts[1])
  72. else:
  73. port = 80
  74. uri = url[2]
  75. if url[4]:
  76. uri += '?%s' % url[4]
  77. http = True
  78. argi += 2
  79. if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
  80. framed = True
  81. argi += 1
  82. if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':
  83. ssl = True
  84. argi += 1
  85. if sys.argv[argi] == '-novalidate':
  86. validate = False
  87. argi += 1
  88. if sys.argv[argi] == '-ca_certs':
  89. ca_certs = sys.argv[argi+1]
  90. argi += 2
  91. if sys.argv[argi] == '-keyfile':
  92. keyfile = sys.argv[argi+1]
  93. argi += 2
  94. if sys.argv[argi] == '-certfile':
  95. certfile = sys.argv[argi+1]
  96. argi += 2
  97. cmd = sys.argv[argi]
  98. args = sys.argv[argi + 1:]
  99. if http:
  100. transport = THttpClient.THttpClient(host, port, uri)
  101. else:
  102. if ssl:
  103. socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile)
  104. else:
  105. socket = TSocket.TSocket(host, port)
  106. if framed:
  107. transport = TTransport.TFramedTransport(socket)
  108. else:
  109. transport = TTransport.TBufferedTransport(socket)
  110. protocol = TBinaryProtocol(transport)
  111. client = ImpalaHiveServer2Service.Client(protocol)
  112. transport.open()
  113. if cmd == 'GetExecSummary':
  114. if len(args) != 1:
  115. print('GetExecSummary requires 1 args')
  116. sys.exit(1)
  117. pp.pprint(client.GetExecSummary(eval(args[0]),))
  118. elif cmd == 'GetRuntimeProfile':
  119. if len(args) != 1:
  120. print('GetRuntimeProfile requires 1 args')
  121. sys.exit(1)
  122. pp.pprint(client.GetRuntimeProfile(eval(args[0]),))
  123. elif cmd == 'OpenSession':
  124. if len(args) != 1:
  125. print('OpenSession requires 1 args')
  126. sys.exit(1)
  127. pp.pprint(client.OpenSession(eval(args[0]),))
  128. elif cmd == 'CloseSession':
  129. if len(args) != 1:
  130. print('CloseSession requires 1 args')
  131. sys.exit(1)
  132. pp.pprint(client.CloseSession(eval(args[0]),))
  133. elif cmd == 'GetInfo':
  134. if len(args) != 1:
  135. print('GetInfo requires 1 args')
  136. sys.exit(1)
  137. pp.pprint(client.GetInfo(eval(args[0]),))
  138. elif cmd == 'ExecuteStatement':
  139. if len(args) != 1:
  140. print('ExecuteStatement requires 1 args')
  141. sys.exit(1)
  142. pp.pprint(client.ExecuteStatement(eval(args[0]),))
  143. elif cmd == 'GetTypeInfo':
  144. if len(args) != 1:
  145. print('GetTypeInfo requires 1 args')
  146. sys.exit(1)
  147. pp.pprint(client.GetTypeInfo(eval(args[0]),))
  148. elif cmd == 'GetCatalogs':
  149. if len(args) != 1:
  150. print('GetCatalogs requires 1 args')
  151. sys.exit(1)
  152. pp.pprint(client.GetCatalogs(eval(args[0]),))
  153. elif cmd == 'GetSchemas':
  154. if len(args) != 1:
  155. print('GetSchemas requires 1 args')
  156. sys.exit(1)
  157. pp.pprint(client.GetSchemas(eval(args[0]),))
  158. elif cmd == 'GetTables':
  159. if len(args) != 1:
  160. print('GetTables requires 1 args')
  161. sys.exit(1)
  162. pp.pprint(client.GetTables(eval(args[0]),))
  163. elif cmd == 'GetTableTypes':
  164. if len(args) != 1:
  165. print('GetTableTypes requires 1 args')
  166. sys.exit(1)
  167. pp.pprint(client.GetTableTypes(eval(args[0]),))
  168. elif cmd == 'GetColumns':
  169. if len(args) != 1:
  170. print('GetColumns requires 1 args')
  171. sys.exit(1)
  172. pp.pprint(client.GetColumns(eval(args[0]),))
  173. elif cmd == 'GetFunctions':
  174. if len(args) != 1:
  175. print('GetFunctions requires 1 args')
  176. sys.exit(1)
  177. pp.pprint(client.GetFunctions(eval(args[0]),))
  178. elif cmd == 'GetOperationStatus':
  179. if len(args) != 1:
  180. print('GetOperationStatus requires 1 args')
  181. sys.exit(1)
  182. pp.pprint(client.GetOperationStatus(eval(args[0]),))
  183. elif cmd == 'CancelOperation':
  184. if len(args) != 1:
  185. print('CancelOperation requires 1 args')
  186. sys.exit(1)
  187. pp.pprint(client.CancelOperation(eval(args[0]),))
  188. elif cmd == 'CloseOperation':
  189. if len(args) != 1:
  190. print('CloseOperation requires 1 args')
  191. sys.exit(1)
  192. pp.pprint(client.CloseOperation(eval(args[0]),))
  193. elif cmd == 'GetResultSetMetadata':
  194. if len(args) != 1:
  195. print('GetResultSetMetadata requires 1 args')
  196. sys.exit(1)
  197. pp.pprint(client.GetResultSetMetadata(eval(args[0]),))
  198. elif cmd == 'FetchResults':
  199. if len(args) != 1:
  200. print('FetchResults requires 1 args')
  201. sys.exit(1)
  202. pp.pprint(client.FetchResults(eval(args[0]),))
  203. elif cmd == 'GetDelegationToken':
  204. if len(args) != 1:
  205. print('GetDelegationToken requires 1 args')
  206. sys.exit(1)
  207. pp.pprint(client.GetDelegationToken(eval(args[0]),))
  208. elif cmd == 'CancelDelegationToken':
  209. if len(args) != 1:
  210. print('CancelDelegationToken requires 1 args')
  211. sys.exit(1)
  212. pp.pprint(client.CancelDelegationToken(eval(args[0]),))
  213. elif cmd == 'RenewDelegationToken':
  214. if len(args) != 1:
  215. print('RenewDelegationToken requires 1 args')
  216. sys.exit(1)
  217. pp.pprint(client.RenewDelegationToken(eval(args[0]),))
  218. elif cmd == 'GetLog':
  219. if len(args) != 1:
  220. print('GetLog requires 1 args')
  221. sys.exit(1)
  222. pp.pprint(client.GetLog(eval(args[0]),))
  223. else:
  224. print('Unrecognized method %s' % cmd)
  225. sys.exit(1)
  226. transport.close()