ImpalaHiveServer2Service-remote 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. #!/usr/bin/env python
  2. #
  3. # Autogenerated by Thrift Compiler (0.9.3)
  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. from urlparse import urlparse
  12. from thrift.transport import TTransport
  13. from thrift.transport import TSocket
  14. from thrift.transport import TSSLSocket
  15. from thrift.transport import THttpClient
  16. from thrift.protocol 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]] 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. http = False
  55. argi = 1
  56. if sys.argv[argi] == '-h':
  57. parts = sys.argv[argi+1].split(':')
  58. host = parts[0]
  59. if len(parts) > 1:
  60. port = int(parts[1])
  61. argi += 2
  62. if sys.argv[argi] == '-u':
  63. url = urlparse(sys.argv[argi+1])
  64. parts = url[1].split(':')
  65. host = parts[0]
  66. if len(parts) > 1:
  67. port = int(parts[1])
  68. else:
  69. port = 80
  70. uri = url[2]
  71. if url[4]:
  72. uri += '?%s' % url[4]
  73. http = True
  74. argi += 2
  75. if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
  76. framed = True
  77. argi += 1
  78. if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':
  79. ssl = True
  80. argi += 1
  81. cmd = sys.argv[argi]
  82. args = sys.argv[argi+1:]
  83. if http:
  84. transport = THttpClient.THttpClient(host, port, uri)
  85. else:
  86. socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else TSocket.TSocket(host, port)
  87. if framed:
  88. transport = TTransport.TFramedTransport(socket)
  89. else:
  90. transport = TTransport.TBufferedTransport(socket)
  91. protocol = TBinaryProtocol.TBinaryProtocol(transport)
  92. client = ImpalaHiveServer2Service.Client(protocol)
  93. transport.open()
  94. if cmd == 'GetExecSummary':
  95. if len(args) != 1:
  96. print('GetExecSummary requires 1 args')
  97. sys.exit(1)
  98. pp.pprint(client.GetExecSummary(eval(args[0]),))
  99. elif cmd == 'GetRuntimeProfile':
  100. if len(args) != 1:
  101. print('GetRuntimeProfile requires 1 args')
  102. sys.exit(1)
  103. pp.pprint(client.GetRuntimeProfile(eval(args[0]),))
  104. elif cmd == 'OpenSession':
  105. if len(args) != 1:
  106. print('OpenSession requires 1 args')
  107. sys.exit(1)
  108. pp.pprint(client.OpenSession(eval(args[0]),))
  109. elif cmd == 'CloseSession':
  110. if len(args) != 1:
  111. print('CloseSession requires 1 args')
  112. sys.exit(1)
  113. pp.pprint(client.CloseSession(eval(args[0]),))
  114. elif cmd == 'GetInfo':
  115. if len(args) != 1:
  116. print('GetInfo requires 1 args')
  117. sys.exit(1)
  118. pp.pprint(client.GetInfo(eval(args[0]),))
  119. elif cmd == 'ExecuteStatement':
  120. if len(args) != 1:
  121. print('ExecuteStatement requires 1 args')
  122. sys.exit(1)
  123. pp.pprint(client.ExecuteStatement(eval(args[0]),))
  124. elif cmd == 'GetTypeInfo':
  125. if len(args) != 1:
  126. print('GetTypeInfo requires 1 args')
  127. sys.exit(1)
  128. pp.pprint(client.GetTypeInfo(eval(args[0]),))
  129. elif cmd == 'GetCatalogs':
  130. if len(args) != 1:
  131. print('GetCatalogs requires 1 args')
  132. sys.exit(1)
  133. pp.pprint(client.GetCatalogs(eval(args[0]),))
  134. elif cmd == 'GetSchemas':
  135. if len(args) != 1:
  136. print('GetSchemas requires 1 args')
  137. sys.exit(1)
  138. pp.pprint(client.GetSchemas(eval(args[0]),))
  139. elif cmd == 'GetTables':
  140. if len(args) != 1:
  141. print('GetTables requires 1 args')
  142. sys.exit(1)
  143. pp.pprint(client.GetTables(eval(args[0]),))
  144. elif cmd == 'GetTableTypes':
  145. if len(args) != 1:
  146. print('GetTableTypes requires 1 args')
  147. sys.exit(1)
  148. pp.pprint(client.GetTableTypes(eval(args[0]),))
  149. elif cmd == 'GetColumns':
  150. if len(args) != 1:
  151. print('GetColumns requires 1 args')
  152. sys.exit(1)
  153. pp.pprint(client.GetColumns(eval(args[0]),))
  154. elif cmd == 'GetFunctions':
  155. if len(args) != 1:
  156. print('GetFunctions requires 1 args')
  157. sys.exit(1)
  158. pp.pprint(client.GetFunctions(eval(args[0]),))
  159. elif cmd == 'GetOperationStatus':
  160. if len(args) != 1:
  161. print('GetOperationStatus requires 1 args')
  162. sys.exit(1)
  163. pp.pprint(client.GetOperationStatus(eval(args[0]),))
  164. elif cmd == 'CancelOperation':
  165. if len(args) != 1:
  166. print('CancelOperation requires 1 args')
  167. sys.exit(1)
  168. pp.pprint(client.CancelOperation(eval(args[0]),))
  169. elif cmd == 'CloseOperation':
  170. if len(args) != 1:
  171. print('CloseOperation requires 1 args')
  172. sys.exit(1)
  173. pp.pprint(client.CloseOperation(eval(args[0]),))
  174. elif cmd == 'GetResultSetMetadata':
  175. if len(args) != 1:
  176. print('GetResultSetMetadata requires 1 args')
  177. sys.exit(1)
  178. pp.pprint(client.GetResultSetMetadata(eval(args[0]),))
  179. elif cmd == 'FetchResults':
  180. if len(args) != 1:
  181. print('FetchResults requires 1 args')
  182. sys.exit(1)
  183. pp.pprint(client.FetchResults(eval(args[0]),))
  184. elif cmd == 'GetDelegationToken':
  185. if len(args) != 1:
  186. print('GetDelegationToken requires 1 args')
  187. sys.exit(1)
  188. pp.pprint(client.GetDelegationToken(eval(args[0]),))
  189. elif cmd == 'CancelDelegationToken':
  190. if len(args) != 1:
  191. print('CancelDelegationToken requires 1 args')
  192. sys.exit(1)
  193. pp.pprint(client.CancelDelegationToken(eval(args[0]),))
  194. elif cmd == 'RenewDelegationToken':
  195. if len(args) != 1:
  196. print('RenewDelegationToken requires 1 args')
  197. sys.exit(1)
  198. pp.pprint(client.RenewDelegationToken(eval(args[0]),))
  199. elif cmd == 'GetLog':
  200. if len(args) != 1:
  201. print('GetLog requires 1 args')
  202. sys.exit(1)
  203. pp.pprint(client.GetLog(eval(args[0]),))
  204. else:
  205. print('Unrecognized method %s' % cmd)
  206. sys.exit(1)
  207. transport.close()