Browse Source

[beeswax] Integration of Hive Server 2

Add a layer of abstraction called 'dbms'. This layer is then calling
either a 'Beeswaxd' or 'Hive Server 2' service.

Beeswax is working as before. Hive Server 2 can now:
- list tables
- describe the columns of a table and provide and example of data
- send a SELECT query

Other features are not implemented yet. This is not part 1.

Hive Server 2 can be selected with the
server_interface=hiveserver2 property in [beeswax]
Romain Rigaux 13 years ago
parent
commit
a85eaeb8c2
38 changed files with 11728 additions and 1390 deletions
  1. 190 0
      apps/beeswax/gen-py/cli_service/TCLIService-remote
  2. 2770 0
      apps/beeswax/gen-py/cli_service/TCLIService.py
  3. 1 0
      apps/beeswax/gen-py/cli_service/__init__.py
  4. 48 0
      apps/beeswax/gen-py/cli_service/constants.py
  5. 5054 0
      apps/beeswax/gen-py/cli_service/ttypes.py
  6. 1 0
      apps/beeswax/regenerate_thrift.sh
  7. 1 1
      apps/beeswax/setup.py
  8. 0 11
      apps/beeswax/src/beeswax/common.py
  9. 6 0
      apps/beeswax/src/beeswax/conf.py
  10. 37 26
      apps/beeswax/src/beeswax/create_table.py
  11. 27 48
      apps/beeswax/src/beeswax/data_export.py
  12. 0 377
      apps/beeswax/src/beeswax/db_utils.py
  13. 78 12
      apps/beeswax/src/beeswax/design.py
  14. 40 20
      apps/beeswax/src/beeswax/forms.py
  15. 13 20
      apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py
  16. 139 0
      apps/beeswax/src/beeswax/migrations/0004_auto__add_session__add_field_queryhistory_server_type__add_field_query.py
  17. 248 59
      apps/beeswax/src/beeswax/models.py
  18. 0 0
      apps/beeswax/src/beeswax/server/__init__.py
  19. 386 0
      apps/beeswax/src/beeswax/server/beeswax_lib.py
  20. 293 0
      apps/beeswax/src/beeswax/server/dbms.py
  21. 465 0
      apps/beeswax/src/beeswax/server/hive_server2_lib.py
  22. 30 27
      apps/beeswax/src/beeswax/templates/describe_partitions.mako
  23. 123 134
      apps/beeswax/src/beeswax/templates/describe_table.mako
  24. 1 1
      apps/beeswax/src/beeswax/templates/explain.mako
  25. 2 0
      apps/beeswax/src/beeswax/templates/watch_results.mako
  26. 2 0
      apps/beeswax/src/beeswax/templates/watch_wait.mako
  27. 20 11
      apps/beeswax/src/beeswax/test_base.py
  28. 69 81
      apps/beeswax/src/beeswax/tests.py
  29. 37 28
      apps/beeswax/src/beeswax/urls.py
  30. 632 519
      apps/beeswax/src/beeswax/views.py
  31. 992 0
      apps/beeswax/thrift/cli_service.thrift
  32. 2 2
      apps/filebrowser/src/filebrowser/views.py
  33. 3 3
      apps/jobbrowser/src/jobbrowser/templates/job.mako
  34. 2 1
      apps/jobbrowser/src/jobbrowser/views.py
  35. 4 0
      desktop/conf.dist/hue.ini
  36. 4 0
      desktop/conf/pseudo-distributed.ini.tmpl
  37. 6 4
      desktop/core/src/desktop/conf.py
  38. 2 5
      desktop/core/src/desktop/lib/thrift_util.py

+ 190 - 0
apps/beeswax/gen-py/cli_service/TCLIService-remote

@@ -0,0 +1,190 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.7.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+import TCLIService
+from ttypes import *
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  TOpenSessionResp OpenSession(TOpenSessionReq req)'
+  print '  TCloseSessionResp CloseSession(TCloseSessionReq req)'
+  print '  TGetInfoResp GetInfo(TGetInfoReq req)'
+  print '  TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req)'
+  print '  TGetTypeInfoResp GetTypeInfo(TGetTypeInfoReq req)'
+  print '  TGetCatalogsResp GetCatalogs(TGetCatalogsReq req)'
+  print '  TGetSchemasResp GetSchemas(TGetSchemasReq req)'
+  print '  TGetTablesResp GetTables(TGetTablesReq req)'
+  print '  TGetTableTypesResp GetTableTypes(TGetTableTypesReq req)'
+  print '  TGetColumnsResp GetColumns(TGetColumnsReq req)'
+  print '  TGetFunctionsResp GetFunctions(TGetFunctionsReq req)'
+  print '  TGetOperationStatusResp GetOperationStatus(TGetOperationStatusReq req)'
+  print '  TCancelOperationResp CancelOperation(TCancelOperationReq req)'
+  print '  TCloseOperationResp CloseOperation(TCloseOperationReq req)'
+  print '  TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req)'
+  print '  TFetchResultsResp FetchResults(TFetchResultsReq req)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = TCLIService.Client(protocol)
+transport.open()
+
+if cmd == 'OpenSession':
+  if len(args) != 1:
+    print 'OpenSession requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.OpenSession(eval(args[0]),))
+
+elif cmd == 'CloseSession':
+  if len(args) != 1:
+    print 'CloseSession requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.CloseSession(eval(args[0]),))
+
+elif cmd == 'GetInfo':
+  if len(args) != 1:
+    print 'GetInfo requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetInfo(eval(args[0]),))
+
+elif cmd == 'ExecuteStatement':
+  if len(args) != 1:
+    print 'ExecuteStatement requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.ExecuteStatement(eval(args[0]),))
+
+elif cmd == 'GetTypeInfo':
+  if len(args) != 1:
+    print 'GetTypeInfo requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetTypeInfo(eval(args[0]),))
+
+elif cmd == 'GetCatalogs':
+  if len(args) != 1:
+    print 'GetCatalogs requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetCatalogs(eval(args[0]),))
+
+elif cmd == 'GetSchemas':
+  if len(args) != 1:
+    print 'GetSchemas requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetSchemas(eval(args[0]),))
+
+elif cmd == 'GetTables':
+  if len(args) != 1:
+    print 'GetTables requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetTables(eval(args[0]),))
+
+elif cmd == 'GetTableTypes':
+  if len(args) != 1:
+    print 'GetTableTypes requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetTableTypes(eval(args[0]),))
+
+elif cmd == 'GetColumns':
+  if len(args) != 1:
+    print 'GetColumns requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetColumns(eval(args[0]),))
+
+elif cmd == 'GetFunctions':
+  if len(args) != 1:
+    print 'GetFunctions requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetFunctions(eval(args[0]),))
+
+elif cmd == 'GetOperationStatus':
+  if len(args) != 1:
+    print 'GetOperationStatus requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetOperationStatus(eval(args[0]),))
+
+elif cmd == 'CancelOperation':
+  if len(args) != 1:
+    print 'CancelOperation requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.CancelOperation(eval(args[0]),))
+
+elif cmd == 'CloseOperation':
+  if len(args) != 1:
+    print 'CloseOperation requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.CloseOperation(eval(args[0]),))
+
+elif cmd == 'GetResultSetMetadata':
+  if len(args) != 1:
+    print 'GetResultSetMetadata requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.GetResultSetMetadata(eval(args[0]),))
+
+elif cmd == 'FetchResults':
+  if len(args) != 1:
+    print 'FetchResults requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.FetchResults(eval(args[0]),))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()

+ 2770 - 0
apps/beeswax/gen-py/cli_service/TCLIService.py

@@ -0,0 +1,2770 @@
+#
+# Autogenerated by Thrift Compiler (0.7.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import TType as TTType
+from thrift.Thrift import *
+from ttypes import *
+from thrift.Thrift import TProcessor
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class Iface(object):
+  def OpenSession(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def CloseSession(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetInfo(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def ExecuteStatement(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetTypeInfo(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetCatalogs(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetSchemas(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetTables(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetTableTypes(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetColumns(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetFunctions(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetOperationStatus(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def CancelOperation(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def CloseOperation(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def GetResultSetMetadata(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+  def FetchResults(self, req):
+    """
+    Parameters:
+     - req
+    """
+    pass
+
+
+class Client(Iface):
+  def __init__(self, iprot, oprot=None):
+    self._iprot = self._oprot = iprot
+    if oprot is not None:
+      self._oprot = oprot
+    self._seqid = 0
+
+  def OpenSession(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_OpenSession(req)
+    return self.recv_OpenSession()
+
+  def send_OpenSession(self, req):
+    self._oprot.writeMessageBegin('OpenSession', TMessageType.CALL, self._seqid)
+    args = OpenSession_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_OpenSession(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = OpenSession_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "OpenSession failed: unknown result");
+
+  def CloseSession(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_CloseSession(req)
+    return self.recv_CloseSession()
+
+  def send_CloseSession(self, req):
+    self._oprot.writeMessageBegin('CloseSession', TMessageType.CALL, self._seqid)
+    args = CloseSession_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_CloseSession(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = CloseSession_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "CloseSession failed: unknown result");
+
+  def GetInfo(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetInfo(req)
+    return self.recv_GetInfo()
+
+  def send_GetInfo(self, req):
+    self._oprot.writeMessageBegin('GetInfo', TMessageType.CALL, self._seqid)
+    args = GetInfo_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetInfo(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetInfo_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetInfo failed: unknown result");
+
+  def ExecuteStatement(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_ExecuteStatement(req)
+    return self.recv_ExecuteStatement()
+
+  def send_ExecuteStatement(self, req):
+    self._oprot.writeMessageBegin('ExecuteStatement', TMessageType.CALL, self._seqid)
+    args = ExecuteStatement_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_ExecuteStatement(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = ExecuteStatement_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "ExecuteStatement failed: unknown result");
+
+  def GetTypeInfo(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetTypeInfo(req)
+    return self.recv_GetTypeInfo()
+
+  def send_GetTypeInfo(self, req):
+    self._oprot.writeMessageBegin('GetTypeInfo', TMessageType.CALL, self._seqid)
+    args = GetTypeInfo_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetTypeInfo(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetTypeInfo_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetTypeInfo failed: unknown result");
+
+  def GetCatalogs(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetCatalogs(req)
+    return self.recv_GetCatalogs()
+
+  def send_GetCatalogs(self, req):
+    self._oprot.writeMessageBegin('GetCatalogs', TMessageType.CALL, self._seqid)
+    args = GetCatalogs_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetCatalogs(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetCatalogs_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetCatalogs failed: unknown result");
+
+  def GetSchemas(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetSchemas(req)
+    return self.recv_GetSchemas()
+
+  def send_GetSchemas(self, req):
+    self._oprot.writeMessageBegin('GetSchemas', TMessageType.CALL, self._seqid)
+    args = GetSchemas_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetSchemas(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetSchemas_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetSchemas failed: unknown result");
+
+  def GetTables(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetTables(req)
+    return self.recv_GetTables()
+
+  def send_GetTables(self, req):
+    self._oprot.writeMessageBegin('GetTables', TMessageType.CALL, self._seqid)
+    args = GetTables_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetTables(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetTables_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetTables failed: unknown result");
+
+  def GetTableTypes(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetTableTypes(req)
+    return self.recv_GetTableTypes()
+
+  def send_GetTableTypes(self, req):
+    self._oprot.writeMessageBegin('GetTableTypes', TMessageType.CALL, self._seqid)
+    args = GetTableTypes_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetTableTypes(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetTableTypes_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetTableTypes failed: unknown result");
+
+  def GetColumns(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetColumns(req)
+    return self.recv_GetColumns()
+
+  def send_GetColumns(self, req):
+    self._oprot.writeMessageBegin('GetColumns', TMessageType.CALL, self._seqid)
+    args = GetColumns_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetColumns(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetColumns_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetColumns failed: unknown result");
+
+  def GetFunctions(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetFunctions(req)
+    return self.recv_GetFunctions()
+
+  def send_GetFunctions(self, req):
+    self._oprot.writeMessageBegin('GetFunctions', TMessageType.CALL, self._seqid)
+    args = GetFunctions_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetFunctions(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetFunctions_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetFunctions failed: unknown result");
+
+  def GetOperationStatus(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetOperationStatus(req)
+    return self.recv_GetOperationStatus()
+
+  def send_GetOperationStatus(self, req):
+    self._oprot.writeMessageBegin('GetOperationStatus', TMessageType.CALL, self._seqid)
+    args = GetOperationStatus_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetOperationStatus(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetOperationStatus_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetOperationStatus failed: unknown result");
+
+  def CancelOperation(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_CancelOperation(req)
+    return self.recv_CancelOperation()
+
+  def send_CancelOperation(self, req):
+    self._oprot.writeMessageBegin('CancelOperation', TMessageType.CALL, self._seqid)
+    args = CancelOperation_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_CancelOperation(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = CancelOperation_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "CancelOperation failed: unknown result");
+
+  def CloseOperation(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_CloseOperation(req)
+    return self.recv_CloseOperation()
+
+  def send_CloseOperation(self, req):
+    self._oprot.writeMessageBegin('CloseOperation', TMessageType.CALL, self._seqid)
+    args = CloseOperation_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_CloseOperation(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = CloseOperation_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "CloseOperation failed: unknown result");
+
+  def GetResultSetMetadata(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_GetResultSetMetadata(req)
+    return self.recv_GetResultSetMetadata()
+
+  def send_GetResultSetMetadata(self, req):
+    self._oprot.writeMessageBegin('GetResultSetMetadata', TMessageType.CALL, self._seqid)
+    args = GetResultSetMetadata_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_GetResultSetMetadata(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = GetResultSetMetadata_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "GetResultSetMetadata failed: unknown result");
+
+  def FetchResults(self, req):
+    """
+    Parameters:
+     - req
+    """
+    self.send_FetchResults(req)
+    return self.recv_FetchResults()
+
+  def send_FetchResults(self, req):
+    self._oprot.writeMessageBegin('FetchResults', TMessageType.CALL, self._seqid)
+    args = FetchResults_args()
+    args.req = req
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_FetchResults(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = FetchResults_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success is not None:
+      return result.success
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "FetchResults failed: unknown result");
+
+
+class Processor(Iface, TProcessor):
+  def __init__(self, handler):
+    self._handler = handler
+    self._processMap = {}
+    self._processMap["OpenSession"] = Processor.process_OpenSession
+    self._processMap["CloseSession"] = Processor.process_CloseSession
+    self._processMap["GetInfo"] = Processor.process_GetInfo
+    self._processMap["ExecuteStatement"] = Processor.process_ExecuteStatement
+    self._processMap["GetTypeInfo"] = Processor.process_GetTypeInfo
+    self._processMap["GetCatalogs"] = Processor.process_GetCatalogs
+    self._processMap["GetSchemas"] = Processor.process_GetSchemas
+    self._processMap["GetTables"] = Processor.process_GetTables
+    self._processMap["GetTableTypes"] = Processor.process_GetTableTypes
+    self._processMap["GetColumns"] = Processor.process_GetColumns
+    self._processMap["GetFunctions"] = Processor.process_GetFunctions
+    self._processMap["GetOperationStatus"] = Processor.process_GetOperationStatus
+    self._processMap["CancelOperation"] = Processor.process_CancelOperation
+    self._processMap["CloseOperation"] = Processor.process_CloseOperation
+    self._processMap["GetResultSetMetadata"] = Processor.process_GetResultSetMetadata
+    self._processMap["FetchResults"] = Processor.process_FetchResults
+
+  def process(self, iprot, oprot):
+    (name, type, seqid) = iprot.readMessageBegin()
+    if name not in self._processMap:
+      iprot.skip(TTType.STRUCT)
+      iprot.readMessageEnd()
+      x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
+      oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
+      x.write(oprot)
+      oprot.writeMessageEnd()
+      oprot.trans.flush()
+      return
+    else:
+      self._processMap[name](self, seqid, iprot, oprot)
+    return True
+
+  def process_OpenSession(self, seqid, iprot, oprot):
+    args = OpenSession_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = OpenSession_result()
+    result.success = self._handler.OpenSession(args.req)
+    oprot.writeMessageBegin("OpenSession", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_CloseSession(self, seqid, iprot, oprot):
+    args = CloseSession_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = CloseSession_result()
+    result.success = self._handler.CloseSession(args.req)
+    oprot.writeMessageBegin("CloseSession", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetInfo(self, seqid, iprot, oprot):
+    args = GetInfo_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetInfo_result()
+    result.success = self._handler.GetInfo(args.req)
+    oprot.writeMessageBegin("GetInfo", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_ExecuteStatement(self, seqid, iprot, oprot):
+    args = ExecuteStatement_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = ExecuteStatement_result()
+    result.success = self._handler.ExecuteStatement(args.req)
+    oprot.writeMessageBegin("ExecuteStatement", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetTypeInfo(self, seqid, iprot, oprot):
+    args = GetTypeInfo_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetTypeInfo_result()
+    result.success = self._handler.GetTypeInfo(args.req)
+    oprot.writeMessageBegin("GetTypeInfo", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetCatalogs(self, seqid, iprot, oprot):
+    args = GetCatalogs_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetCatalogs_result()
+    result.success = self._handler.GetCatalogs(args.req)
+    oprot.writeMessageBegin("GetCatalogs", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetSchemas(self, seqid, iprot, oprot):
+    args = GetSchemas_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetSchemas_result()
+    result.success = self._handler.GetSchemas(args.req)
+    oprot.writeMessageBegin("GetSchemas", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetTables(self, seqid, iprot, oprot):
+    args = GetTables_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetTables_result()
+    result.success = self._handler.GetTables(args.req)
+    oprot.writeMessageBegin("GetTables", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetTableTypes(self, seqid, iprot, oprot):
+    args = GetTableTypes_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetTableTypes_result()
+    result.success = self._handler.GetTableTypes(args.req)
+    oprot.writeMessageBegin("GetTableTypes", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetColumns(self, seqid, iprot, oprot):
+    args = GetColumns_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetColumns_result()
+    result.success = self._handler.GetColumns(args.req)
+    oprot.writeMessageBegin("GetColumns", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetFunctions(self, seqid, iprot, oprot):
+    args = GetFunctions_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetFunctions_result()
+    result.success = self._handler.GetFunctions(args.req)
+    oprot.writeMessageBegin("GetFunctions", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetOperationStatus(self, seqid, iprot, oprot):
+    args = GetOperationStatus_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetOperationStatus_result()
+    result.success = self._handler.GetOperationStatus(args.req)
+    oprot.writeMessageBegin("GetOperationStatus", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_CancelOperation(self, seqid, iprot, oprot):
+    args = CancelOperation_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = CancelOperation_result()
+    result.success = self._handler.CancelOperation(args.req)
+    oprot.writeMessageBegin("CancelOperation", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_CloseOperation(self, seqid, iprot, oprot):
+    args = CloseOperation_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = CloseOperation_result()
+    result.success = self._handler.CloseOperation(args.req)
+    oprot.writeMessageBegin("CloseOperation", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_GetResultSetMetadata(self, seqid, iprot, oprot):
+    args = GetResultSetMetadata_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = GetResultSetMetadata_result()
+    result.success = self._handler.GetResultSetMetadata(args.req)
+    oprot.writeMessageBegin("GetResultSetMetadata", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+  def process_FetchResults(self, seqid, iprot, oprot):
+    args = FetchResults_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = FetchResults_result()
+    result.success = self._handler.FetchResults(args.req)
+    oprot.writeMessageBegin("FetchResults", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
+
+# HELPER FUNCTIONS AND STRUCTURES
+
+class OpenSession_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TOpenSessionReq, TOpenSessionReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TOpenSessionReq()
+          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('OpenSession_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 OpenSession_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TOpenSessionResp, TOpenSessionResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TOpenSessionResp()
+          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('OpenSession_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class CloseSession_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TCloseSessionReq, TCloseSessionReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TCloseSessionReq()
+          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('CloseSession_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 CloseSession_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TCloseSessionResp, TCloseSessionResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TCloseSessionResp()
+          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('CloseSession_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetInfo_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetInfoReq, TGetInfoReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetInfoReq()
+          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('GetInfo_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetInfo_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetInfoResp, TGetInfoResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetInfoResp()
+          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('GetInfo_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class ExecuteStatement_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.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('ExecuteStatement_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 ExecuteStatement_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TExecuteStatementResp, TExecuteStatementResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TExecuteStatementResp()
+          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('ExecuteStatement_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetTypeInfo_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetTypeInfoReq, TGetTypeInfoReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetTypeInfoReq()
+          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('GetTypeInfo_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetTypeInfo_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetTypeInfoResp, TGetTypeInfoResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetTypeInfoResp()
+          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('GetTypeInfo_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetCatalogs_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetCatalogsReq, TGetCatalogsReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetCatalogsReq()
+          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('GetCatalogs_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetCatalogs_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetCatalogsResp, TGetCatalogsResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetCatalogsResp()
+          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('GetCatalogs_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetSchemas_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetSchemasReq, TGetSchemasReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetSchemasReq()
+          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('GetSchemas_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetSchemas_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetSchemasResp, TGetSchemasResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetSchemasResp()
+          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('GetSchemas_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetTables_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetTablesReq, TGetTablesReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetTablesReq()
+          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('GetTables_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetTables_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetTablesResp, TGetTablesResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetTablesResp()
+          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('GetTables_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetTableTypes_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetTableTypesReq, TGetTableTypesReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetTableTypesReq()
+          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('GetTableTypes_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetTableTypes_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetTableTypesResp, TGetTableTypesResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetTableTypesResp()
+          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('GetTableTypes_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetColumns_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetColumnsReq, TGetColumnsReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetColumnsReq()
+          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('GetColumns_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetColumns_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetColumnsResp, TGetColumnsResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetColumnsResp()
+          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('GetColumns_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetFunctions_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetFunctionsReq, TGetFunctionsReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetFunctionsReq()
+          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('GetFunctions_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetFunctions_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetFunctionsResp, TGetFunctionsResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetFunctionsResp()
+          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('GetFunctions_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetOperationStatus_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetOperationStatusReq, TGetOperationStatusReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetOperationStatusReq()
+          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('GetOperationStatus_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetOperationStatus_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetOperationStatusResp, TGetOperationStatusResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetOperationStatusResp()
+          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('GetOperationStatus_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class CancelOperation_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TCancelOperationReq, TCancelOperationReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TCancelOperationReq()
+          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('CancelOperation_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 CancelOperation_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TCancelOperationResp, TCancelOperationResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TCancelOperationResp()
+          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('CancelOperation_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class CloseOperation_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TCloseOperationReq, TCloseOperationReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TCloseOperationReq()
+          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('CloseOperation_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 CloseOperation_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TCloseOperationResp, TCloseOperationResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TCloseOperationResp()
+          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('CloseOperation_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class GetResultSetMetadata_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TGetResultSetMetadataReq, TGetResultSetMetadataReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TGetResultSetMetadataReq()
+          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('GetResultSetMetadata_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 GetResultSetMetadata_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TGetResultSetMetadataResp, TGetResultSetMetadataResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TGetResultSetMetadataResp()
+          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('GetResultSetMetadata_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)
+
+class FetchResults_args(object):
+  """
+  Attributes:
+   - req
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'req', (TFetchResultsReq, TFetchResultsReq.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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.req = TFetchResultsReq()
+          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('FetchResults_args')
+    if self.req is not None:
+      oprot.writeFieldBegin('req', TTType.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 FetchResults_result(object):
+  """
+  Attributes:
+   - success
+  """
+
+  thrift_spec = (
+    (0, TTType.STRUCT, 'success', (TFetchResultsResp, TFetchResultsResp.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 == TTType.STOP:
+        break
+      if fid == 0:
+        if ftype == TTType.STRUCT:
+          self.success = TFetchResultsResp()
+          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('FetchResults_result')
+    if self.success is not None:
+      oprot.writeFieldBegin('success', TTType.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)

+ 1 - 0
apps/beeswax/gen-py/cli_service/__init__.py

@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'TCLIService']

+ 48 - 0
apps/beeswax/gen-py/cli_service/constants.py

@@ -0,0 +1,48 @@
+#
+# Autogenerated by Thrift Compiler (0.7.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import *
+from ttypes import *
+
+PRIMITIVE_TYPES = set([
+    0,
+    1,
+    2,
+    3,
+    4,
+    5,
+    6,
+    7,
+    8,
+    9,
+])
+COMPLEX_TYPES = set([
+    10,
+    11,
+    12,
+    13,
+    14,
+])
+COLLECTION_TYPES = set([
+    10,
+    11,
+])
+TYPE_NAMES = {
+    0 : "BOOLEAN",
+    1 : "TINYINT",
+    2 : "SMALLINT",
+    3 : "INT",
+    4 : "BIGINT",
+    5 : "FLOAT",
+    6 : "DOUBLE",
+    7 : "STRING",
+    8 : "TIMESTAMP",
+    9 : "BINARY",
+    10 : "ARRAY",
+    11 : "MAP",
+    12 : "STRUCT",
+    13 : "UNIONTYPE",
+}

+ 5054 - 0
apps/beeswax/gen-py/cli_service/ttypes.py

@@ -0,0 +1,5054 @@
+#
+# Autogenerated by Thrift Compiler (0.7.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import TType as TTType
+from thrift.Thrift import *
+
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class TProtocolVersion(object):
+  HIVE_CLI_SERVICE_PROTOCOL_V1 = 0
+
+  _VALUES_TO_NAMES = {
+    0: "HIVE_CLI_SERVICE_PROTOCOL_V1",
+  }
+
+  _NAMES_TO_VALUES = {
+    "HIVE_CLI_SERVICE_PROTOCOL_V1": 0,
+  }
+
+class TType(object):
+  BOOLEAN_TYPE = 0
+  TINYINT_TYPE = 1
+  SMALLINT_TYPE = 2
+  INT_TYPE = 3
+  BIGINT_TYPE = 4
+  FLOAT_TYPE = 5
+  DOUBLE_TYPE = 6
+  STRING_TYPE = 7
+  TIMESTAMP_TYPE = 8
+  BINARY_TYPE = 9
+  ARRAY_TYPE = 10
+  MAP_TYPE = 11
+  STRUCT_TYPE = 12
+  UNION_TYPE = 13
+  USER_DEFINED_TYPE = 14
+
+  _VALUES_TO_NAMES = {
+    0: "BOOLEAN_TYPE",
+    1: "TINYINT_TYPE",
+    2: "SMALLINT_TYPE",
+    3: "INT_TYPE",
+    4: "BIGINT_TYPE",
+    5: "FLOAT_TYPE",
+    6: "DOUBLE_TYPE",
+    7: "STRING_TYPE",
+    8: "TIMESTAMP_TYPE",
+    9: "BINARY_TYPE",
+    10: "ARRAY_TYPE",
+    11: "MAP_TYPE",
+    12: "STRUCT_TYPE",
+    13: "UNION_TYPE",
+    14: "USER_DEFINED_TYPE",
+  }
+
+  _NAMES_TO_VALUES = {
+    "BOOLEAN_TYPE": 0,
+    "TINYINT_TYPE": 1,
+    "SMALLINT_TYPE": 2,
+    "INT_TYPE": 3,
+    "BIGINT_TYPE": 4,
+    "FLOAT_TYPE": 5,
+    "DOUBLE_TYPE": 6,
+    "STRING_TYPE": 7,
+    "TIMESTAMP_TYPE": 8,
+    "BINARY_TYPE": 9,
+    "ARRAY_TYPE": 10,
+    "MAP_TYPE": 11,
+    "STRUCT_TYPE": 12,
+    "UNION_TYPE": 13,
+    "USER_DEFINED_TYPE": 14,
+  }
+
+class TStatusCode(object):
+  SUCCESS_STATUS = 0
+  SUCCESS_WITH_INFO_STATUS = 1
+  STILL_EXECUTING_STATUS = 2
+  ERROR_STATUS = 3
+  INVALID_HANDLE_STATUS = 4
+
+  _VALUES_TO_NAMES = {
+    0: "SUCCESS_STATUS",
+    1: "SUCCESS_WITH_INFO_STATUS",
+    2: "STILL_EXECUTING_STATUS",
+    3: "ERROR_STATUS",
+    4: "INVALID_HANDLE_STATUS",
+  }
+
+  _NAMES_TO_VALUES = {
+    "SUCCESS_STATUS": 0,
+    "SUCCESS_WITH_INFO_STATUS": 1,
+    "STILL_EXECUTING_STATUS": 2,
+    "ERROR_STATUS": 3,
+    "INVALID_HANDLE_STATUS": 4,
+  }
+
+class TOperationState(object):
+  INITIALIZED_STATE = 0
+  RUNNING_STATE = 1
+  FINISHED_STATE = 2
+  CANCELED_STATE = 3
+  CLOSED_STATE = 4
+  ERROR_STATE = 5
+  UKNOWN_STATE = 6
+
+  _VALUES_TO_NAMES = {
+    0: "INITIALIZED_STATE",
+    1: "RUNNING_STATE",
+    2: "FINISHED_STATE",
+    3: "CANCELED_STATE",
+    4: "CLOSED_STATE",
+    5: "ERROR_STATE",
+    6: "UKNOWN_STATE",
+  }
+
+  _NAMES_TO_VALUES = {
+    "INITIALIZED_STATE": 0,
+    "RUNNING_STATE": 1,
+    "FINISHED_STATE": 2,
+    "CANCELED_STATE": 3,
+    "CLOSED_STATE": 4,
+    "ERROR_STATE": 5,
+    "UKNOWN_STATE": 6,
+  }
+
+class TOperationType(object):
+  EXECUTE_STATEMENT = 0
+  GET_TYPE_INFO = 1
+  GET_CATALOGS = 2
+  GET_SCHEMAS = 3
+  GET_TABLES = 4
+  GET_TABLE_TYPES = 5
+  GET_COLUMNS = 6
+  GET_FUNCTIONS = 7
+  UNKNOWN = 8
+
+  _VALUES_TO_NAMES = {
+    0: "EXECUTE_STATEMENT",
+    1: "GET_TYPE_INFO",
+    2: "GET_CATALOGS",
+    3: "GET_SCHEMAS",
+    4: "GET_TABLES",
+    5: "GET_TABLE_TYPES",
+    6: "GET_COLUMNS",
+    7: "GET_FUNCTIONS",
+    8: "UNKNOWN",
+  }
+
+  _NAMES_TO_VALUES = {
+    "EXECUTE_STATEMENT": 0,
+    "GET_TYPE_INFO": 1,
+    "GET_CATALOGS": 2,
+    "GET_SCHEMAS": 3,
+    "GET_TABLES": 4,
+    "GET_TABLE_TYPES": 5,
+    "GET_COLUMNS": 6,
+    "GET_FUNCTIONS": 7,
+    "UNKNOWN": 8,
+  }
+
+class TGetInfoType(object):
+  CLI_MAX_DRIVER_CONNECTIONS = 0
+  CLI_MAX_CONCURRENT_ACTIVITIES = 1
+  CLI_DATA_SOURCE_NAME = 2
+  CLI_FETCH_DIRECTION = 8
+  CLI_SERVER_NAME = 13
+  CLI_SEARCH_PATTERN_ESCAPE = 14
+  CLI_DBMS_NAME = 17
+  CLI_DBMS_VER = 18
+  CLI_ACCESSIBLE_TABLES = 19
+  CLI_ACCESSIBLE_PROCEDURES = 20
+  CLI_CURSOR_COMMIT_BEHAVIOR = 23
+  CLI_DATA_SOURCE_READ_ONLY = 25
+  CLI_DEFAULT_TXN_ISOLATION = 26
+  CLI_IDENTIFIER_CASE = 28
+  CLI_IDENTIFIER_QUOTE_CHAR = 29
+  CLI_MAX_COLUMN_NAME_LEN = 30
+  CLI_MAX_CURSOR_NAME_LEN = 31
+  CLI_MAX_SCHEMA_NAME_LEN = 32
+  CLI_MAX_CATALOG_NAME_LEN = 34
+  CLI_MAX_TABLE_NAME_LEN = 35
+  CLI_SCROLL_CONCURRENCY = 43
+  CLI_TXN_CAPABLE = 46
+  CLI_USER_NAME = 47
+  CLI_TXN_ISOLATION_OPTION = 72
+  CLI_INTEGRITY = 73
+  CLI_GETDATA_EXTENSIONS = 81
+  CLI_NULL_COLLATION = 85
+  CLI_ALTER_TABLE = 86
+  CLI_ORDER_BY_COLUMNS_IN_SELECT = 90
+  CLI_SPECIAL_CHARACTERS = 94
+  CLI_MAX_COLUMNS_IN_GROUP_BY = 97
+  CLI_MAX_COLUMNS_IN_INDEX = 98
+  CLI_MAX_COLUMNS_IN_ORDER_BY = 99
+  CLI_MAX_COLUMNS_IN_SELECT = 100
+  CLI_MAX_COLUMNS_IN_TABLE = 101
+  CLI_MAX_INDEX_SIZE = 102
+  CLI_MAX_ROW_SIZE = 104
+  CLI_MAX_STATEMENT_LEN = 105
+  CLI_MAX_TABLES_IN_SELECT = 106
+  CLI_MAX_USER_NAME_LEN = 107
+  CLI_OJ_CAPABILITIES = 115
+  CLI_XOPEN_CLI_YEAR = 10000
+  CLI_CURSOR_SENSITIVITY = 10001
+  CLI_DESCRIBE_PARAMETER = 10002
+  CLI_CATALOG_NAME = 10003
+  CLI_COLLATION_SEQ = 10004
+  CLI_MAX_IDENTIFIER_LEN = 10005
+
+  _VALUES_TO_NAMES = {
+    0: "CLI_MAX_DRIVER_CONNECTIONS",
+    1: "CLI_MAX_CONCURRENT_ACTIVITIES",
+    2: "CLI_DATA_SOURCE_NAME",
+    8: "CLI_FETCH_DIRECTION",
+    13: "CLI_SERVER_NAME",
+    14: "CLI_SEARCH_PATTERN_ESCAPE",
+    17: "CLI_DBMS_NAME",
+    18: "CLI_DBMS_VER",
+    19: "CLI_ACCESSIBLE_TABLES",
+    20: "CLI_ACCESSIBLE_PROCEDURES",
+    23: "CLI_CURSOR_COMMIT_BEHAVIOR",
+    25: "CLI_DATA_SOURCE_READ_ONLY",
+    26: "CLI_DEFAULT_TXN_ISOLATION",
+    28: "CLI_IDENTIFIER_CASE",
+    29: "CLI_IDENTIFIER_QUOTE_CHAR",
+    30: "CLI_MAX_COLUMN_NAME_LEN",
+    31: "CLI_MAX_CURSOR_NAME_LEN",
+    32: "CLI_MAX_SCHEMA_NAME_LEN",
+    34: "CLI_MAX_CATALOG_NAME_LEN",
+    35: "CLI_MAX_TABLE_NAME_LEN",
+    43: "CLI_SCROLL_CONCURRENCY",
+    46: "CLI_TXN_CAPABLE",
+    47: "CLI_USER_NAME",
+    72: "CLI_TXN_ISOLATION_OPTION",
+    73: "CLI_INTEGRITY",
+    81: "CLI_GETDATA_EXTENSIONS",
+    85: "CLI_NULL_COLLATION",
+    86: "CLI_ALTER_TABLE",
+    90: "CLI_ORDER_BY_COLUMNS_IN_SELECT",
+    94: "CLI_SPECIAL_CHARACTERS",
+    97: "CLI_MAX_COLUMNS_IN_GROUP_BY",
+    98: "CLI_MAX_COLUMNS_IN_INDEX",
+    99: "CLI_MAX_COLUMNS_IN_ORDER_BY",
+    100: "CLI_MAX_COLUMNS_IN_SELECT",
+    101: "CLI_MAX_COLUMNS_IN_TABLE",
+    102: "CLI_MAX_INDEX_SIZE",
+    104: "CLI_MAX_ROW_SIZE",
+    105: "CLI_MAX_STATEMENT_LEN",
+    106: "CLI_MAX_TABLES_IN_SELECT",
+    107: "CLI_MAX_USER_NAME_LEN",
+    115: "CLI_OJ_CAPABILITIES",
+    10000: "CLI_XOPEN_CLI_YEAR",
+    10001: "CLI_CURSOR_SENSITIVITY",
+    10002: "CLI_DESCRIBE_PARAMETER",
+    10003: "CLI_CATALOG_NAME",
+    10004: "CLI_COLLATION_SEQ",
+    10005: "CLI_MAX_IDENTIFIER_LEN",
+  }
+
+  _NAMES_TO_VALUES = {
+    "CLI_MAX_DRIVER_CONNECTIONS": 0,
+    "CLI_MAX_CONCURRENT_ACTIVITIES": 1,
+    "CLI_DATA_SOURCE_NAME": 2,
+    "CLI_FETCH_DIRECTION": 8,
+    "CLI_SERVER_NAME": 13,
+    "CLI_SEARCH_PATTERN_ESCAPE": 14,
+    "CLI_DBMS_NAME": 17,
+    "CLI_DBMS_VER": 18,
+    "CLI_ACCESSIBLE_TABLES": 19,
+    "CLI_ACCESSIBLE_PROCEDURES": 20,
+    "CLI_CURSOR_COMMIT_BEHAVIOR": 23,
+    "CLI_DATA_SOURCE_READ_ONLY": 25,
+    "CLI_DEFAULT_TXN_ISOLATION": 26,
+    "CLI_IDENTIFIER_CASE": 28,
+    "CLI_IDENTIFIER_QUOTE_CHAR": 29,
+    "CLI_MAX_COLUMN_NAME_LEN": 30,
+    "CLI_MAX_CURSOR_NAME_LEN": 31,
+    "CLI_MAX_SCHEMA_NAME_LEN": 32,
+    "CLI_MAX_CATALOG_NAME_LEN": 34,
+    "CLI_MAX_TABLE_NAME_LEN": 35,
+    "CLI_SCROLL_CONCURRENCY": 43,
+    "CLI_TXN_CAPABLE": 46,
+    "CLI_USER_NAME": 47,
+    "CLI_TXN_ISOLATION_OPTION": 72,
+    "CLI_INTEGRITY": 73,
+    "CLI_GETDATA_EXTENSIONS": 81,
+    "CLI_NULL_COLLATION": 85,
+    "CLI_ALTER_TABLE": 86,
+    "CLI_ORDER_BY_COLUMNS_IN_SELECT": 90,
+    "CLI_SPECIAL_CHARACTERS": 94,
+    "CLI_MAX_COLUMNS_IN_GROUP_BY": 97,
+    "CLI_MAX_COLUMNS_IN_INDEX": 98,
+    "CLI_MAX_COLUMNS_IN_ORDER_BY": 99,
+    "CLI_MAX_COLUMNS_IN_SELECT": 100,
+    "CLI_MAX_COLUMNS_IN_TABLE": 101,
+    "CLI_MAX_INDEX_SIZE": 102,
+    "CLI_MAX_ROW_SIZE": 104,
+    "CLI_MAX_STATEMENT_LEN": 105,
+    "CLI_MAX_TABLES_IN_SELECT": 106,
+    "CLI_MAX_USER_NAME_LEN": 107,
+    "CLI_OJ_CAPABILITIES": 115,
+    "CLI_XOPEN_CLI_YEAR": 10000,
+    "CLI_CURSOR_SENSITIVITY": 10001,
+    "CLI_DESCRIBE_PARAMETER": 10002,
+    "CLI_CATALOG_NAME": 10003,
+    "CLI_COLLATION_SEQ": 10004,
+    "CLI_MAX_IDENTIFIER_LEN": 10005,
+  }
+
+class TFetchOrientation(object):
+  FETCH_NEXT = 0
+  FETCH_PRIOR = 1
+  FETCH_RELATIVE = 2
+  FETCH_ABSOLUTE = 3
+  FETCH_FIRST = 4
+  FETCH_LAST = 5
+
+  _VALUES_TO_NAMES = {
+    0: "FETCH_NEXT",
+    1: "FETCH_PRIOR",
+    2: "FETCH_RELATIVE",
+    3: "FETCH_ABSOLUTE",
+    4: "FETCH_FIRST",
+    5: "FETCH_LAST",
+  }
+
+  _NAMES_TO_VALUES = {
+    "FETCH_NEXT": 0,
+    "FETCH_PRIOR": 1,
+    "FETCH_RELATIVE": 2,
+    "FETCH_ABSOLUTE": 3,
+    "FETCH_FIRST": 4,
+    "FETCH_LAST": 5,
+  }
+
+
+class TPrimitiveTypeEntry(object):
+  """
+  Attributes:
+   - type
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I32, 'type', None, None, ), # 1
+  )
+
+  def __init__(self, type=None,):
+    self.type = type
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I32:
+          self.type = iprot.readI32();
+        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('TPrimitiveTypeEntry')
+    if self.type is not None:
+      oprot.writeFieldBegin('type', TTType.I32, 1)
+      oprot.writeI32(self.type)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.type is None:
+      raise TProtocol.TProtocolException(message='Required field type 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)
+
+class TArrayTypeEntry(object):
+  """
+  Attributes:
+   - objectTypePtr
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I32, 'objectTypePtr', None, None, ), # 1
+  )
+
+  def __init__(self, objectTypePtr=None,):
+    self.objectTypePtr = objectTypePtr
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I32:
+          self.objectTypePtr = iprot.readI32();
+        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('TArrayTypeEntry')
+    if self.objectTypePtr is not None:
+      oprot.writeFieldBegin('objectTypePtr', TTType.I32, 1)
+      oprot.writeI32(self.objectTypePtr)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.objectTypePtr is None:
+      raise TProtocol.TProtocolException(message='Required field objectTypePtr 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)
+
+class TMapTypeEntry(object):
+  """
+  Attributes:
+   - keyTypePtr
+   - valueTypePtr
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I32, 'keyTypePtr', None, None, ), # 1
+    (2, TTType.I32, 'valueTypePtr', None, None, ), # 2
+  )
+
+  def __init__(self, keyTypePtr=None, valueTypePtr=None,):
+    self.keyTypePtr = keyTypePtr
+    self.valueTypePtr = valueTypePtr
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I32:
+          self.keyTypePtr = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I32:
+          self.valueTypePtr = iprot.readI32();
+        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('TMapTypeEntry')
+    if self.keyTypePtr is not None:
+      oprot.writeFieldBegin('keyTypePtr', TTType.I32, 1)
+      oprot.writeI32(self.keyTypePtr)
+      oprot.writeFieldEnd()
+    if self.valueTypePtr is not None:
+      oprot.writeFieldBegin('valueTypePtr', TTType.I32, 2)
+      oprot.writeI32(self.valueTypePtr)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.keyTypePtr is None:
+      raise TProtocol.TProtocolException(message='Required field keyTypePtr is unset!')
+    if self.valueTypePtr is None:
+      raise TProtocol.TProtocolException(message='Required field valueTypePtr 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)
+
+class TStructTypeEntry(object):
+  """
+  Attributes:
+   - nameToTypePtr
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.MAP, 'nameToTypePtr', (TTType.STRING,None,TTType.I32,None), None, ), # 1
+  )
+
+  def __init__(self, nameToTypePtr=None,):
+    self.nameToTypePtr = nameToTypePtr
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.MAP:
+          self.nameToTypePtr = {}
+          (_ktype1, _vtype2, _size0 ) = iprot.readMapBegin() 
+          for _i4 in xrange(_size0):
+            _key5 = iprot.readString();
+            _val6 = iprot.readI32();
+            self.nameToTypePtr[_key5] = _val6
+          iprot.readMapEnd()
+        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('TStructTypeEntry')
+    if self.nameToTypePtr is not None:
+      oprot.writeFieldBegin('nameToTypePtr', TTType.MAP, 1)
+      oprot.writeMapBegin(TTType.STRING, TTType.I32, len(self.nameToTypePtr))
+      for kiter7,viter8 in self.nameToTypePtr.items():
+        oprot.writeString(kiter7)
+        oprot.writeI32(viter8)
+      oprot.writeMapEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.nameToTypePtr is None:
+      raise TProtocol.TProtocolException(message='Required field nameToTypePtr 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)
+
+class TUnionTypeEntry(object):
+  """
+  Attributes:
+   - nameToTypePtr
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.MAP, 'nameToTypePtr', (TTType.STRING,None,TTType.I32,None), None, ), # 1
+  )
+
+  def __init__(self, nameToTypePtr=None,):
+    self.nameToTypePtr = nameToTypePtr
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.MAP:
+          self.nameToTypePtr = {}
+          (_ktype10, _vtype11, _size9 ) = iprot.readMapBegin() 
+          for _i13 in xrange(_size9):
+            _key14 = iprot.readString();
+            _val15 = iprot.readI32();
+            self.nameToTypePtr[_key14] = _val15
+          iprot.readMapEnd()
+        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('TUnionTypeEntry')
+    if self.nameToTypePtr is not None:
+      oprot.writeFieldBegin('nameToTypePtr', TTType.MAP, 1)
+      oprot.writeMapBegin(TTType.STRING, TTType.I32, len(self.nameToTypePtr))
+      for kiter16,viter17 in self.nameToTypePtr.items():
+        oprot.writeString(kiter16)
+        oprot.writeI32(viter17)
+      oprot.writeMapEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.nameToTypePtr is None:
+      raise TProtocol.TProtocolException(message='Required field nameToTypePtr 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)
+
+class TUserDefinedTypeEntry(object):
+  """
+  Attributes:
+   - typeClassName
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRING, 'typeClassName', None, None, ), # 1
+  )
+
+  def __init__(self, typeClassName=None,):
+    self.typeClassName = typeClassName
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRING:
+          self.typeClassName = iprot.readString();
+        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('TUserDefinedTypeEntry')
+    if self.typeClassName is not None:
+      oprot.writeFieldBegin('typeClassName', TTType.STRING, 1)
+      oprot.writeString(self.typeClassName)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.typeClassName is None:
+      raise TProtocol.TProtocolException(message='Required field typeClassName 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)
+
+class TTypeEntry(object):
+  """
+  Attributes:
+   - primitiveEntry
+   - arrayEntry
+   - mapEntry
+   - structEntry
+   - unionEntry
+   - userDefinedTypeEntry
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'primitiveEntry', (TPrimitiveTypeEntry, TPrimitiveTypeEntry.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'arrayEntry', (TArrayTypeEntry, TArrayTypeEntry.thrift_spec), None, ), # 2
+    (3, TTType.STRUCT, 'mapEntry', (TMapTypeEntry, TMapTypeEntry.thrift_spec), None, ), # 3
+    (4, TTType.STRUCT, 'structEntry', (TStructTypeEntry, TStructTypeEntry.thrift_spec), None, ), # 4
+    (5, TTType.STRUCT, 'unionEntry', (TUnionTypeEntry, TUnionTypeEntry.thrift_spec), None, ), # 5
+    (6, TTType.STRUCT, 'userDefinedTypeEntry', (TUserDefinedTypeEntry, TUserDefinedTypeEntry.thrift_spec), None, ), # 6
+  )
+
+  def __init__(self, primitiveEntry=None, arrayEntry=None, mapEntry=None, structEntry=None, unionEntry=None, userDefinedTypeEntry=None,):
+    self.primitiveEntry = primitiveEntry
+    self.arrayEntry = arrayEntry
+    self.mapEntry = mapEntry
+    self.structEntry = structEntry
+    self.unionEntry = unionEntry
+    self.userDefinedTypeEntry = userDefinedTypeEntry
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.primitiveEntry = TPrimitiveTypeEntry()
+          self.primitiveEntry.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.arrayEntry = TArrayTypeEntry()
+          self.arrayEntry.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRUCT:
+          self.mapEntry = TMapTypeEntry()
+          self.mapEntry.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.STRUCT:
+          self.structEntry = TStructTypeEntry()
+          self.structEntry.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.STRUCT:
+          self.unionEntry = TUnionTypeEntry()
+          self.unionEntry.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TTType.STRUCT:
+          self.userDefinedTypeEntry = TUserDefinedTypeEntry()
+          self.userDefinedTypeEntry.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('TTTypeEntry')
+    if self.primitiveEntry is not None:
+      oprot.writeFieldBegin('primitiveEntry', TTType.STRUCT, 1)
+      self.primitiveEntry.write(oprot)
+      oprot.writeFieldEnd()
+    if self.arrayEntry is not None:
+      oprot.writeFieldBegin('arrayEntry', TTType.STRUCT, 2)
+      self.arrayEntry.write(oprot)
+      oprot.writeFieldEnd()
+    if self.mapEntry is not None:
+      oprot.writeFieldBegin('mapEntry', TTType.STRUCT, 3)
+      self.mapEntry.write(oprot)
+      oprot.writeFieldEnd()
+    if self.structEntry is not None:
+      oprot.writeFieldBegin('structEntry', TTType.STRUCT, 4)
+      self.structEntry.write(oprot)
+      oprot.writeFieldEnd()
+    if self.unionEntry is not None:
+      oprot.writeFieldBegin('unionEntry', TTType.STRUCT, 5)
+      self.unionEntry.write(oprot)
+      oprot.writeFieldEnd()
+    if self.userDefinedTypeEntry is not None:
+      oprot.writeFieldBegin('userDefinedTypeEntry', TTType.STRUCT, 6)
+      self.userDefinedTypeEntry.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 TTypeDesc(object):
+  """
+  Attributes:
+   - types
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.LIST, 'types', (TTType.STRUCT,(TTypeEntry, TTypeEntry.thrift_spec)), None, ), # 1
+  )
+
+  def __init__(self, types=None,):
+    self.types = types
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.LIST:
+          self.types = []
+          (_etype21, _size18) = iprot.readListBegin()
+          for _i22 in xrange(_size18):
+            _elem23 = TTypeEntry()
+            _elem23.read(iprot)
+            self.types.append(_elem23)
+          iprot.readListEnd()
+        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('TTypeDesc')
+    if self.types is not None:
+      oprot.writeFieldBegin('types', TTType.LIST, 1)
+      oprot.writeListBegin(TTType.STRUCT, len(self.types))
+      for iter24 in self.types:
+        iter24.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.types is None:
+      raise TProtocol.TProtocolException(message='Required field types 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)
+
+class TColumnDesc(object):
+  """
+  Attributes:
+   - columnName
+   - typeDesc
+   - position
+   - comment
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRING, 'columnName', None, None, ), # 1
+    (2, TTType.STRUCT, 'typeDesc', (TTypeDesc, TTypeDesc.thrift_spec), None, ), # 2
+    (3, TTType.I32, 'position', None, None, ), # 3
+    (4, TTType.STRING, 'comment', None, None, ), # 4
+  )
+
+  def __init__(self, columnName=None, typeDesc=None, position=None, comment=None,):
+    self.columnName = columnName
+    self.typeDesc = typeDesc
+    self.position = position
+    self.comment = comment
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRING:
+          self.columnName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.typeDesc = TTypeDesc()
+          self.typeDesc.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.I32:
+          self.position = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.STRING:
+          self.comment = iprot.readString();
+        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('TColumnDesc')
+    if self.columnName is not None:
+      oprot.writeFieldBegin('columnName', TTType.STRING, 1)
+      oprot.writeString(self.columnName)
+      oprot.writeFieldEnd()
+    if self.typeDesc is not None:
+      oprot.writeFieldBegin('typeDesc', TTType.STRUCT, 2)
+      self.typeDesc.write(oprot)
+      oprot.writeFieldEnd()
+    if self.position is not None:
+      oprot.writeFieldBegin('position', TTType.I32, 3)
+      oprot.writeI32(self.position)
+      oprot.writeFieldEnd()
+    if self.comment is not None:
+      oprot.writeFieldBegin('comment', TTType.STRING, 4)
+      oprot.writeString(self.comment)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.columnName is None:
+      raise TProtocol.TProtocolException(message='Required field columnName is unset!')
+    if self.typeDesc is None:
+      raise TProtocol.TProtocolException(message='Required field typeDesc is unset!')
+    if self.position is None:
+      raise TProtocol.TProtocolException(message='Required field position 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)
+
+class TTableSchema(object):
+  """
+  Attributes:
+   - columns
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.LIST, 'columns', (TTType.STRUCT,(TColumnDesc, TColumnDesc.thrift_spec)), None, ), # 1
+  )
+
+  def __init__(self, columns=None,):
+    self.columns = columns
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.LIST:
+          self.columns = []
+          (_etype28, _size25) = iprot.readListBegin()
+          for _i29 in xrange(_size25):
+            _elem30 = TColumnDesc()
+            _elem30.read(iprot)
+            self.columns.append(_elem30)
+          iprot.readListEnd()
+        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('TTableSchema')
+    if self.columns is not None:
+      oprot.writeFieldBegin('columns', TTType.LIST, 1)
+      oprot.writeListBegin(TTType.STRUCT, len(self.columns))
+      for iter31 in self.columns:
+        iter31.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.columns is None:
+      raise TProtocol.TProtocolException(message='Required field columns 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)
+
+class TBoolValue(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.BOOL, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.BOOL:
+          self.value = iprot.readBool();
+        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('TBoolValue')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.BOOL, 1)
+      oprot.writeBool(self.value)
+      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 TByteValue(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.BYTE, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.BYTE:
+          self.value = iprot.readByte();
+        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('TByteValue')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.BYTE, 1)
+      oprot.writeByte(self.value)
+      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 TI16Value(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I16, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I16:
+          self.value = iprot.readI16();
+        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('TI16Value')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.I16, 1)
+      oprot.writeI16(self.value)
+      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 TI32Value(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I32, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I32:
+          self.value = iprot.readI32();
+        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('TI32Value')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.I32, 1)
+      oprot.writeI32(self.value)
+      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 TI64Value(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I64, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I64:
+          self.value = iprot.readI64();
+        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('TI64Value')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.I64, 1)
+      oprot.writeI64(self.value)
+      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 TDoubleValue(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.DOUBLE, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.DOUBLE:
+          self.value = iprot.readDouble();
+        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('TDoubleValue')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.DOUBLE, 1)
+      oprot.writeDouble(self.value)
+      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 TStringValue(object):
+  """
+  Attributes:
+   - value
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRING, 'value', None, None, ), # 1
+  )
+
+  def __init__(self, value=None,):
+    self.value = value
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRING:
+          self.value = iprot.readString();
+        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('TStringValue')
+    if self.value is not None:
+      oprot.writeFieldBegin('value', TTType.STRING, 1)
+      oprot.writeString(self.value)
+      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 TColumn(object):
+  """
+  Attributes:
+   - boolColumn
+   - byteColumn
+   - i16Column
+   - i32Column
+   - i64Column
+   - doubleColumn
+   - stringColumn
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.LIST, 'boolColumn', (TTType.STRUCT,(TBoolValue, TBoolValue.thrift_spec)), None, ), # 1
+    (2, TTType.LIST, 'byteColumn', (TTType.STRUCT,(TByteValue, TByteValue.thrift_spec)), None, ), # 2
+    (3, TTType.LIST, 'i16Column', (TTType.STRUCT,(TI16Value, TI16Value.thrift_spec)), None, ), # 3
+    (4, TTType.LIST, 'i32Column', (TTType.STRUCT,(TI32Value, TI32Value.thrift_spec)), None, ), # 4
+    (5, TTType.LIST, 'i64Column', (TTType.STRUCT,(TI64Value, TI64Value.thrift_spec)), None, ), # 5
+    (6, TTType.LIST, 'doubleColumn', (TTType.STRUCT,(TDoubleValue, TDoubleValue.thrift_spec)), None, ), # 6
+    (7, TTType.LIST, 'stringColumn', (TTType.STRUCT,(TStringValue, TStringValue.thrift_spec)), None, ), # 7
+  )
+
+  def __init__(self, boolColumn=None, byteColumn=None, i16Column=None, i32Column=None, i64Column=None, doubleColumn=None, stringColumn=None,):
+    self.boolColumn = boolColumn
+    self.byteColumn = byteColumn
+    self.i16Column = i16Column
+    self.i32Column = i32Column
+    self.i64Column = i64Column
+    self.doubleColumn = doubleColumn
+    self.stringColumn = stringColumn
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.LIST:
+          self.boolColumn = []
+          (_etype35, _size32) = iprot.readListBegin()
+          for _i36 in xrange(_size32):
+            _elem37 = TBoolValue()
+            _elem37.read(iprot)
+            self.boolColumn.append(_elem37)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.LIST:
+          self.byteColumn = []
+          (_etype41, _size38) = iprot.readListBegin()
+          for _i42 in xrange(_size38):
+            _elem43 = TByteValue()
+            _elem43.read(iprot)
+            self.byteColumn.append(_elem43)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.LIST:
+          self.i16Column = []
+          (_etype47, _size44) = iprot.readListBegin()
+          for _i48 in xrange(_size44):
+            _elem49 = TI16Value()
+            _elem49.read(iprot)
+            self.i16Column.append(_elem49)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.LIST:
+          self.i32Column = []
+          (_etype53, _size50) = iprot.readListBegin()
+          for _i54 in xrange(_size50):
+            _elem55 = TI32Value()
+            _elem55.read(iprot)
+            self.i32Column.append(_elem55)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.LIST:
+          self.i64Column = []
+          (_etype59, _size56) = iprot.readListBegin()
+          for _i60 in xrange(_size56):
+            _elem61 = TI64Value()
+            _elem61.read(iprot)
+            self.i64Column.append(_elem61)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TTType.LIST:
+          self.doubleColumn = []
+          (_etype65, _size62) = iprot.readListBegin()
+          for _i66 in xrange(_size62):
+            _elem67 = TDoubleValue()
+            _elem67.read(iprot)
+            self.doubleColumn.append(_elem67)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TTType.LIST:
+          self.stringColumn = []
+          (_etype71, _size68) = iprot.readListBegin()
+          for _i72 in xrange(_size68):
+            _elem73 = TStringValue()
+            _elem73.read(iprot)
+            self.stringColumn.append(_elem73)
+          iprot.readListEnd()
+        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('TColumn')
+    if self.boolColumn is not None:
+      oprot.writeFieldBegin('boolColumn', TTType.LIST, 1)
+      oprot.writeListBegin(TTType.STRUCT, len(self.boolColumn))
+      for iter74 in self.boolColumn:
+        iter74.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.byteColumn is not None:
+      oprot.writeFieldBegin('byteColumn', TTType.LIST, 2)
+      oprot.writeListBegin(TTType.STRUCT, len(self.byteColumn))
+      for iter75 in self.byteColumn:
+        iter75.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.i16Column is not None:
+      oprot.writeFieldBegin('i16Column', TTType.LIST, 3)
+      oprot.writeListBegin(TTType.STRUCT, len(self.i16Column))
+      for iter76 in self.i16Column:
+        iter76.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.i32Column is not None:
+      oprot.writeFieldBegin('i32Column', TTType.LIST, 4)
+      oprot.writeListBegin(TTType.STRUCT, len(self.i32Column))
+      for iter77 in self.i32Column:
+        iter77.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.i64Column is not None:
+      oprot.writeFieldBegin('i64Column', TTType.LIST, 5)
+      oprot.writeListBegin(TTType.STRUCT, len(self.i64Column))
+      for iter78 in self.i64Column:
+        iter78.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.doubleColumn is not None:
+      oprot.writeFieldBegin('doubleColumn', TTType.LIST, 6)
+      oprot.writeListBegin(TTType.STRUCT, len(self.doubleColumn))
+      for iter79 in self.doubleColumn:
+        iter79.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.stringColumn is not None:
+      oprot.writeFieldBegin('stringColumn', TTType.LIST, 7)
+      oprot.writeListBegin(TTType.STRUCT, len(self.stringColumn))
+      for iter80 in self.stringColumn:
+        iter80.write(oprot)
+      oprot.writeListEnd()
+      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 TColumnValue(object):
+  """
+  Attributes:
+   - boolVal
+   - byteVal
+   - i16Val
+   - i32Val
+   - i64Val
+   - doubleVal
+   - stringVal
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'boolVal', (TBoolValue, TBoolValue.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'byteVal', (TByteValue, TByteValue.thrift_spec), None, ), # 2
+    (3, TTType.STRUCT, 'i16Val', (TI16Value, TI16Value.thrift_spec), None, ), # 3
+    (4, TTType.STRUCT, 'i32Val', (TI32Value, TI32Value.thrift_spec), None, ), # 4
+    (5, TTType.STRUCT, 'i64Val', (TI64Value, TI64Value.thrift_spec), None, ), # 5
+    (6, TTType.STRUCT, 'doubleVal', (TDoubleValue, TDoubleValue.thrift_spec), None, ), # 6
+    (7, TTType.STRUCT, 'stringVal', (TStringValue, TStringValue.thrift_spec), None, ), # 7
+  )
+
+  def __init__(self, boolVal=None, byteVal=None, i16Val=None, i32Val=None, i64Val=None, doubleVal=None, stringVal=None,):
+    self.boolVal = boolVal
+    self.byteVal = byteVal
+    self.i16Val = i16Val
+    self.i32Val = i32Val
+    self.i64Val = i64Val
+    self.doubleVal = doubleVal
+    self.stringVal = stringVal
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.boolVal = TBoolValue()
+          self.boolVal.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.byteVal = TByteValue()
+          self.byteVal.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRUCT:
+          self.i16Val = TI16Value()
+          self.i16Val.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.STRUCT:
+          self.i32Val = TI32Value()
+          self.i32Val.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.STRUCT:
+          self.i64Val = TI64Value()
+          self.i64Val.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TTType.STRUCT:
+          self.doubleVal = TDoubleValue()
+          self.doubleVal.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TTType.STRUCT:
+          self.stringVal = TStringValue()
+          self.stringVal.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('TColumnValue')
+    if self.boolVal is not None:
+      oprot.writeFieldBegin('boolVal', TTType.STRUCT, 1)
+      self.boolVal.write(oprot)
+      oprot.writeFieldEnd()
+    if self.byteVal is not None:
+      oprot.writeFieldBegin('byteVal', TTType.STRUCT, 2)
+      self.byteVal.write(oprot)
+      oprot.writeFieldEnd()
+    if self.i16Val is not None:
+      oprot.writeFieldBegin('i16Val', TTType.STRUCT, 3)
+      self.i16Val.write(oprot)
+      oprot.writeFieldEnd()
+    if self.i32Val is not None:
+      oprot.writeFieldBegin('i32Val', TTType.STRUCT, 4)
+      self.i32Val.write(oprot)
+      oprot.writeFieldEnd()
+    if self.i64Val is not None:
+      oprot.writeFieldBegin('i64Val', TTType.STRUCT, 5)
+      self.i64Val.write(oprot)
+      oprot.writeFieldEnd()
+    if self.doubleVal is not None:
+      oprot.writeFieldBegin('doubleVal', TTType.STRUCT, 6)
+      self.doubleVal.write(oprot)
+      oprot.writeFieldEnd()
+    if self.stringVal is not None:
+      oprot.writeFieldBegin('stringVal', TTType.STRUCT, 7)
+      self.stringVal.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 TRow(object):
+  """
+  Attributes:
+   - colVals
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.LIST, 'colVals', (TTType.STRUCT,(TColumnValue, TColumnValue.thrift_spec)), None, ), # 1
+  )
+
+  def __init__(self, colVals=None,):
+    self.colVals = colVals
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.LIST:
+          self.colVals = []
+          (_etype84, _size81) = iprot.readListBegin()
+          for _i85 in xrange(_size81):
+            _elem86 = TColumnValue()
+            _elem86.read(iprot)
+            self.colVals.append(_elem86)
+          iprot.readListEnd()
+        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('TRow')
+    if self.colVals is not None:
+      oprot.writeFieldBegin('colVals', TTType.LIST, 1)
+      oprot.writeListBegin(TTType.STRUCT, len(self.colVals))
+      for iter87 in self.colVals:
+        iter87.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.colVals is None:
+      raise TProtocol.TProtocolException(message='Required field colVals 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)
+
+class TRowSet(object):
+  """
+  Attributes:
+   - startRowOffset
+   - rows
+   - columns
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I64, 'startRowOffset', None, None, ), # 1
+    (2, TTType.LIST, 'rows', (TTType.STRUCT,(TRow, TRow.thrift_spec)), None, ), # 2
+    (3, TTType.LIST, 'columns', (TTType.STRUCT,(TColumn, TColumn.thrift_spec)), None, ), # 3
+  )
+
+  def __init__(self, startRowOffset=None, rows=None, columns=None,):
+    self.startRowOffset = startRowOffset
+    self.rows = rows
+    self.columns = columns
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I64:
+          self.startRowOffset = iprot.readI64();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.LIST:
+          self.rows = []
+          (_etype91, _size88) = iprot.readListBegin()
+          for _i92 in xrange(_size88):
+            _elem93 = TRow()
+            _elem93.read(iprot)
+            self.rows.append(_elem93)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.LIST:
+          self.columns = []
+          (_etype97, _size94) = iprot.readListBegin()
+          for _i98 in xrange(_size94):
+            _elem99 = TColumn()
+            _elem99.read(iprot)
+            self.columns.append(_elem99)
+          iprot.readListEnd()
+        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('TRowSet')
+    if self.startRowOffset is not None:
+      oprot.writeFieldBegin('startRowOffset', TTType.I64, 1)
+      oprot.writeI64(self.startRowOffset)
+      oprot.writeFieldEnd()
+    if self.rows is not None:
+      oprot.writeFieldBegin('rows', TTType.LIST, 2)
+      oprot.writeListBegin(TTType.STRUCT, len(self.rows))
+      for iter100 in self.rows:
+        iter100.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.columns is not None:
+      oprot.writeFieldBegin('columns', TTType.LIST, 3)
+      oprot.writeListBegin(TTType.STRUCT, len(self.columns))
+      for iter101 in self.columns:
+        iter101.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.startRowOffset is None:
+      raise TProtocol.TProtocolException(message='Required field startRowOffset is unset!')
+    if self.rows is None:
+      raise TProtocol.TProtocolException(message='Required field rows 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)
+
+class TStatus(object):
+  """
+  Attributes:
+   - statusCode
+   - infoMessages
+   - sqlState
+   - errorCode
+   - errorMessage
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I32, 'statusCode', None, None, ), # 1
+    (2, TTType.LIST, 'infoMessages', (TTType.STRING,None), None, ), # 2
+    (3, TTType.STRING, 'sqlState', None, None, ), # 3
+    (4, TTType.I32, 'errorCode', None, None, ), # 4
+    (5, TTType.STRING, 'errorMessage', None, None, ), # 5
+  )
+
+  def __init__(self, statusCode=None, infoMessages=None, sqlState=None, errorCode=None, errorMessage=None,):
+    self.statusCode = statusCode
+    self.infoMessages = infoMessages
+    self.sqlState = sqlState
+    self.errorCode = errorCode
+    self.errorMessage = errorMessage
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I32:
+          self.statusCode = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.LIST:
+          self.infoMessages = []
+          (_etype105, _size102) = iprot.readListBegin()
+          for _i106 in xrange(_size102):
+            _elem107 = iprot.readString();
+            self.infoMessages.append(_elem107)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRING:
+          self.sqlState = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.I32:
+          self.errorCode = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.STRING:
+          self.errorMessage = iprot.readString();
+        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('TStatus')
+    if self.statusCode is not None:
+      oprot.writeFieldBegin('statusCode', TTType.I32, 1)
+      oprot.writeI32(self.statusCode)
+      oprot.writeFieldEnd()
+    if self.infoMessages is not None:
+      oprot.writeFieldBegin('infoMessages', TTType.LIST, 2)
+      oprot.writeListBegin(TTType.STRING, len(self.infoMessages))
+      for iter108 in self.infoMessages:
+        oprot.writeString(iter108)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.sqlState is not None:
+      oprot.writeFieldBegin('sqlState', TTType.STRING, 3)
+      oprot.writeString(self.sqlState)
+      oprot.writeFieldEnd()
+    if self.errorCode is not None:
+      oprot.writeFieldBegin('errorCode', TTType.I32, 4)
+      oprot.writeI32(self.errorCode)
+      oprot.writeFieldEnd()
+    if self.errorMessage is not None:
+      oprot.writeFieldBegin('errorMessage', TTType.STRING, 5)
+      oprot.writeString(self.errorMessage)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.statusCode is None:
+      raise TProtocol.TProtocolException(message='Required field statusCode 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)
+
+class THandleIdentifier(object):
+  """
+  Attributes:
+   - guid
+   - secret
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRING, 'guid', None, None, ), # 1
+    (2, TTType.STRING, 'secret', None, None, ), # 2
+  )
+
+  def __init__(self, guid=None, secret=None,):
+    self.guid = guid
+    self.secret = secret
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRING:
+          self.guid = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.secret = iprot.readString();
+        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('THandleIdentifier')
+    if self.guid is not None:
+      oprot.writeFieldBegin('guid', TTType.STRING, 1)
+      oprot.writeString(self.guid)
+      oprot.writeFieldEnd()
+    if self.secret is not None:
+      oprot.writeFieldBegin('secret', TTType.STRING, 2)
+      oprot.writeString(self.secret)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.guid is None:
+      raise TProtocol.TProtocolException(message='Required field guid is unset!')
+    if self.secret is None:
+      raise TProtocol.TProtocolException(message='Required field secret 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)
+
+class TSessionHandle(object):
+  """
+  Attributes:
+   - sessionId
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionId', (THandleIdentifier, THandleIdentifier.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, sessionId=None,):
+    self.sessionId = sessionId
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionId = THandleIdentifier()
+          self.sessionId.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('TSessionHandle')
+    if self.sessionId is not None:
+      oprot.writeFieldBegin('sessionId', TTType.STRUCT, 1)
+      self.sessionId.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionId is None:
+      raise TProtocol.TProtocolException(message='Required field sessionId 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)
+
+class TOperationHandle(object):
+  """
+  Attributes:
+   - operationId
+   - operationType
+   - hasResultSet
+   - modifiedRowCount
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'operationId', (THandleIdentifier, THandleIdentifier.thrift_spec), None, ), # 1
+    (2, TTType.I32, 'operationType', None, None, ), # 2
+    (3, TTType.BOOL, 'hasResultSet', None, None, ), # 3
+    (4, TTType.DOUBLE, 'modifiedRowCount', None, None, ), # 4
+  )
+
+  def __init__(self, operationId=None, operationType=None, hasResultSet=None, modifiedRowCount=None,):
+    self.operationId = operationId
+    self.operationType = operationType
+    self.hasResultSet = hasResultSet
+    self.modifiedRowCount = modifiedRowCount
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.operationId = THandleIdentifier()
+          self.operationId.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I32:
+          self.operationType = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.BOOL:
+          self.hasResultSet = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.DOUBLE:
+          self.modifiedRowCount = iprot.readDouble();
+        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('TOperationHandle')
+    if self.operationId is not None:
+      oprot.writeFieldBegin('operationId', TTType.STRUCT, 1)
+      self.operationId.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationType is not None:
+      oprot.writeFieldBegin('operationType', TTType.I32, 2)
+      oprot.writeI32(self.operationType)
+      oprot.writeFieldEnd()
+    if self.hasResultSet is not None:
+      oprot.writeFieldBegin('hasResultSet', TTType.BOOL, 3)
+      oprot.writeBool(self.hasResultSet)
+      oprot.writeFieldEnd()
+    if self.modifiedRowCount is not None:
+      oprot.writeFieldBegin('modifiedRowCount', TTType.DOUBLE, 4)
+      oprot.writeDouble(self.modifiedRowCount)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.operationId is None:
+      raise TProtocol.TProtocolException(message='Required field operationId is unset!')
+    if self.operationType is None:
+      raise TProtocol.TProtocolException(message='Required field operationType is unset!')
+    if self.hasResultSet is None:
+      raise TProtocol.TProtocolException(message='Required field hasResultSet 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)
+
+class TOpenSessionReq(object):
+  """
+  Attributes:
+   - client_protocol
+   - username
+   - password
+   - configuration
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.I32, 'client_protocol', None,     0, ), # 1
+    (2, TTType.STRING, 'username', None, None, ), # 2
+    (3, TTType.STRING, 'password', None, None, ), # 3
+    (4, TTType.MAP, 'configuration', (TTType.STRING,None,TTType.STRING,None), None, ), # 4
+  )
+
+  def __init__(self, client_protocol=thrift_spec[1][4], username=None, password=None, configuration=None,):
+    self.client_protocol = client_protocol
+    self.username = username
+    self.password = password
+    self.configuration = configuration
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.I32:
+          self.client_protocol = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.username = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRING:
+          self.password = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.MAP:
+          self.configuration = {}
+          (_ktype110, _vtype111, _size109 ) = iprot.readMapBegin() 
+          for _i113 in xrange(_size109):
+            _key114 = iprot.readString();
+            _val115 = iprot.readString();
+            self.configuration[_key114] = _val115
+          iprot.readMapEnd()
+        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('TOpenSessionReq')
+    if self.client_protocol is not None:
+      oprot.writeFieldBegin('client_protocol', TTType.I32, 1)
+      oprot.writeI32(self.client_protocol)
+      oprot.writeFieldEnd()
+    if self.username is not None:
+      oprot.writeFieldBegin('username', TTType.STRING, 2)
+      oprot.writeString(self.username)
+      oprot.writeFieldEnd()
+    if self.password is not None:
+      oprot.writeFieldBegin('password', TTType.STRING, 3)
+      oprot.writeString(self.password)
+      oprot.writeFieldEnd()
+    if self.configuration is not None:
+      oprot.writeFieldBegin('configuration', TTType.MAP, 4)
+      oprot.writeMapBegin(TTType.STRING, TTType.STRING, len(self.configuration))
+      for kiter116,viter117 in self.configuration.items():
+        oprot.writeString(kiter116)
+        oprot.writeString(viter117)
+      oprot.writeMapEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.client_protocol is None:
+      raise TProtocol.TProtocolException(message='Required field client_protocol 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)
+
+class TOpenSessionResp(object):
+  """
+  Attributes:
+   - status
+   - serverProtocolVersion
+   - sessionHandle
+   - configuration
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.I32, 'serverProtocolVersion', None,     0, ), # 2
+    (3, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 3
+    (4, TTType.MAP, 'configuration', (TTType.STRING,None,TTType.STRING,None), None, ), # 4
+  )
+
+  def __init__(self, status=None, serverProtocolVersion=thrift_spec[2][4], sessionHandle=None, configuration=None,):
+    self.status = status
+    self.serverProtocolVersion = serverProtocolVersion
+    self.sessionHandle = sessionHandle
+    self.configuration = configuration
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I32:
+          self.serverProtocolVersion = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.MAP:
+          self.configuration = {}
+          (_ktype119, _vtype120, _size118 ) = iprot.readMapBegin() 
+          for _i122 in xrange(_size118):
+            _key123 = iprot.readString();
+            _val124 = iprot.readString();
+            self.configuration[_key123] = _val124
+          iprot.readMapEnd()
+        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('TOpenSessionResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.serverProtocolVersion is not None:
+      oprot.writeFieldBegin('serverProtocolVersion', TTType.I32, 2)
+      oprot.writeI32(self.serverProtocolVersion)
+      oprot.writeFieldEnd()
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 3)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.configuration is not None:
+      oprot.writeFieldBegin('configuration', TTType.MAP, 4)
+      oprot.writeMapBegin(TTType.STRING, TTType.STRING, len(self.configuration))
+      for kiter125,viter126 in self.configuration.items():
+        oprot.writeString(kiter125)
+        oprot.writeString(viter126)
+      oprot.writeMapEnd()
+      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.serverProtocolVersion is None:
+      raise TProtocol.TProtocolException(message='Required field serverProtocolVersion 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)
+
+class TCloseSessionReq(object):
+  """
+  Attributes:
+   - sessionHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, sessionHandle=None,):
+    self.sessionHandle = sessionHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.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('TCloseSessionReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TCloseSessionResp(object):
+  """
+  Attributes:
+   - status
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, status=None,):
+    self.status = status
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.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('TCloseSessionResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.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!')
+    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 TGetInfoValue(object):
+  """
+  Attributes:
+   - stringValue
+   - smallIntValue
+   - integerBitmask
+   - integerFlag
+   - binaryValue
+   - lenValue
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRING, 'stringValue', None, None, ), # 1
+    (2, TTType.I16, 'smallIntValue', None, None, ), # 2
+    (3, TTType.I32, 'integerBitmask', None, None, ), # 3
+    (4, TTType.I32, 'integerFlag', None, None, ), # 4
+    (5, TTType.I32, 'binaryValue', None, None, ), # 5
+    (6, TTType.I64, 'lenValue', None, None, ), # 6
+  )
+
+  def __init__(self, stringValue=None, smallIntValue=None, integerBitmask=None, integerFlag=None, binaryValue=None, lenValue=None,):
+    self.stringValue = stringValue
+    self.smallIntValue = smallIntValue
+    self.integerBitmask = integerBitmask
+    self.integerFlag = integerFlag
+    self.binaryValue = binaryValue
+    self.lenValue = lenValue
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRING:
+          self.stringValue = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I16:
+          self.smallIntValue = iprot.readI16();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.I32:
+          self.integerBitmask = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.I32:
+          self.integerFlag = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.I32:
+          self.binaryValue = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TTType.I64:
+          self.lenValue = iprot.readI64();
+        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('TGetInfoValue')
+    if self.stringValue is not None:
+      oprot.writeFieldBegin('stringValue', TTType.STRING, 1)
+      oprot.writeString(self.stringValue)
+      oprot.writeFieldEnd()
+    if self.smallIntValue is not None:
+      oprot.writeFieldBegin('smallIntValue', TTType.I16, 2)
+      oprot.writeI16(self.smallIntValue)
+      oprot.writeFieldEnd()
+    if self.integerBitmask is not None:
+      oprot.writeFieldBegin('integerBitmask', TTType.I32, 3)
+      oprot.writeI32(self.integerBitmask)
+      oprot.writeFieldEnd()
+    if self.integerFlag is not None:
+      oprot.writeFieldBegin('integerFlag', TTType.I32, 4)
+      oprot.writeI32(self.integerFlag)
+      oprot.writeFieldEnd()
+    if self.binaryValue is not None:
+      oprot.writeFieldBegin('binaryValue', TTType.I32, 5)
+      oprot.writeI32(self.binaryValue)
+      oprot.writeFieldEnd()
+    if self.lenValue is not None:
+      oprot.writeFieldBegin('lenValue', TTType.I64, 6)
+      oprot.writeI64(self.lenValue)
+      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 TGetInfoReq(object):
+  """
+  Attributes:
+   - sessionHandle
+   - infoType
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+    (2, TTType.I32, 'infoType', None, None, ), # 2
+  )
+
+  def __init__(self, sessionHandle=None, infoType=None,):
+    self.sessionHandle = sessionHandle
+    self.infoType = infoType
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I32:
+          self.infoType = iprot.readI32();
+        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('TGetInfoReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.infoType is not None:
+      oprot.writeFieldBegin('infoType', TTType.I32, 2)
+      oprot.writeI32(self.infoType)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle is unset!')
+    if self.infoType is None:
+      raise TProtocol.TProtocolException(message='Required field infoType 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)
+
+class TGetInfoResp(object):
+  """
+  Attributes:
+   - status
+   - infoValue
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'infoValue', (TGetInfoValue, TGetInfoValue.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, infoValue=None,):
+    self.status = status
+    self.infoValue = infoValue
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.infoValue = TGetInfoValue()
+          self.infoValue.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('TGetInfoResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.infoValue is not None:
+      oprot.writeFieldBegin('infoValue', TTType.STRUCT, 2)
+      self.infoValue.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.infoValue is None:
+      raise TProtocol.TProtocolException(message='Required field infoValue 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)
+
+class TExecuteStatementReq(object):
+  """
+  Attributes:
+   - sessionHandle
+   - statement
+   - confOverlay
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+    (2, TTType.STRING, 'statement', None, None, ), # 2
+    (3, TTType.MAP, 'confOverlay', (TTType.STRING,None,TTType.STRING,None), None, ), # 3
+  )
+
+  def __init__(self, sessionHandle=None, statement=None, confOverlay=None,):
+    self.sessionHandle = sessionHandle
+    self.statement = statement
+    self.confOverlay = confOverlay
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.statement = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.MAP:
+          self.confOverlay = {}
+          (_ktype128, _vtype129, _size127 ) = iprot.readMapBegin() 
+          for _i131 in xrange(_size127):
+            _key132 = iprot.readString();
+            _val133 = iprot.readString();
+            self.confOverlay[_key132] = _val133
+          iprot.readMapEnd()
+        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('TExecuteStatementReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.statement is not None:
+      oprot.writeFieldBegin('statement', TTType.STRING, 2)
+      oprot.writeString(self.statement)
+      oprot.writeFieldEnd()
+    if self.confOverlay is not None:
+      oprot.writeFieldBegin('confOverlay', TTType.MAP, 3)
+      oprot.writeMapBegin(TTType.STRING, TTType.STRING, len(self.confOverlay))
+      for kiter134,viter135 in self.confOverlay.items():
+        oprot.writeString(kiter134)
+        oprot.writeString(viter135)
+      oprot.writeMapEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle is unset!')
+    if self.statement is None:
+      raise TProtocol.TProtocolException(message='Required field statement 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)
+
+class TExecuteStatementResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TExecuteStatementResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetTypeInfoReq(object):
+  """
+  Attributes:
+   - sessionHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, sessionHandle=None,):
+    self.sessionHandle = sessionHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.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('TGetTypeInfoReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TGetTypeInfoResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetTypeInfoResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetCatalogsReq(object):
+  """
+  Attributes:
+   - sessionHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, sessionHandle=None,):
+    self.sessionHandle = sessionHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.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('TGetCatalogsReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TGetCatalogsResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetCatalogsResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetSchemasReq(object):
+  """
+  Attributes:
+   - sessionHandle
+   - catalogName
+   - schemaName
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+    (2, TTType.STRING, 'catalogName', None, None, ), # 2
+    (3, TTType.STRING, 'schemaName', None, None, ), # 3
+  )
+
+  def __init__(self, sessionHandle=None, catalogName=None, schemaName=None,):
+    self.sessionHandle = sessionHandle
+    self.catalogName = catalogName
+    self.schemaName = schemaName
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.catalogName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRING:
+          self.schemaName = iprot.readString();
+        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('TGetSchemasReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.catalogName is not None:
+      oprot.writeFieldBegin('catalogName', TTType.STRING, 2)
+      oprot.writeString(self.catalogName)
+      oprot.writeFieldEnd()
+    if self.schemaName is not None:
+      oprot.writeFieldBegin('schemaName', TTType.STRING, 3)
+      oprot.writeString(self.schemaName)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TGetSchemasResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetSchemasResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetTablesReq(object):
+  """
+  Attributes:
+   - sessionHandle
+   - catalogName
+   - schemaName
+   - tableName
+   - tableTypes
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+    (2, TTType.STRING, 'catalogName', None, None, ), # 2
+    (3, TTType.STRING, 'schemaName', None, None, ), # 3
+    (4, TTType.STRING, 'tableName', None, None, ), # 4
+    (5, TTType.LIST, 'tableTypes', (TTType.STRING,None), None, ), # 5
+  )
+
+  def __init__(self, sessionHandle=None, catalogName=None, schemaName=None, tableName=None, tableTypes=None,):
+    self.sessionHandle = sessionHandle
+    self.catalogName = catalogName
+    self.schemaName = schemaName
+    self.tableName = tableName
+    self.tableTypes = tableTypes
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.catalogName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRING:
+          self.schemaName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.STRING:
+          self.tableName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.LIST:
+          self.tableTypes = []
+          (_etype139, _size136) = iprot.readListBegin()
+          for _i140 in xrange(_size136):
+            _elem141 = iprot.readString();
+            self.tableTypes.append(_elem141)
+          iprot.readListEnd()
+        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('TGetTablesReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.catalogName is not None:
+      oprot.writeFieldBegin('catalogName', TTType.STRING, 2)
+      oprot.writeString(self.catalogName)
+      oprot.writeFieldEnd()
+    if self.schemaName is not None:
+      oprot.writeFieldBegin('schemaName', TTType.STRING, 3)
+      oprot.writeString(self.schemaName)
+      oprot.writeFieldEnd()
+    if self.tableName is not None:
+      oprot.writeFieldBegin('tableName', TTType.STRING, 4)
+      oprot.writeString(self.tableName)
+      oprot.writeFieldEnd()
+    if self.tableTypes is not None:
+      oprot.writeFieldBegin('tableTypes', TTType.LIST, 5)
+      oprot.writeListBegin(TTType.STRING, len(self.tableTypes))
+      for iter142 in self.tableTypes:
+        oprot.writeString(iter142)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TGetTablesResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetTablesResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetTableTypesReq(object):
+  """
+  Attributes:
+   - sessionHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, sessionHandle=None,):
+    self.sessionHandle = sessionHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.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('TGetTableTypesReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TGetTableTypesResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetTableTypesResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetColumnsReq(object):
+  """
+  Attributes:
+   - sessionHandle
+   - catalogName
+   - schemaName
+   - tableName
+   - columnName
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+    (2, TTType.STRING, 'catalogName', None, None, ), # 2
+    (3, TTType.STRING, 'schemaName', None, None, ), # 3
+    (4, TTType.STRING, 'tableName', None, None, ), # 4
+    (5, TTType.STRING, 'columnName', None, None, ), # 5
+  )
+
+  def __init__(self, sessionHandle=None, catalogName=None, schemaName=None, tableName=None, columnName=None,):
+    self.sessionHandle = sessionHandle
+    self.catalogName = catalogName
+    self.schemaName = schemaName
+    self.tableName = tableName
+    self.columnName = columnName
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.catalogName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRING:
+          self.schemaName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.STRING:
+          self.tableName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TTType.STRING:
+          self.columnName = iprot.readString();
+        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('TGetColumnsReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.catalogName is not None:
+      oprot.writeFieldBegin('catalogName', TTType.STRING, 2)
+      oprot.writeString(self.catalogName)
+      oprot.writeFieldEnd()
+    if self.schemaName is not None:
+      oprot.writeFieldBegin('schemaName', TTType.STRING, 3)
+      oprot.writeString(self.schemaName)
+      oprot.writeFieldEnd()
+    if self.tableName is not None:
+      oprot.writeFieldBegin('tableName', TTType.STRING, 4)
+      oprot.writeString(self.tableName)
+      oprot.writeFieldEnd()
+    if self.columnName is not None:
+      oprot.writeFieldBegin('columnName', TTType.STRING, 5)
+      oprot.writeString(self.columnName)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle 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)
+
+class TGetColumnsResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetColumnsResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetFunctionsReq(object):
+  """
+  Attributes:
+   - sessionHandle
+   - catalogName
+   - schemaName
+   - functionName
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 1
+    (2, TTType.STRING, 'catalogName', None, None, ), # 2
+    (3, TTType.STRING, 'schemaName', None, None, ), # 3
+    (4, TTType.STRING, 'functionName', None, None, ), # 4
+  )
+
+  def __init__(self, sessionHandle=None, catalogName=None, schemaName=None, functionName=None,):
+    self.sessionHandle = sessionHandle
+    self.catalogName = catalogName
+    self.schemaName = schemaName
+    self.functionName = functionName
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.sessionHandle = TSessionHandle()
+          self.sessionHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRING:
+          self.catalogName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRING:
+          self.schemaName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TTType.STRING:
+          self.functionName = iprot.readString();
+        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('TGetFunctionsReq')
+    if self.sessionHandle is not None:
+      oprot.writeFieldBegin('sessionHandle', TTType.STRUCT, 1)
+      self.sessionHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.catalogName is not None:
+      oprot.writeFieldBegin('catalogName', TTType.STRING, 2)
+      oprot.writeString(self.catalogName)
+      oprot.writeFieldEnd()
+    if self.schemaName is not None:
+      oprot.writeFieldBegin('schemaName', TTType.STRING, 3)
+      oprot.writeString(self.schemaName)
+      oprot.writeFieldEnd()
+    if self.functionName is not None:
+      oprot.writeFieldBegin('functionName', TTType.STRING, 4)
+      oprot.writeString(self.functionName)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.sessionHandle is None:
+      raise TProtocol.TProtocolException(message='Required field sessionHandle is unset!')
+    if self.functionName is None:
+      raise TProtocol.TProtocolException(message='Required field functionName 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)
+
+class TGetFunctionsResp(object):
+  """
+  Attributes:
+   - status
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, operationHandle=None,):
+    self.status = status
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetFunctionsResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 2)
+      self.operationHandle.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!')
+    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 TGetOperationStatusReq(object):
+  """
+  Attributes:
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, operationHandle=None,):
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetOperationStatusReq')
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 1)
+      self.operationHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.operationHandle is None:
+      raise TProtocol.TProtocolException(message='Required field operationHandle 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)
+
+class TGetOperationStatusResp(object):
+  """
+  Attributes:
+   - status
+   - operationState
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.I32, 'operationState', None, None, ), # 2
+  )
+
+  def __init__(self, status=None, operationState=None,):
+    self.status = status
+    self.operationState = operationState
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I32:
+          self.operationState = iprot.readI32();
+        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('TGetOperationStatusResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.operationState is not None:
+      oprot.writeFieldBegin('operationState', TTType.I32, 2)
+      oprot.writeI32(self.operationState)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.status is None:
+      raise TProtocol.TProtocolException(message='Required field status 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)
+
+class TCancelOperationReq(object):
+  """
+  Attributes:
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, operationHandle=None,):
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TCancelOperationReq')
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 1)
+      self.operationHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.operationHandle is None:
+      raise TProtocol.TProtocolException(message='Required field operationHandle 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)
+
+class TCancelOperationResp(object):
+  """
+  Attributes:
+   - status
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, status=None,):
+    self.status = status
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.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('TCancelOperationResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.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!')
+    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 TCloseOperationReq(object):
+  """
+  Attributes:
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, operationHandle=None,):
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TCloseOperationReq')
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 1)
+      self.operationHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.operationHandle is None:
+      raise TProtocol.TProtocolException(message='Required field operationHandle 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)
+
+class TCloseOperationResp(object):
+  """
+  Attributes:
+   - status
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, status=None,):
+    self.status = status
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.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('TCloseOperationResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.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!')
+    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 TGetResultSetMetadataReq(object):
+  """
+  Attributes:
+   - operationHandle
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, operationHandle=None,):
+    self.operationHandle = operationHandle
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.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('TGetResultSetMetadataReq')
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 1)
+      self.operationHandle.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.operationHandle is None:
+      raise TProtocol.TProtocolException(message='Required field operationHandle 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)
+
+class TGetResultSetMetadataResp(object):
+  """
+  Attributes:
+   - status
+   - schema
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.STRUCT, 'schema', (TTableSchema, TTableSchema.thrift_spec), None, ), # 2
+  )
+
+  def __init__(self, status=None, schema=None,):
+    self.status = status
+    self.schema = schema
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.STRUCT:
+          self.schema = TTableSchema()
+          self.schema.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('TGetResultSetMetadataResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.schema is not None:
+      oprot.writeFieldBegin('schema', TTType.STRUCT, 2)
+      self.schema.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!')
+    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 TFetchResultsReq(object):
+  """
+  Attributes:
+   - operationHandle
+   - orientation
+   - maxRows
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'operationHandle', (TOperationHandle, TOperationHandle.thrift_spec), None, ), # 1
+    (2, TTType.I32, 'orientation', None,     0, ), # 2
+    (3, TTType.I64, 'maxRows', None, None, ), # 3
+  )
+
+  def __init__(self, operationHandle=None, orientation=thrift_spec[2][4], maxRows=None,):
+    self.operationHandle = operationHandle
+    self.orientation = orientation
+    self.maxRows = maxRows
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.operationHandle = TOperationHandle()
+          self.operationHandle.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.I32:
+          self.orientation = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.I64:
+          self.maxRows = iprot.readI64();
+        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('TFetchResultsReq')
+    if self.operationHandle is not None:
+      oprot.writeFieldBegin('operationHandle', TTType.STRUCT, 1)
+      self.operationHandle.write(oprot)
+      oprot.writeFieldEnd()
+    if self.orientation is not None:
+      oprot.writeFieldBegin('orientation', TTType.I32, 2)
+      oprot.writeI32(self.orientation)
+      oprot.writeFieldEnd()
+    if self.maxRows is not None:
+      oprot.writeFieldBegin('maxRows', TTType.I64, 3)
+      oprot.writeI64(self.maxRows)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.operationHandle is None:
+      raise TProtocol.TProtocolException(message='Required field operationHandle is unset!')
+    if self.orientation is None:
+      raise TProtocol.TProtocolException(message='Required field orientation is unset!')
+    if self.maxRows is None:
+      raise TProtocol.TProtocolException(message='Required field maxRows 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)
+
+class TFetchResultsResp(object):
+  """
+  Attributes:
+   - status
+   - hasMoreRows
+   - results
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TTType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1
+    (2, TTType.BOOL, 'hasMoreRows', None, None, ), # 2
+    (3, TTType.STRUCT, 'results', (TRowSet, TRowSet.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, status=None, hasMoreRows=None, results=None,):
+    self.status = status
+    self.hasMoreRows = hasMoreRows
+    self.results = results
+
+  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 == TTType.STOP:
+        break
+      if fid == 1:
+        if ftype == TTType.STRUCT:
+          self.status = TStatus()
+          self.status.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TTType.BOOL:
+          self.hasMoreRows = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TTType.STRUCT:
+          self.results = TRowSet()
+          self.results.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('TFetchResultsResp')
+    if self.status is not None:
+      oprot.writeFieldBegin('status', TTType.STRUCT, 1)
+      self.status.write(oprot)
+      oprot.writeFieldEnd()
+    if self.hasMoreRows is not None:
+      oprot.writeFieldBegin('hasMoreRows', TTType.BOOL, 2)
+      oprot.writeBool(self.hasMoreRows)
+      oprot.writeFieldEnd()
+    if self.results is not None:
+      oprot.writeFieldBegin('results', TTType.STRUCT, 3)
+      self.results.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!')
+    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)

+ 1 - 0
apps/beeswax/regenerate_thrift.sh

@@ -22,6 +22,7 @@ cd $(dirname $0)
 
 thrift -I thrift/include -r --gen py:new_style -o ./ thrift/beeswax.thrift
 thrift -I thrift/include -r --gen java:hashcode -o java/src/main thrift/beeswax.thrift
+thrift -I thrift/include -r --gen py:new_style -o ./ thrift/cli_service.thrift
 
 # We don't need to have generated code for the metastore, since that's
 # in one of the hive jars that we include

+ 1 - 1
apps/beeswax/setup.py

@@ -23,7 +23,7 @@ setup(
       url = 'http://github.com/cloudera/hue',
       description = "Hive Interface on Hue",
       packages = find_packages('src') + find_packages('gen-py'),
-      package_dir = {'hive_metastore': 'gen-py', 'beeswaxd': 'gen-py', 'fb303': 'gen-py', '': 'src'},
+      package_dir = {'hive_metastore': 'gen-py', 'beeswaxd': 'gen-py', 'fb303': 'gen-py', 'cli_service': 'gen-py', '': 'src'},
       install_requires = ['setuptools', 'desktop'],
       entry_points = {
         'desktop.sdk.application': 'beeswax=beeswax',

+ 0 - 11
apps/beeswax/src/beeswax/common.py

@@ -22,7 +22,6 @@ Common utils for beeswax.
 import re
 
 from django import forms
-from beeswax import db_utils
 
 
 HIVE_IDENTIFER_REGEX = re.compile("^[a-zA-Z0-9]\w*$")
@@ -67,13 +66,3 @@ class HiveIdentifierField(forms.RegexField):
   def __init__(self, *args, **kwargs):
     kwargs['regex'] = HIVE_IDENTIFER_REGEX
     super(HiveIdentifierField, self).__init__(*args, **kwargs)
-
-
-class HiveTableChoiceField(forms.ChoiceField):
-  """To choose from a defined table"""
-  def __init__(self, *args, **kwargs):
-    table_names = db_utils.meta_client().get_tables("default", ".*")
-    kwargs['choices'] = to_choices([''] + table_names)
-    forms.ChoiceField.__init__(self, *args, **kwargs)
-
-

+ 6 - 0
apps/beeswax/src/beeswax/conf.py

@@ -21,6 +21,12 @@ from django.utils.translation import ugettext_lazy as _
 from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection, coerce_bool
 
 
+SERVER_INTERFACE = Config(
+  key="server_interface",
+  help=_("Beeswax or Hive Server 2 Thrift API used. Choices are: 'beeswax' or 'hiveserver2'."),
+  default="beeswax")
+
+
 QUERY_SERVERS = UnspecifiedConfigSection(
   "query_servers",
   help=_("One entry for each Query Server that can execute some queries."),

+ 37 - 26
apps/beeswax/src/beeswax/create_table.py

@@ -23,6 +23,7 @@ import logging
 import gzip
 
 from django.core import urlresolvers
+from django.utils.translation import ugettext as _
 
 from desktop.lib import django_mako, i18n
 from desktop.lib.django_util import render
@@ -30,16 +31,18 @@ from desktop.lib.exceptions import PopupException
 from desktop.lib.django_forms import MultiForm
 from hadoop.fs import hadoopfs
 
-import beeswax.common
-import beeswax.forms
+from beeswax.common import TERMINATORS
+from beeswax.design import hql_query
+from beeswax.forms import CreateTableForm, ColumnTypeFormSet,\
+  PartitionTypeFormSet, CreateByImportFileForm, CreateByImportDelimForm,\
+  TERMINATOR_CHOICES
+from beeswax.server import dbms
 from beeswax.views import describe_table, execute_directly
-from beeswax.views import make_beeswax_query
-from beeswax import db_utils
 
-from django.utils.translation import ugettext as _
 
 LOG = logging.getLogger(__name__)
 
+
 def index(request):
   """Main create table entry point, to divert into manual creation vs create from file."""
   return render("create_table_index.mako", request, {})
@@ -47,12 +50,17 @@ def index(request):
 
 def create_table(request):
   """Create a table by specifying its attributes manually"""
+  db = dbms.get(request.user)
+
   form = MultiForm(
-      table=beeswax.forms.CreateTableForm,
-      columns=beeswax.forms.ColumnTypeFormSet,
-      partitions=beeswax.forms.PartitionTypeFormSet)
+      table=CreateTableForm,
+      columns=ColumnTypeFormSet,
+      partitions=PartitionTypeFormSet)
+
   if request.method == "POST":
     form.bind(request.POST)
+    form.table.db = db  # curry is invalid
+
     if form.is_valid():
       columns = [ f.cleaned_data for f in form.columns.forms ]
       partition_columns = [ f.cleaned_data for f in form.partitions.forms ]
@@ -69,18 +77,19 @@ def create_table(request):
       return _submit_create_and_load(request, proposed_query, table_name, None, False)
   else:
     form.bind()
+
   return render("create_table_manually.mako", request, dict(
     action="#",
     table_form=form.table,
     columns_form=form.columns,
     partitions_form=form.partitions,
-    has_tables=len(db_utils.meta_client().get_tables("default", ".*")) > 0
+    has_tables=len(dbms.get(request.user).get_tables()) > 0
   ))
 
 
 IMPORT_PEEK_SIZE = 8192
 IMPORT_PEEK_NLINES = 10
-DELIMITERS = [ hive_val for hive_val, desc, ascii in beeswax.common.TERMINATORS ]
+DELIMITERS = [ hive_val for hive_val, desc, ascii in TERMINATORS ]
 DELIMITER_READABLE = {'\\001' : _('ctrl-As'),
                       '\\002' : _('ctrl-Bs'),
                       '\\003' : _('ctrl-Cs'),
@@ -122,7 +131,8 @@ def import_wizard(request):
       s3_col_formset = None
 
       # Everything requires a valid file form
-      s1_file_form = beeswax.forms.CreateByImportFileForm(request.POST)
+      db = dbms.get(request.user)
+      s1_file_form = CreateByImportFileForm(request.POST, db=db)
       if not s1_file_form.is_valid():
         break
 
@@ -147,14 +157,14 @@ def import_wizard(request):
       #
       if not do_s2_auto_delim:
         # We should have a valid delim form
-        s2_delim_form = beeswax.forms.CreateByImportDelimForm(request.POST)
+        s2_delim_form = CreateByImportDelimForm(request.POST)
         if not s2_delim_form.is_valid():
           # Go back to picking delimiter
           do_s2_user_delim, do_s3_column_def, do_hive_create = True, False, False
 
       if do_hive_create:
         # We should have a valid columns formset
-        s3_col_formset = beeswax.forms.ColumnTypeFormSet(prefix='cols', data=request.POST)
+        s3_col_formset = ColumnTypeFormSet(prefix='cols', data=request.POST)
         if not s3_col_formset.is_valid():
           # Go back to define columns
           do_s3_column_def, do_hive_create = True, False
@@ -188,7 +198,7 @@ def import_wizard(request):
           file_form=s1_file_form,
           delim_form=s2_delim_form,
           fields_list=fields_list,
-          delimiter_choices=beeswax.forms.TERMINATOR_CHOICES,
+          delimiter_choices=TERMINATOR_CHOICES,
           n_cols=n_cols,
         ))
 
@@ -203,7 +213,7 @@ def import_wizard(request):
                 column_name='col_%s' % (i,),
                 column_type='string',
             ))
-          s3_col_formset = beeswax.forms.ColumnTypeFormSet(prefix='cols', initial=columns)
+          s3_col_formset = ColumnTypeFormSet(prefix='cols', initial=columns)
         return render('define_columns.mako', request, dict(
           action=urlresolvers.reverse(import_wizard),
           file_form=s1_file_form,
@@ -234,7 +244,7 @@ def import_wizard(request):
         path = s1_file_form.cleaned_data['path']
         return _submit_create_and_load(request, proposed_query, table_name, path, do_load_data)
   else:
-    s1_file_form = beeswax.forms.CreateByImportFileForm()
+    s1_file_form = CreateByImportFileForm()
 
   return render('choose_file.mako', request, dict(
     action=urlresolvers.reverse(import_wizard),
@@ -247,15 +257,16 @@ def _submit_create_and_load(request, create_hql, table_name, path, do_load):
   Submit the table creation, and setup the load to happen (if ``do_load``).
   """
   on_success_params = { }
+
   if do_load:
     on_success_params['table'] = table_name
     on_success_params['path'] = path
-    on_success_url = urlresolvers.reverse(beeswax.create_table.load_after_create)
+    on_success_url = urlresolvers.reverse(load_after_create)
   else:
     on_success_url = urlresolvers.reverse(describe_table, kwargs={'table': table_name})
 
-  query_msg = make_beeswax_query(request, create_hql)
-  return execute_directly(request, query_msg,
+  query = hql_query(create_hql)
+  return execute_directly(request, query,
                           on_success_url=on_success_url,
                           on_success_params=on_success_params)
 
@@ -286,14 +297,14 @@ def _delim_preview(fs, file_form, encoding, file_types, delimiters):
   delimiter_0 = delim
   delimiter_1 = ''
   # If custom delimiter
-  if not filter(lambda val: val[0] == delim, beeswax.forms.TERMINATOR_CHOICES):
+  if not filter(lambda val: val[0] == delim, TERMINATOR_CHOICES):
     delimiter_0 = '__other__'
     delimiter_1 = delim
 
-  delim_form = beeswax.forms.CreateByImportDelimForm(dict(delimiter_0=delimiter_0,
-                                                          delimiter_1=delimiter_1,
-                                                          file_type=file_type,
-                                                          n_cols=n_cols))
+  delim_form = CreateByImportDelimForm(dict(delimiter_0=delimiter_0,
+                                            delimiter_1=delimiter_1,
+                                            file_type=file_type,
+                                            n_cols=n_cols))
   if not delim_form.is_valid():
     assert False, _('Internal error when constructing the delimiter form: %(error)s' % {'error': delim_form.errors})
   return fields_list, n_cols, delim_form
@@ -441,7 +452,7 @@ def load_after_create(request):
 
   LOG.debug("Auto loading data from %s into table %s" % (path, tablename))
   hql = "LOAD DATA INPATH '%s' INTO TABLE `%s`" % (path, tablename)
-  query_msg = make_beeswax_query(request, hql)
+  query = hql_query(hql)
   on_success_url = urlresolvers.reverse(describe_table, kwargs={'table': tablename})
 
-  return execute_directly(request, query_msg, on_success_url=on_success_url)
+  return execute_directly(request, query, on_success_url=on_success_url)

+ 27 - 48
apps/beeswax/src/beeswax/data_export.py

@@ -22,20 +22,17 @@ import time
 
 from django.http import HttpResponse
 
-from beeswax import common
-from beeswax import db_utils
-from beeswaxd.ttypes import QueryHandle
-
 from desktop.lib.export_csvxls import CSVformatter, XLSformatter, TooBigToDownloadException
 
-from django.utils.translation import ugettext as _
+from beeswax import common
+
 
 LOG = logging.getLogger(__name__)
 
 _DATA_WAIT_SLEEP = 0.1                  # Sleep 0.1 sec before checking for data availability
 
 
-def download(query_model, format):
+def download(handle, format, db):
   """
   download(query_model, format) -> HttpResponse
 
@@ -52,13 +49,14 @@ def download(query_model, format):
     formatter = XLSformatter()
     mimetype = 'application/xls'
 
-  gen = data_generator(query_model, formatter)
+  gen = data_generator(handle, formatter, db)
   resp = HttpResponse(gen, mimetype=mimetype)
   resp['Content-Disposition'] = 'attachment; filename=query_result.%s' % (format,)
+
   return resp
 
 
-def data_generator(query_model, formatter):
+def data_generator(handle, formatter, db):
   """
   data_generator(query_model, formatter) -> generator object
 
@@ -67,51 +65,32 @@ def data_generator(query_model, formatter):
   This is similar to export_csvxls.generator, but has
   one or two extra complexities.
   """
-  global _DATA_WAIT_SLEEP
+  _DATA_WAIT_SLEEP
   is_first_row = True
-  next_row = 0
-  results = None
-  handle = QueryHandle(query_model.server_id, query_model.log_context)
 
   yield formatter.init_doc()
 
-  while True:
-    # Make sure that we have the next batch of ready results
-    while results is None or not results.ready:
-      results = db_utils.db_client(query_model.get_query_server()).fetch(handle, start_over=is_first_row, fetch_size=-1)
-      if not results.ready:
-        time.sleep(_DATA_WAIT_SLEEP)
-
-    # Someone is reading the results concurrently. Abort.
-    # But unfortunately, this current generator will produce incomplete data.
-    if next_row != results.start_row:
-      msg = _('Error: Potentially incomplete results as an error occurred during data retrieval.')
-      yield formatter.format_row([msg])
-      err = (_('Detected another client retrieving results for %(server_id)s. '
-             'Expected next row to be %(row)s and got %(start_row)s. Aborting') %
-             {'server_id': query_model.server_id, 'row': next_row, 'start_row': results.start_row})
-      LOG.error(err)
-      raise RuntimeError(err)
+  results = db.fetch(handle, start_over=is_first_row, rows=None)
 
+  while results is not None:
+    while not results.ready:   # For Beeswax
+      time.sleep(_DATA_WAIT_SLEEP)
+      results = db.fetch(handle, start_over=is_first_row, rows=None)
+
+    # TODO Check for concurrent reading when HS2 supports start_row
     if is_first_row:
       is_first_row = False
-      yield formatter.format_header(results.columns)
+      yield formatter.format_header(results.cols())
+
+    for row in results.rows():
+      try:
+        yield formatter.format_row(row)
+      except TooBigToDownloadException, ex:
+        LOG.error(ex)
+
+    if results.has_more:
+      results = db.fetch(handle, start_over=is_first_row, rows=None)
     else:
-      for i, row in enumerate(results.data):
-        # TODO(bc): Hive seems to always return tab delimited row data.
-        # What if a cell has a tab?
-        row = row.split('\t')
-        try:
-          yield formatter.format_row(row)
-        except TooBigToDownloadException, ex:
-          LOG.error(ex)
-          # Exceeded limit. Stop.
-          results.has_more = False
-          break
-
-      if results.has_more:
-        next_row += len(results.data)
-        results = None
-      else:
-        yield formatter.fini_doc()
-        break
+      results = None
+
+  yield formatter.fini_doc()

+ 0 - 377
apps/beeswax/src/beeswax/db_utils.py

@@ -1,377 +0,0 @@
-#!/usr/bin/env python
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""
-Utils for interacting with Beeswaxd/Hive
-"""
-
-import logging
-import thrift
-import time
-
-import hadoop.cluster
-
-from beeswax import conf
-from beeswax import models
-from beeswax import hive_site
-from beeswax.models import QueryHistory
-from beeswaxd import BeeswaxService
-
-from django.utils.encoding import smart_str, force_unicode
-from desktop.lib import thrift_util
-from hive_metastore import ThriftHiveMetastore
-from beeswaxd.ttypes import BeeswaxException, QueryHandle, QueryNotFoundException
-
-from django.utils.translation import ugettext_lazy as _
-
-LOG = logging.getLogger(__name__)
-
-
-def execute_directly(user, query_msg, query_server=None, design=None, notify=False):
-  """
-  execute_directly(user, query_msg [,design]) -> QueryHistory object
-
-  This method also creates a QueryHistory object and saves it.
-  user - Django user.
-  query_msg - The thrift Query object.
-  design - The SavedQuery object (i.e. design) associated with this query.
-  notify - Whether to notify the user upon completion.
-  """
-  if query_server is None:
-    query_server = get_query_server(support_ddl=True) # For convenience with DDL queries only
-
-  query_history = QueryHistory(
-                            owner=user,
-                            query=query_msg.query,
-                            server_host='%(server_host)s' % query_server,
-                            server_port='%(server_port)d' % query_server,
-                            server_name='%(server_name)s' % query_server,
-                            last_state=QueryHistory.STATE.submitted.index,
-                            design=design,
-                            notify=notify)
-  query_history.save()
-  LOG.debug("Made new QueryHistory id %s user %s query: %s..." %
-            (query_history.id, user, query_history.query[:25]))
-
-  # Now submit it
-  try:
-    handle = db_client(query_server).query(query_msg)
-    if not handle or not handle.id:
-      # It really shouldn't happen
-      msg = _("BeeswaxServer returning invalid handle for query id %(id)d [%(query)s]...") % \
-            {'id': query_history.id, 'query': query_msg.query[:40]}
-      raise Exception(msg)
-  except BeeswaxException, bex:
-    # Kind of expected (hql compile/syntax error, etc.)
-    if bex.handle:
-      query_history.server_id = bex.handle.id
-      query_history.log_context = bex.handle.log_context
-    query_history.save_state(QueryHistory.STATE.failed)
-    raise bex
-  except Exception, ex:
-    LOG.exception(ex)
-    query_history.save_state(QueryHistory.STATE.failed)
-    raise ex
-
-  # All good
-  query_history.server_id = handle.id
-  query_history.log_context = handle.log_context
-  query_history.save_state(QueryHistory.STATE.running)
-  return query_history
-
-
-def wait_for_results(query_history, timeout_sec=30.0):
-  """
-  wait_for_results(query_history [,timeout_sec]) -> results or None
-
-  timeout_sec: 0 to be non-blocking. Default to 30 seconds.
-  Return the results when the query is completed, or None on timeout.
-  May raise BeeswaxException.
-  """
-  SLEEP_INTERVAL = 0.5
-  START_OVER = True
-
-  handle = QueryHandle(id=query_history.server_id, log_context=query_history.log_context)
-
-  curr = time.time()
-  end = curr + timeout_sec
-  while curr <= end:
-    results = db_client(query_history.get_query_server()).fetch(handle, START_OVER, fetch_size=-1)
-    if results.ready:
-      return results
-    time.sleep(SLEEP_INTERVAL)
-    curr = time.time()
-  return None
-
-
-def execute_and_wait(user, query_msg, query_server=None, timeout_sec=30.0):
-  """
-  execute_and_wait(user, query_msg) -> results or None
-  Combine execute_directly() and wait_for_results()
-  May raise BeeswaxException
-  """
-  history = execute_directly(user, query_msg, query_server)
-  result = wait_for_results(history, timeout_sec)
-  return result
-
-
-def get_query_state(query_history):
-  """
-  get_query_state(query_history) --> state enum
-
-  Find out the *server* state of this query, and translate it to the *client* state.
-  Expects to find the server_id from the ``query_history``.
-  Return None on error. (It catches all anticipated exceptions.)
-  """
-  # First, we need the server handle
-  ok, server_id = query_history.get_server_id()
-  if not server_id:
-    if not ok:
-      return None
-    return models.QueryHistory.STATE[query_history.last_state]
-
-  # Now check the server state
-  handle = QueryHandle(id=server_id, log_context=query_history.log_context)
-  try:
-    server_state = db_client(query_history.get_query_server()).get_state(handle)
-    return models.QueryHistory.STATE_MAP[server_state]
-  except QueryNotFoundException:
-    LOG.debug("Query id %s has expired" % (query_history.id,))
-    return models.QueryHistory.STATE.expired
-  except thrift.transport.TTransport.TTransportException, ex:
-    LOG.error("Failed to retrieve server state of submitted query id %s: %s" %
-              (query_history.id, ex))
-    return None
-
-
-def get_query_server(name='default', support_ddl=False):
-  if 'beeswax_server_host' in conf.QUERY_SERVERS['bind_to'] or 'beeswax_server_port' in conf.QUERY_SERVERS['bind_to']:
-    return {
-          'server_name': 'default',
-          'server_host': conf.BEESWAX_SERVER_HOST.get(),
-          'server_port': conf.BEESWAX_SERVER_PORT.get(),
-          'support_ddl': True,
-      }
-
-  servers = conf.QUERY_SERVERS
-
-  if support_ddl:
-    if not servers[name].SUPPORT_DDL.get():
-      for key in servers.keys():
-        if servers[key].SUPPORT_DDL.get():
-          name = key
-          break
-
-  config = servers[name]
-
-  query_server = {
-      'server_name': name,
-      'server_host': config.SERVER_HOST.get(),
-      'server_port': config.SERVER_PORT.get(),
-      'support_ddl': config.SUPPORT_DDL.get(),
-  }
-
-  return query_server
-
-#
-# Note that thrift_util does client connection caching for us.
-#
-def db_client(query_server):
-  """Get the Thrift client to talk to beeswax server"""
-
-  class UnicodeBeeswaxClient(object):
-    """Wrap the thrift client to take and return Unicode"""
-    def __init__(self, client):
-      self._client = client
-
-    def __getattr__(self, attr):
-      if attr in self.__dict__:
-        return self.__dict__[attr]
-      return getattr(self._client, attr)
-
-    def query(self, query):
-      _encode_struct_attr(query, 'query')
-      return self._client.query(query)
-
-    def explain(self, query):
-      _encode_struct_attr(query, 'query')
-      res = self._client.explain(query)
-      return _decode_struct_attr(res, 'textual')
-
-    def fetch(self, *args, **kwargs):
-      no_start_over_support = [ config_variable for config_variable in self.get_default_configuration(False)
-                                if config_variable.key == 'support_start_over' and config_variable.value == 'false' ]
-      if no_start_over_support:
-        copy = list(args)
-        copy[1] = False
-        args = copy
-
-      res = self._client.fetch(*args, **kwargs)
-      if res.ready:
-        res.columns = [ force_unicode(col, errors='replace') for col in res.columns ]
-        res.data = [ force_unicode(row, errors='replace') for row in res.data ]
-      return res
-
-    def dump_config(self):
-      res = self._client.dump_config()
-      return force_unicode(res, errors='replace')
-
-    def echo(self, msg):
-      return self._client.echo(smart_str(msg))
-
-    def get_log(self, *args, **kwargs):
-      res = self._client.get_log(*args, **kwargs)
-      return force_unicode(res, errors='replace')
-
-    def get_default_configuration(self, *args, **kwargs):
-      config_list = self._client.get_default_configuration(*args, **kwargs)
-      for config in config_list:
-        _decode_struct_attr(config, 'key')
-        _decode_struct_attr(config, 'value')
-        _decode_struct_attr(config, 'desc')
-      return config_list
-
-    def get_results_metadata(self, *args, **kwargs):
-      res = self._client.get_results_metadata(*args, **kwargs)
-      return _decode_struct_attr(res, 'table_dir')
-
-  cluster_conf = hadoop.cluster.get_cluster_conf_for_job_submission()
-  use_sasl = cluster_conf is not None and cluster_conf.SECURITY_ENABLED.get()
-
-  client = thrift_util.get_client(BeeswaxService.Client,
-                                  query_server['server_host'],
-                                  query_server['server_port'],
-                                  service_name=query_server['server_name'],
-                                  kerberos_principal="hue",
-                                  use_sasl=use_sasl,
-                                  timeout_seconds=conf.BEESWAX_SERVER_CONN_TIMEOUT.get())
-  return UnicodeBeeswaxClient(client)
-
-
-def meta_client():
-  """Get the Thrift client to talk to the metastore"""
-
-  class UnicodeMetastoreClient(object):
-    """Wrap the thrift client to take and return Unicode."""
-    def __init__(self, client):
-      self._client = client
-
-    def __getattr__(self, attr):
-      if attr in self.__dict__:
-        return self.__dict__[attr]
-      return getattr(self._client, attr)
-
-    def _encode_storage_descriptor(self, sd):
-      _encode_struct_attr(sd, 'location')
-      for col in sd.cols:
-        _encode_struct_attr(col, 'comment')
-      self._encode_map(sd.parameters)
-
-    def _decode_storage_descriptor(self, sd):
-      _decode_struct_attr(sd, 'location')
-      for col in sd.cols:
-        _decode_struct_attr(col, 'comment')
-      self._decode_map(sd.parameters)
-
-    def _encode_map(self, mapp):
-      for key, value in mapp.iteritems():
-        mapp[key] = smart_str(value, strings_only=True)
-
-    def _decode_map(self, mapp):
-      for key, value in mapp.iteritems():
-        mapp[key] = force_unicode(value, strings_only=True, errors='replace')
-
-    def create_database(self, name, description):
-      description = smart_str(description)
-      return self._client.create_database(name, description)
-
-    def get_database(self, *args, **kwargs):
-      db = self._client.get_database(*args, **kwargs)
-      return _decode_struct_attr(db, 'description')
-
-    def get_fields(self, *args, **kwargs):
-      res = self._client.get_fields(*args, **kwargs)
-      for fschema in res:
-        _decode_struct_attr(fschema, 'comment')
-      return res
-
-    def get_table(self, *args, **kwargs):
-      res = self._client.get_table(*args, **kwargs)
-      self._decode_storage_descriptor(res.sd)
-      self._decode_map(res.parameters)
-      return res
-
-    def alter_table(self, dbname, tbl_name, new_tbl):
-      self._encode_storage_descriptor(new_tbl.sd)
-      self._encode_map(new_tbl.parameters)
-      return self._client.alter_table(dbname, tbl_name, new_tbl)
-
-    def _encode_partition(self, part):
-      self._encode_storage_descriptor(part.sd)
-      self._encode_map(part.parameters)
-      return part
-
-    def _decode_partition(self, part):
-      self._decode_storage_descriptor(part.sd)
-      self._decode_map(part.parameters)
-      return part
-
-    def add_partition(self, new_part):
-      self._encode_partition(new_part)
-      part = self._client.add_partition(new_part)
-      return self._decode_partition(part)
-
-    def get_partition(self, *args, **kwargs):
-      part = self._client.get_partition(*args, **kwargs)
-      return self._decode_partition(part)
-
-    def get_partitions(self, *args, **kwargs):
-      part_list = self._client.get_partitions(*args, **kwargs)
-      for part in part_list:
-        self._decode_partition(part)
-      return part_list
-
-    def alter_partition(self, db_name, tbl_name, new_part):
-      self._encode_partition(new_part)
-      return self._client.alter_partition(db_name, tbl_name, new_part)
-
-  _, host, port = hive_site.get_metastore()
-  client = thrift_util.get_client(ThriftHiveMetastore.Client,
-                                  host,
-                                  port,
-                                  service_name="Hive Metastore Server",
-                                  timeout_seconds=conf.METASTORE_CONN_TIMEOUT.get())
-  return UnicodeMetastoreClient(client)
-
-
-def _decode_struct_attr(struct, attr):
-  try:
-    val = getattr(struct, attr)
-  except AttributeError:
-    return struct
-  unival = force_unicode(val, strings_only=True, errors='replace')
-  setattr(struct, attr, unival)
-  return struct
-
-def _encode_struct_attr(struct, attr):
-  try:
-    unival = getattr(struct, attr)
-  except AttributeError:
-    return struct
-  val = smart_str(unival, strings_only=True)
-  setattr(struct, attr, val)
-  return struct

+ 78 - 12
apps/beeswax/src/beeswax/design.py

@@ -20,19 +20,35 @@ The HQLdesign class can (de)serialize a design to/from a QueryDict.
 """
 
 import logging
+import re
 import simplejson
 
 import django.http
 from django import forms
 
 from desktop.lib.django_forms import BaseSimpleFormSet, MultiForm
+from desktop.lib.django_mako import render_to_string
 
-import beeswax.forms
 
 LOG = logging.getLogger(__name__)
 
 SERIALIZATION_VERSION = '0.4.0'
 
+
+def hql_query(hql):
+  data_dict = simplejson.loads('{"query": {"email_notify": null, "query": null, "type": null, "is_parameterized": null}, '
+                               '"functions": [], "VERSION": "0.4.0", "file_resources": [], "settings": []}')
+  if not (isinstance(hql, str) or isinstance(hql, unicode)):
+    raise Exception('Requires a SQL text query of type <str>, <unicode> and not %s' % type(hql))
+
+  data_dict['query']['query'] = _strip_trailing_semicolon(hql)
+  hql_design = HQLdesign()
+  hql_design._data_dict = data_dict
+
+  return hql_design
+
+
+
 class HQLdesign(object):
   """
   Represents an HQL design, with methods to perform (de)serialization.
@@ -41,19 +57,20 @@ class HQLdesign(object):
   want to use "$" natively, but we leave that as an advanced
   option to turn off.
   """
-  _QUERY_ATTRS = [ 'query', 'type', "is_parameterized", 'email_notify' ]
+  _QUERY_ATTRS = [ 'query', 'type', 'is_parameterized', 'email_notify' ]
   _SETTINGS_ATTRS = [ 'key', 'value' ]
   _FILE_RES_ATTRS = [ 'type', 'path' ]
   _FUNCTIONS_ATTRS = [ 'name', 'class_name' ]
 
-  def __init__(self, form):
-    """Initialize the design from form data. The form may be invalid."""
-    assert isinstance(form, MultiForm)
-    self._data_dict = dict(
-        query = normalize_form_dict(form.query, HQLdesign._QUERY_ATTRS),
-        settings = normalize_formset_dict(form.settings, HQLdesign._SETTINGS_ATTRS),
-        file_resources = normalize_formset_dict(form.file_resources, HQLdesign._FILE_RES_ATTRS),
-        functions = normalize_formset_dict(form.functions, HQLdesign._FUNCTIONS_ATTRS))
+  def __init__(self, form=None):
+    """Initialize the design from a valid form data."""
+    if form is not None:
+      assert isinstance(form, MultiForm)
+      self._data_dict = dict(
+          query = normalize_form_dict(form.query, HQLdesign._QUERY_ATTRS),
+          settings = normalize_formset_dict(form.settings, HQLdesign._SETTINGS_ATTRS),
+          file_resources = normalize_formset_dict(form.file_resources, HQLdesign._FILE_RES_ATTRS),
+          functions = normalize_formset_dict(form.functions, HQLdesign._FUNCTIONS_ATTRS))
 
   def dumps(self):
     """Returns the serialized form of the design in a string"""
@@ -61,11 +78,46 @@ class HQLdesign(object):
     dic['VERSION'] = SERIALIZATION_VERSION
     return simplejson.dumps(dic)
 
+  @property
+  def hql_query(self):
+    return self._data_dict['query']['query']
+
+  @property
+  def query(self):
+    return self._data_dict['query'].copy()
+
+  @property
+  def settings(self):
+    return list(self._data_dict['settings'])
+
+  @property
+  def file_resources(self):
+    return list(self._data_dict['file_resources'])
+
+  @property
+  def functions(self):
+    return list(self._data_dict['functions'])
+
+  def get_configuration(self):
+    configuration = []
+
+    for f in self.settings:
+      configuration.append(render_to_string("hql_set.mako", f))
+
+    for f in self.file_resources:
+      configuration.append(render_to_string("hql_resource.mako", dict(type=f['type'], path=f['path'])))
+
+    for f in self.functions:
+      configuration.append(render_to_string("hql_function.mako", f))
+
+    return configuration
+
   def get_query_dict(self):
     """get_query_dict() -> QueryDict"""
     # We construct the mform to use its structure and prefix. We don't actually bind
     # data to the forms.
-    mform = beeswax.forms.query_form()
+    from beeswax.forms import QueryForm
+    mform = QueryForm()
     mform.bind()
 
     res = django.http.QueryDict('', mutable=True)
@@ -105,7 +157,7 @@ def normalize_form_dict(form, attr_list):
   assert isinstance(form, forms.Form)
   res = { }
   for attr in attr_list:
-    res[attr] = form.data.get(form.add_prefix(attr))
+    res[attr] = form.cleaned_data.get(attr)
   return res
 
 
@@ -148,3 +200,17 @@ def denormalize_formset_dict(data_dict_list, formset, attr_list):
 
   res[formset.management_form.add_prefix('next_form_id')] = str(len(data_dict_list))
   return res
+
+  def __str__(self):
+    return '%s: %s' % (self.__class__, self.query)
+
+
+_SEMICOLON_WHITESPACE = re.compile(";\s*$")
+
+def _strip_trailing_semicolon(query):
+  """As a convenience, we remove trailing semicolons from queries."""
+  s = _SEMICOLON_WHITESPACE.split(query, 2)
+  if len(s) > 1:
+    assert len(s) == 2
+    assert s[1] == ''
+  return s[0]

+ 40 - 20
apps/beeswax/src/beeswax/forms.py

@@ -22,13 +22,18 @@ import hive_metastore
 
 from desktop.lib.django_forms import simple_formset_factory, DependencyAwareForm
 from desktop.lib.django_forms import ChoiceOrOtherField, MultiForm, SubmitButton
-from beeswax import db_utils, common, conf, models
+
 from filebrowser.forms import PathField
 
+from beeswax import common, conf, models
+from beeswax.design import _strip_trailing_semicolon
+import hadoop
+from beeswax.server.dbms import NoSuchObjectException
+
 
-def query_form():
-  """Generates a multi form object for queries."""
-  return MultiForm(
+class QueryForm(MultiForm):
+  def __init__(self):
+    super(QueryForm, self).__init__(
       query=HQLForm,
       settings=SettingFormSet,
       file_resources=FileResourceFormSet,
@@ -101,18 +106,23 @@ class SaveResultsForm(DependencyAwareForm):
                                   required=False,
                                   help_text=_t("Name of the new table"))
   target_dir = PathField(label=_t("Results Location"),
-                        required=False,
-                        help_text=_t("Empty directory in HDFS to put the results"))
+                         required=False,
+                         help_text=_t("Empty directory in HDFS to put the results"))
   dependencies = [
     ('save_target', SAVE_TYPE_TBL, 'target_table'),
     ('save_target', SAVE_TYPE_DIR, 'target_dir'),
   ]
 
+  def __init__(self, *args, **kwargs):
+    self.db = kwargs.pop('db', None)
+    super(SaveResultsForm, self).__init__(*args, **kwargs)
+
   def clean_target_table(self):
     tbl = self.cleaned_data.get('target_table')
     if tbl:
       try:
-        db_utils.meta_client().get_table("default", tbl)
+        if self.db is not None:
+          self.db.get_table("default", tbl)
         raise forms.ValidationError(_('Table already exists'))
       except hive_metastore.ttypes.NoSuchObjectException:
         pass
@@ -126,6 +136,9 @@ class HQLForm(forms.Form):
   is_parameterized = forms.BooleanField(required=False, initial=True)
   email_notify = forms.BooleanField(required=False, initial=False)
 
+  def clean_query(self):
+    return _strip_trailing_semicolon(self.cleaned_data['query'])
+
 
 class FunctionForm(forms.Form):
   name = forms.CharField(required=True)
@@ -145,10 +158,13 @@ class FileResourceForm(forms.Form):
        "files to be copied and made locally available duirng MAP/TRANSFORM. " +
        "Paths are on HDFS.")
   )
-  # TODO(philip): Could upload files here, too.  Or merely link
-  # to upload utility?
+
   path = forms.CharField(required=True, help_text=_t("Path to file on HDFS."))
 
+  def clean_path(self):
+    return hadoop.conf.HDFS_CLUSTERS['default'].FS_DEFAULTFS.get() + self.cleaned_data['path']
+
+
 FileResourceFormSet = simple_formset_factory(FileResourceForm)
 
 
@@ -234,20 +250,21 @@ class CreateTableForm(DependencyAwareForm):
     return _clean_terminator(self.cleaned_data.get('map_key_terminator'))
 
   def clean_name(self):
-    return _clean_tablename(self.cleaned_data['name'])
+    return _clean_tablename(self.db, self.cleaned_data['name'])
 
 
-def _clean_tablename(name):
+def _clean_tablename(db, name):
   try:
-    db_utils.meta_client().get_table("default", name)
-    raise forms.ValidationError(_('Table "%(name)s" already exists') % {'name': name})
-  except hive_metastore.ttypes.NoSuchObjectException:
+    table = db.get_table("default", name)
+    if table.name:
+      raise forms.ValidationError(_('Table "%(name)s" already exists') % {'name': name})
+  except (hive_metastore.ttypes.NoSuchObjectException, NoSuchObjectException):
     return name
 
 
 def _clean_terminator(val):
   if val is not None and len(val.decode('string_escape')) != 1:
-      raise forms.ValidationError(_('Terminator must be exactly one character.'))
+    raise forms.ValidationError(_('Terminator must be exactly one character.'))
   return val
 
 
@@ -263,8 +280,12 @@ class CreateByImportFileForm(forms.Form):
                           label=_t("Import data from file"),
                           help_text=_t("Automatically load this file into the table after creation."))
 
+  def __init__(self, *args, **kwargs):
+    self.db = kwargs.pop('db', None)
+    super(CreateByImportFileForm, self).__init__(*args, **kwargs)
+
   def clean_name(self):
-    return _clean_tablename(self.cleaned_data['name'])
+    return _clean_tablename(self.db, self.cleaned_data['name'])
 
 
 class CreateByImportDelimForm(forms.Form):
@@ -334,17 +355,16 @@ PartitionTypeFormSet = simple_formset_factory(PartitionTypeForm, add_label=_t("a
 class LoadDataForm(forms.Form):
   """Form used for loading data into an existing table."""
   path = PathField(label=_t("Path"))
-  overwrite = forms.BooleanField(required=False, initial=False,
-    label=_t("Overwrite?"))
+  overwrite = forms.BooleanField(required=False, initial=False, label=_t("Overwrite?"))
 
   def __init__(self, table_obj, *args, **kwargs):
     """
     @param table_obj is a hive_metastore.thrift Table object,
-    used to add fields corresopnding to partition keys.
+    used to add fields corresponding to partition keys.
     """
     super(LoadDataForm, self).__init__(*args, **kwargs)
     self.partition_columns = dict()
-    for i, column in enumerate(table_obj.partitionKeys):
+    for i, column in enumerate(table_obj.partition_keys):
       # We give these numeric names because column names
       # may be unpleasantly arbitrary.
       name = "partition_%d" % i

+ 13 - 20
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -39,19 +39,22 @@ import simplejson
 
 from django.core.management.base import NoArgsCommand
 from django.contrib.auth.models import User
+from django.utils.translation import ugettext as _
 
-import beeswax.conf
-from beeswax import db_utils, models
-from beeswaxd import BeeswaxService
+import hive_metastore.ttypes
 from beeswaxd.ttypes import BeeswaxException
 
-import hive_metastore.ttypes
+import beeswax.conf
+
+from beeswax import models
+from beeswax.design import hql_query
+from beeswax.server import dbms
 
-from django.utils.translation import ugettext as _
 
 LOG = logging.getLogger(__name__)
 DEFAULT_INSTALL_USER = 'hue'
 
+
 def get_install_user():
   """Use the DEFAULT_INSTALL_USER if it exists, else try the current user"""
   try:
@@ -145,16 +148,6 @@ class Command(NoArgsCommand):
     LOG.info('Successfully installed all sample queries')
 
 
-def _make_query_msg(hql):
-  """
-  Make a thrift Query object.
-  Need to run query as a valid hadoop user. Use hue:supergroup
-  """
-  query_msg = BeeswaxService.Query(query=hql, configuration=[])
-  query_msg.hadoop_user = get_install_user()
-  return query_msg
-
-
 class SampleTable(object):
   """
   Represents a table loaded from the tables.json file
@@ -184,14 +177,14 @@ class SampleTable(object):
     LOG.info('Creating table "%s"' % (self.name,))
     try:
       # Already exists?
-      tables = db_utils.meta_client().get_table("default", self.name)
+      dbms.get(django_user).get_table('default', self.name)
       msg = _('Table "%(table)s" already exists.') % {'table': self.name}
       LOG.error(msg)
       raise InstallException(msg)
     except hive_metastore.ttypes.NoSuchObjectException:
-      query_msg = _make_query_msg(self.hql)
+      query = hql_query(self.hql)
       try:
-        results = db_utils.execute_and_wait(django_user, query_msg)
+        results = dbms.get(django_user).execute_and_wait(query)
         if not results:
           msg = _('Error creating table %(table)s: Operation timeout.') % {'table': self.name}
           LOG.error(msg)
@@ -213,9 +206,9 @@ class SampleTable(object):
 
     LOG.info('Loading data into table "%s"' % (self.name,))
     hql = LOAD_HQL % dict(tablename=self.name, filename=self._contents_file)
-    query_msg = _make_query_msg(hql)
+    query = hql_query(hql)
     try:
-      results = db_utils.execute_and_wait(django_user, query_msg)
+      results = dbms.get(django_user).execute_and_wait(query)
       if not results:
         msg = _('Error loading table %(table)s: Operation timeout.') % {'table': self.name}
         LOG.error(msg)

+ 139 - 0
apps/beeswax/src/beeswax/migrations/0004_auto__add_session__add_field_queryhistory_server_type__add_field_query.py

@@ -0,0 +1,139 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+
+        # Adding model 'Session'
+        db.create_table('beeswax_session', (
+            ('last_used', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, db_index=True, blank=True)),
+            ('status_code', self.gf('django.db.models.fields.PositiveSmallIntegerField')()),
+            ('server_protocol_version', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
+            ('secret', self.gf('django.db.models.fields.TextField')(max_length='100')),
+            ('owner', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
+            ('guid', self.gf('django.db.models.fields.TextField')(max_length='100')),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+        ))
+        db.send_create_signal('beeswax', ['Session'])
+
+        # Adding field 'QueryHistory.server_type'
+        db.add_column('beeswax_queryhistory', 'server_type', self.gf('django.db.models.fields.CharField')(default='BEESWAX', max_length=128), keep_default=False)
+
+        # Adding field 'QueryHistory.server_guid'
+        db.add_column('beeswax_queryhistory', 'server_guid', self.gf('django.db.models.fields.CharField')(default=None, max_length=1024, null=True), keep_default=False)
+
+        # Adding field 'QueryHistory.operation_type'
+        db.add_column('beeswax_queryhistory', 'operation_type', self.gf('django.db.models.fields.SmallIntegerField')(null=True), keep_default=False)
+
+        # Adding field 'QueryHistory.modified_row_count'
+        db.add_column('beeswax_queryhistory', 'modified_row_count', self.gf('django.db.models.fields.FloatField')(null=True), keep_default=False)
+
+
+    def backwards(self, orm):
+
+        # Deleting model 'Session'
+        db.delete_table('beeswax_session')
+
+        # Deleting field 'QueryHistory.server_type'
+        db.delete_column('beeswax_queryhistory', 'server_type')
+
+        # Deleting field 'QueryHistory.server_guid'
+        db.delete_column('beeswax_queryhistory', 'server_guid')
+
+        # Deleting field 'QueryHistory.operation_type'
+        db.delete_column('beeswax_queryhistory', 'operation_type')
+
+        # Deleting field 'QueryHistory.modified_row_count'
+        db.delete_column('beeswax_queryhistory', 'modified_row_count')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'beeswax.metainstall': {
+            'Meta': {'object_name': 'MetaInstall'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'installed_example': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'})
+        },
+        'beeswax.queryhistory': {
+            'Meta': {'object_name': 'QueryHistory'},
+            'design': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['beeswax.SavedQuery']", 'null': 'True'}),
+            'has_results': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_state': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+            'log_context': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True'}),
+            'modified_row_count': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
+            'notify': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'operation_type': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True'}),
+            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+            'query': ('django.db.models.fields.TextField', [], {}),
+            'server_guid': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '1024', 'null': 'True'}),
+            'server_host': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128'}),
+            'server_id': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True'}),
+            'server_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128'}),
+            'server_port': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+            'server_type': ('django.db.models.fields.CharField', [], {'default': "'BEESWAX'", 'max_length': '128'}),
+            'submission_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
+        },
+        'beeswax.savedquery': {
+            'Meta': {'object_name': 'SavedQuery'},
+            'data': ('django.db.models.fields.TextField', [], {'max_length': '65536'}),
+            'desc': ('django.db.models.fields.TextField', [], {'max_length': '1024'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_auto': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
+            'mtime': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+            'type': ('django.db.models.fields.IntegerField', [], {})
+        },
+        'beeswax.session': {
+            'Meta': {'object_name': 'Session'},
+            'guid': ('django.db.models.fields.TextField', [], {'max_length': "'100'"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_used': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+            'secret': ('django.db.models.fields.TextField', [], {'max_length': "'100'"}),
+            'server_protocol_version': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+            'status_code': ('django.db.models.fields.PositiveSmallIntegerField', [], {})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        }
+    }
+
+    complete_apps = ['beeswax']

+ 248 - 59
apps/beeswax/src/beeswax/models.py

@@ -16,73 +16,157 @@
 # limitations under the License.
 
 import copy
-import logging
+import base64
 import datetime
+import logging
 import traceback
-from enum import Enum
 
 from django.db import models
 from django.contrib.auth.models import User
+from django.utils.translation import ugettext as _, ugettext_lazy as _t
+
+from enum import Enum
 
 from desktop.lib.exceptions import PopupException
-from beeswaxd.ttypes import QueryState
 
-from django.utils.translation import ugettext as _
+from beeswax.conf import SERVER_INTERFACE
+from beeswaxd.ttypes import QueryHandle as BeeswaxdQueryHandle, QueryState
+from cli_service.ttypes import TSessionHandle, THandleIdentifier,\
+  TOperationState, TOperationHandle, TOperationType
+
 
 LOG = logging.getLogger(__name__)
 
-QUERY_SUBMISSION_TIMEOUT = datetime.timedelta(0, 60 * 60)               # 1 hr
+QUERY_SUBMISSION_TIMEOUT = datetime.timedelta(0, 60 * 60)               # 1 hour
+
+# Constants for DB fields, hue ini
+BEESWAX = 'beeswax'
+HIVE_SERVER2 = 'hiveserver2'
+
 
 class QueryHistory(models.Model):
   """
   Holds metadata about all queries that have been executed.
   """
   STATE = Enum('submitted', 'running', 'available', 'failed', 'expired')
-
-  # Map from (thrift) server state
-  STATE_MAP = {
-    QueryState.CREATED          : STATE.submitted,
-    QueryState.INITIALIZED      : STATE.submitted,
-    QueryState.COMPILED         : STATE.running,
-    QueryState.RUNNING          : STATE.running,
-    QueryState.FINISHED         : STATE.available,
-    QueryState.EXCEPTION        : STATE.failed
-  }
+  SERVER_TYPE = ((BEESWAX, 'Beeswax'), (HIVE_SERVER2, 'Hive Server 2'))
 
   owner = models.ForeignKey(User, db_index=True)
   query = models.TextField()
+
   last_state = models.IntegerField(db_index=True)
-  # If true, this query will eventually return tabular results.
-  has_results = models.BooleanField(default=False)
+  has_results = models.BooleanField(default=False)          # If true, this query will eventually return tabular results.
   submission_date = models.DateTimeField(auto_now_add=True)
-  # Only query in the "submitted" state is allowed to have no server_id
-  server_id = models.CharField(max_length=1024, null=True)
+  server_id = models.CharField(max_length=1024, null=True)  # Aka secret, only query in the "submitted" state is allowed to have no server_id
+  server_guid = models.CharField(max_length=1024, null=True, default=None)
+  operation_type = models.SmallIntegerField(null=True)
+  modified_row_count = models.FloatField(null=True)
   log_context = models.CharField(max_length=1024, null=True)
+
   server_host = models.CharField(max_length=128, help_text=_('Host of the query server.'), default='')
   server_port = models.SmallIntegerField(help_text=_('Port of the query server.'), default=0)
   server_name = models.CharField(max_length=128, help_text=_('Name of the query server.'), default='')
-  # Some queries (like read/drop table) don't have a design
-  design = models.ForeignKey('SavedQuery', to_field='id', null=True)
-  # Notify on completion
-  notify = models.BooleanField(default=False)
+  server_type = models.CharField(max_length=128, help_text=_('Type of the query server.'), default=BEESWAX, choices=SERVER_TYPE)
+
+  design = models.ForeignKey('SavedQuery', to_field='id', null=True) # Some queries (like read/drop table) don't have a design
+  notify = models.BooleanField(default=False)                        # Notify on completion
 
   class Meta:
     ordering = ['-submission_date']
 
+  @staticmethod
+  def build(*args, **kwargs):
+    if SERVER_INTERFACE.get() == HIVE_SERVER2:
+      return HiveServerQueryHistory(*args, **kwargs)
+    else:
+      return BeeswaxQueryHistory(*args, **kwargs)
+
+  def get_full_object(self):
+    if self.server_type == HiveServerQueryHistory.node_type:
+      return HiveServerQueryHistory.objects.get(id=self.id)
+    elif self.server_type == BeeswaxQueryHistory.node_type:
+      return BeeswaxQueryHistory.objects.get(id=self.id)
+    else:
+      raise Exception(_('Unknown QueryHistory type: %s. Was the attribute "server_type" specified?'), (self.server_type,))
+
+  @staticmethod
+  def get(id):
+    if QueryHistory.objects.filter(id=id, server_type=BEESWAX).exists():
+      return BeeswaxQueryHistory.objects.get(id=id)
+    else:
+      return HiveServerQueryHistory.objects.get(id=id)
+
+
+  def get_query_server(self):
+    return dict(zip(['server_name', 'server_host', 'server_port', 'server_type'],
+                    [self.server_name, self.server_host, self.server_port, self.server_type]))
+
+
+  def is_running(self):
+    return self.last_state in (QueryHistory.STATE.running.index, QueryHistory.STATE.submitted.index)
+
+  def is_success(self):
+    return self.last_state in (QueryHistory.STATE.available.index,)
+
+  def is_failure(self):
+    return self.last_state in (QueryHistory.STATE.expired.index, QueryHistory.STATE.failed.index)
+
+  def set_to_running(self):
+    self.last_state = QueryHistory.STATE.running.index
+
+  def set_to_failed(self):
+    self.last_state = QueryHistory.STATE.failed.index
+
+
+class HiveServerQueryHistory(QueryHistory):
+  # Map from (thrift) server state
+  STATE_MAP = {
+    TOperationState.INITIALIZED_STATE          : QueryHistory.STATE.submitted,
+    TOperationState.RUNNING_STATE         : QueryHistory.STATE.running,
+    TOperationState.FINISHED_STATE      : QueryHistory.STATE.available,
+    TOperationState.CANCELED_STATE          : QueryHistory.STATE.failed,
+    TOperationState.CLOSED_STATE         : QueryHistory.STATE.expired,
+    TOperationState.ERROR_STATE        : QueryHistory.STATE.failed,
+    TOperationState.UKNOWN_STATE        : QueryHistory.STATE.failed,
+  }
+
+  node_type = HIVE_SERVER2
+
+  class Meta:
+    proxy = True
+
+  def get_handle(self):
+    secret, guid = HiveServerQueryHandle.get_decoded(self.server_id, self.server_guid)
+
+    return HiveServerQueryHandle(secret=secret,
+                                 guid=guid,
+                                 has_result_set=self.has_results,
+                                 operation_type=self.operation_type,
+                                 modified_row_count=self.modified_row_count)
+
   def save_state(self, new_state):
-    """Set the last_state from an enum, and save"""
-    if self.last_state != new_state.index:
-      if new_state.index < self.last_state:
-        backtrace = ''.join(traceback.format_stack(limit=5))
-        LOG.error("Invalid query state transition: %s -> %s\n%s" % \
-                  (QueryHistory.STATE[self.last_state], new_state, backtrace))
-        return
-      self.last_state = new_state.index
-      self.save()
+    self.last_state = new_state.index
+
 
-  def get_server_id(self):
+class BeeswaxQueryHistory(QueryHistory):
+  # Map from (thrift) server state
+  STATE_MAP = {
+    QueryState.CREATED          : QueryHistory.STATE.submitted,
+    QueryState.INITIALIZED      : QueryHistory.STATE.submitted,
+    QueryState.COMPILED         : QueryHistory.STATE.running,
+    QueryState.RUNNING          : QueryHistory.STATE.running,
+    QueryState.FINISHED         : QueryHistory.STATE.available,
+    QueryState.EXCEPTION        : QueryHistory.STATE.failed
+  }
+
+  node_type = BEESWAX
+
+  class Meta:
+    proxy = True
+
+  def get_handle(self):
     """
-    get_server_id() ->  (True/False, server-side query id)
+    get_server_id() ->  (server-side query id)
 
     The boolean indicates success/failure. The server_id follows, and may be None.
     Note that the server_id can legally be None when the query is just submitted.
@@ -91,33 +175,36 @@ class QueryHistory(models.Model):
     Does not issue RPC.
     """
     if self.server_id:
-      return (True, self.server_id)
-
-    # Query being submitted have no server_id?
-    if self.last_state == QueryHistory.STATE.submitted.index:
-      # (1) Really? Check the submission date.
-      #     This is possibly due to the server dying when compiling the query
-      if self.submission_date.now() - self.submission_date > QUERY_SUBMISSION_TIMEOUT:
-        LOG.error("Query submission taking too long. Expiring id %s: [%s]..." %
-                  (self.id, self.query[:40]))
-        self.save_state(QueryHistory.STATE.expired)
-        return (False, None)
-      else:
-        # (2) It's not an error. Return the current state
-        LOG.debug("Query %s (submitted) has no server id yet" % (self.id,))
-        return (True, None)
+      return BeeswaxQueryHandle(secret=self.server_id, has_result_set=self.has_results, log_context=self.log_context)
     else:
-      # (3) It has no server_id for no good reason. A case (1) will become this
-      #     after we expire it. Note that we'll never be able to recover this
-      #     query.
-      LOG.error("Query %s (%s) has no server id [%s]..." %
-                (self.id, QueryHistory.STATE[self.last_state], self.query[:40]))
-      self.save_state(QueryHistory.STATE.expired)
-      return (False, None)
+      # Query being submitted have no server_id?
+      if self.last_state == QueryHistory.STATE.submitted.index:
+        # (1) Really? Check the submission date.
+        #     This is possibly due to the server dying when compiling the query
+        if self.submission_date.now() - self.submission_date > QUERY_SUBMISSION_TIMEOUT:
+          LOG.error("Query submission taking too long. Expiring id %s: [%s]..." % (self.id, self.query[:40]))
+          self.save_state(QueryHistory.STATE.expired)
+        else:
+          # (2) It's not an error. Return the current state
+          LOG.debug("Query %s (submitted) has no server id yet" % (self.id,))
+      else:
+        # (3) It has no server_id for no good reason. A case (1) will become this
+        #     after we expire it. Note that we'll never be able to recover this
+        #     query.
+        LOG.error("Query %s (%s) has no server id [%s]..." %
+                  (self.id, QueryHistory.STATE[self.last_state], self.query[:40]))
+        self.save_state(QueryHistory.STATE.expired)
+      return None
 
-  def get_query_server(self):
-    return dict(zip(['server_name', 'server_host', 'server_port'],
-                    [self.server_name, self.server_host, self.server_port]))
+  def save_state(self, new_state):
+    """Set the last_state from an enum, and save"""
+    if self.last_state != new_state.index:
+      if new_state.index < self.last_state:
+        backtrace = ''.join(traceback.format_stack(limit=5))
+        LOG.error("Invalid query state transition: %s -> %s\n%s" % (QueryHistory.STATE[self.last_state], new_state, backtrace))
+        return
+      self.last_state = new_state.index
+      self.save()
 
 
 class SavedQuery(models.Model):
@@ -182,6 +269,108 @@ class SavedQuery(models.Model):
 
     return design
 
+  def __str__(self):
+    return '%s %s' % (self.name, self.owner)
+
+
+class SessionManager(models.Manager):
+  def get_session(self, user):
+    try:
+      return self.filter(owner=user).latest("last_used")
+    except Session.DoesNotExist:
+      pass
+
+
+class Session(models.Model):
+  owner = models.ForeignKey(User, db_index=True)
+  status_code = models.PositiveSmallIntegerField()
+  secret = models.TextField(max_length='100')
+  guid = models.TextField(max_length='100')
+  server_protocol_version = models.SmallIntegerField(default=0)
+  last_used = models.DateTimeField(auto_now=True, db_index=True, verbose_name=_t('Last used'))
+
+  objects = SessionManager()
+
+  def get_handle(self):
+    secret, guid = HiveServerQueryHandle.get_decoded(secret=self.secret, guid=self.guid)
+
+    handle_id = THandleIdentifier(secret=secret, guid=guid)
+    return TSessionHandle(sessionId=handle_id)
+
+  def __str__(self):
+    return '%s %s' % (self.owner, self.last_used)
+
+
+
+
+class QueryHandle(object):
+  def __init__(self, secret, guid=None, operation_type=None, has_result_set=None, modified_row_count=None, log_context=None):
+    self.secret = secret
+    self.guid = guid
+    self.operation_type = operation_type
+    self.has_result_set = has_result_set
+    self.modified_row_count = modified_row_count
+    self.log_context = log_context
+
+  def is_valid(self):
+    return all([self.get()])
+
+  def __str__(self):
+    return '%s %s' % (self.secret, self.guid)
+
+
+
+class HiveServerQueryHandle(QueryHandle):
+  """
+  QueryHandle for Hive Server 2.
+
+  Store THandleIdentifier base64 encoded in order to be unicode compatible with Django.
+  """
+  def __init__(self, **kwargs):
+    super(HiveServerQueryHandle, self).__init__(**kwargs)
+    self.secret, self.guid = self.get_encoded()
+
+  def get(self):
+    return self.secret, self.guid
+
+  def get_rpc_handle(self):
+    secret, guid = self.get_decoded(self.secret, self.guid)
+
+    operation = getattr(TOperationType, TOperationType._NAMES_TO_VALUES.get(self.operation_type, 'EXECUTE_STATEMENT'))
+    return TOperationHandle(operationId=THandleIdentifier(guid=guid, secret=secret),
+                            operationType=operation,
+                            hasResultSet=self.has_result_set,
+                            modifiedRowCount=self.modified_row_count)
+
+  # TODO hide
+  @classmethod
+  def get_decoded(cls, secret, guid):
+    return base64.decodestring(secret), base64.decodestring(guid)
+
+  # TODO hide
+  def get_encoded(self):
+    return base64.encodestring(self.secret), base64.encodestring(self.guid)
+
+
+class BeeswaxQueryHandle(QueryHandle):
+  """
+  QueryHandle for Beeswax.
+  """
+  def __init__(self, secret, has_result_set, log_context):
+    super(BeeswaxQueryHandle, self).__init__(secret=secret,
+                                             has_result_set=has_result_set,
+                                             log_context=log_context)
+
+  def get(self):
+    return self.secret, None
+
+  def get_rpc_handle(self):
+    return BeeswaxdQueryHandle(id=self.secret, log_context=self.log_context)
+
+  # TODO remove
+  def get_encoded(self):
+    return self.get(), None
+
 
 class MetaInstall(models.Model):
   """

+ 0 - 0
apps/beeswax/src/beeswax/server/__init__.py


+ 386 - 0
apps/beeswax/src/beeswax/server/beeswax_lib.py

@@ -0,0 +1,386 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+import thrift
+
+from django.utils.encoding import smart_str, force_unicode
+
+import hadoop.cluster
+
+from desktop.lib import thrift_util
+from hive_metastore import ThriftHiveMetastore
+
+from beeswaxd import BeeswaxService
+from beeswaxd.ttypes import QueryNotFoundException
+
+from beeswax import conf
+from beeswax import models
+from beeswax import hive_site
+from beeswax.models import BeeswaxQueryHandle
+from beeswax.server.dbms import Table, DataTable
+
+
+LOG = logging.getLogger(__name__)
+
+
+
+class BeeswaxTable(Table):
+
+  def __init__(self, table_obj):
+    self.table_obj = table_obj
+
+  @property
+  def name(self):
+    return self.table_obj.tableName
+
+  @property
+  def is_view(self):
+    return self.table_obj.tableType == 'VIRTUAL_VIEW'
+
+  @property
+  def partition_keys(self):
+    return self.table_obj.partitionKeys
+
+  @property
+  def path_location(self):
+    return self.table_obj.sd.location
+
+  @property
+  def parameters(self):
+    return self.table_obj.parameters
+
+  @property
+  def cols(self):
+    return self.table_obj.sd.cols
+
+  @property
+  def comment(self):
+    return self.table_obj.parameters.get('comment')
+
+
+class BeeswaxDataTable(DataTable):
+  def __init__(self, results):
+    self.results = results
+    self.has_more = results.has_more
+    self.startRowOffset = results.start_row
+    self.columns = results.columns
+
+  @property
+  def ready(self):
+    return self.results.ready
+
+  def cols(self):
+    return self.results.columns
+
+  def rows(self):
+    """
+    Results come back tab-delimited, and this splits
+    them back up into reasonable things.
+    """
+    def parse_result_row(row):
+      return row.split("\t")
+
+    for row in self.results.data:
+      yield parse_result_row(row)
+
+
+
+class BeeswaxClient:
+
+  def __init__(self, query_server, user):
+    self.user = user
+    self.query_server = query_server
+    self.db_client = self.db_client(query_server)
+    self.meta_client = self.meta_client()
+
+  def make_query(self, hql_query):
+    thrift_query = BeeswaxService.Query(query=hql_query.query['query'], configuration=hql_query.get_configuration())
+    thrift_query.hadoop_user = self.user.username
+    return thrift_query
+
+
+  def get_tables(self, *args, **kwargs):
+    return self.meta_client.get_tables(*args, **kwargs)
+
+
+  def get_table(self, *args, **kwargs):
+    table = self.meta_client.get_table(*args, **kwargs)
+    return BeeswaxTable(table)
+
+
+  def query(self, query):
+    thrift_query = self.make_query(query)
+    handle = self.db_client.query(thrift_query)
+    return BeeswaxQueryHandle(secret=handle.id, has_result_set=True, log_context=handle.log_context)
+
+
+  def fetch(self, handle, start_over=True, rows=-1):
+    if rows is None:
+      rows = -1
+
+    handle = handle.get_rpc_handle()
+    results = self.db_client.fetch(handle, start_over, rows)
+
+    if results.ready:
+      return BeeswaxDataTable(results)
+
+
+  def get_log(self, handle):
+    return self.db_client.get_log(handle.log_context)
+
+
+  def get_state(self, handle):
+    return self.db_client.get_state(handle)
+
+
+  def get_results_metadata(self, handle):
+    handle = handle.get_rpc_handle()
+    return self.db_client.get_results_metadata(handle)
+
+
+  def close(self, handle):
+    handle = handle.get_rpc_handle()
+
+    self.db_client.close(handle)
+    self.db_client.clean(handle.log_context)
+
+
+  def get_partitions(self, db_name, tbl_name, max_parts):
+    if max_parts is None:
+      max_parts = -1
+    return self.meta_client.get_partitions(db_name, tbl_name, max_parts)
+
+
+  def explain(self, statement):
+    thrift_query = self.make_query(statement)
+    return self.db_client.explain(thrift_query)
+
+
+  def echo(self, text):
+    return self.db_client.echo(text)
+
+
+  def getStatus(self):
+    return self.meta_client.getStatus()
+
+
+  def get_default_configuration(self, *args, **kwargs):
+    return self.db_client.get_default_configuration(*args, **kwargs)
+
+
+  def db_client(self, query_server):
+    """Get the Thrift client to talk to beeswax server"""
+
+    class UnicodeBeeswaxClient(object):
+      """Wrap the thrift client to take and return Unicode"""
+      def __init__(self, client):
+        self._client = client
+
+      def __getattr__(self, attr):
+        if attr in self.__dict__:
+          return self.__dict__[attr]
+        return getattr(self._client, attr)
+
+      def query(self, query):
+        _encode_struct_attr(query, 'query')
+        return self._client.query(query)
+
+      def explain(self, query):
+        _encode_struct_attr(query, 'query')
+        res = self._client.explain(query)
+        return _decode_struct_attr(res, 'textual')
+
+      def fetch(self, *args, **kwargs):
+        res = self._client.fetch(*args, **kwargs)
+        if res.ready:
+          res.columns = [ force_unicode(col, errors='replace') for col in res.columns ]
+          res.data = [ force_unicode(row, errors='replace') for row in res.data ]
+        return res
+
+      def get_state(self, handle):
+        """
+        get_query_state(query_history) --> state enum
+
+        Find out the *server* state of this query, and translate it to the *client* state.
+        Expects to find the server_id from the ``query_history``.
+        Return None on error. (It catches all anticipated exceptions.)
+        """
+        rpc_handle = handle.get_rpc_handle()
+
+        try:
+          rpc_state = self._client.get_state(rpc_handle)
+          return models.BeeswaxQueryHistory.STATE_MAP[rpc_state]
+        except QueryNotFoundException:
+          LOG.debug("Query id %s has expired" % (handle.secret,))
+          return models.QueryHistory.STATE.expired
+        except thrift.transport.TTransport.TTransportException, ex:
+          LOG.error("Failed to retrieve server state of submitted query id %s: %s" % (handle.secret, ex)) # queryhistory.id
+          return None
+
+
+      def dump_config(self):
+        res = self._client.dump_config()
+        return force_unicode(res, errors='replace')
+
+      def echo(self, msg):
+        return self._client.echo(smart_str(msg))
+
+      def get_log(self, *args, **kwargs):
+        res = self._client.get_log(*args, **kwargs)
+        return force_unicode(res, errors='replace')
+
+      def get_default_configuration(self, *args, **kwargs):
+        config_list = self._client.get_default_configuration(*args, **kwargs)
+        for config in config_list:
+          _decode_struct_attr(config, 'key')
+          _decode_struct_attr(config, 'value')
+          _decode_struct_attr(config, 'desc')
+        return config_list
+
+      def get_results_metadata(self, *args, **kwargs):
+        res = self._client.get_results_metadata(*args, **kwargs)
+        return _decode_struct_attr(res, 'table_dir')
+
+    cluster_conf = hadoop.cluster.get_cluster_conf_for_job_submission()
+    use_sasl = cluster_conf is not None and cluster_conf.SECURITY_ENABLED.get()
+
+    client = thrift_util.get_client(BeeswaxService.Client,
+                                    query_server['server_host'],
+                                    query_server['server_port'],
+                                    service_name=query_server['server_name'],
+                                    kerberos_principal="hue",
+                                    use_sasl=use_sasl,
+                                    timeout_seconds=conf.BEESWAX_SERVER_CONN_TIMEOUT.get())
+    return UnicodeBeeswaxClient(client)
+
+
+  def meta_client(self):
+    """Get the Thrift client to talk to the metastore"""
+
+    class UnicodeMetastoreClient(object):
+      """Wrap the thrift client to take and return Unicode."""
+      def __init__(self, client):
+        self._client = client
+
+      def __getattr__(self, attr):
+        if attr in self.__dict__:
+          return self.__dict__[attr]
+        return getattr(self._client, attr)
+
+      def _encode_storage_descriptor(self, sd):
+        _encode_struct_attr(sd, 'location')
+        for col in sd.cols:
+          _encode_struct_attr(col, 'comment')
+        self._encode_map(sd.parameters)
+
+      def _decode_storage_descriptor(self, sd):
+        _decode_struct_attr(sd, 'location')
+        for col in sd.cols:
+          _decode_struct_attr(col, 'comment')
+        self._decode_map(sd.parameters)
+
+      def _encode_map(self, mapp):
+        for key, value in mapp.iteritems():
+          mapp[key] = smart_str(value, strings_only=True)
+
+      def _decode_map(self, mapp):
+        for key, value in mapp.iteritems():
+          mapp[key] = force_unicode(value, strings_only=True, errors='replace')
+
+      def create_database(self, name, description):
+        description = smart_str(description)
+        return self._client.create_database(name, description)
+
+      def get_database(self, *args, **kwargs):
+        db = self._client.get_database(*args, **kwargs)
+        return _decode_struct_attr(db, 'description')
+
+      def get_fields(self, *args, **kwargs):
+        res = self._client.get_fields(*args, **kwargs)
+        for fschema in res:
+          _decode_struct_attr(fschema, 'comment')
+        return res
+
+      def get_table(self, *args, **kwargs):
+        res = self._client.get_table(*args, **kwargs)
+        self._decode_storage_descriptor(res.sd)
+        self._decode_map(res.parameters)
+        return res
+
+      def alter_table(self, dbname, tbl_name, new_tbl):
+        self._encode_storage_descriptor(new_tbl.sd)
+        self._encode_map(new_tbl.parameters)
+        return self._client.alter_table(dbname, tbl_name, new_tbl)
+
+      def _encode_partition(self, part):
+        self._encode_storage_descriptor(part.sd)
+        self._encode_map(part.parameters)
+        return part
+
+      def _decode_partition(self, part):
+        self._decode_storage_descriptor(part.sd)
+        self._decode_map(part.parameters)
+        return part
+
+      def add_partition(self, new_part):
+        self._encode_partition(new_part)
+        part = self._client.add_partition(new_part)
+        return self._decode_partition(part)
+
+      def get_partition(self, *args, **kwargs):
+        part = self._client.get_partition(*args, **kwargs)
+        return self._decode_partition(part)
+
+      def get_partitions(self, *args, **kwargs):
+        part_list = self._client.get_partitions(*args, **kwargs)
+        for part in part_list:
+          self._decode_partition(part)
+        return part_list
+
+      def alter_partition(self, db_name, tbl_name, new_part):
+        self._encode_partition(new_part)
+        return self._client.alter_partition(db_name, tbl_name, new_part)
+
+    _, host, port = hive_site.get_metastore()
+    client = thrift_util.get_client(ThriftHiveMetastore.Client,
+                                    host,
+                                    port,
+                                    service_name="Hive Metastore Server",
+                                    timeout_seconds=conf.METASTORE_CONN_TIMEOUT.get())
+    return UnicodeMetastoreClient(client)
+
+
+def _decode_struct_attr(struct, attr):
+  try:
+    val = getattr(struct, attr)
+  except AttributeError:
+    return struct
+  unival = force_unicode(val, strings_only=True, errors='replace')
+  setattr(struct, attr, unival)
+  return struct
+
+
+def _encode_struct_attr(struct, attr):
+  try:
+    unival = getattr(struct, attr)
+  except AttributeError:
+    return struct
+  val = smart_str(unival, strings_only=True)
+  setattr(struct, attr, val)
+  return struct
+

+ 293 - 0
apps/beeswax/src/beeswax/server/dbms.py

@@ -0,0 +1,293 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+import thrift
+import time
+
+from django.utils.encoding import force_unicode
+from django.utils.translation import ugettext_lazy as _
+
+from filebrowser.views import location_to_url
+
+from beeswaxd.ttypes import BeeswaxException
+
+from beeswax import conf
+from beeswax.design import hql_query
+from beeswax.models import QueryHistory, HIVE_SERVER2
+from beeswax.conf import SERVER_INTERFACE
+
+
+LOG = logging.getLogger(__name__)
+
+
+def get(user, query_server=None):
+  # Avoid circular dependency
+  from beeswax.server.hive_server2_lib import HiveServerClientCompatible, HiveServerClient
+  from beeswax.server.beeswax_lib import BeeswaxClient
+
+  if query_server is None:
+    query_server = get_query_server(support_ddl=True)
+
+  if SERVER_INTERFACE.get() == HIVE_SERVER2:
+    return Dbms(HiveServerClientCompatible(HiveServerClient(query_server, user)), QueryHistory.SERVER_TYPE[1][0])
+  else:
+    return Dbms(BeeswaxClient(query_server, user), QueryHistory.SERVER_TYPE[0][0])
+
+
+
+def get_query_server(name='default', support_ddl=False):
+  if 'beeswax_server_host' in conf.QUERY_SERVERS['bind_to'] or 'beeswax_server_port' in conf.QUERY_SERVERS['bind_to']:
+    return {
+          'server_name': 'default',
+          'server_host': conf.BEESWAX_SERVER_HOST.get(),
+          'server_port': conf.BEESWAX_SERVER_PORT.get(),
+          'support_ddl': True,
+      }
+
+  servers = conf.QUERY_SERVERS
+
+  if support_ddl:
+    if not servers[name].SUPPORT_DDL.get():
+      for key in servers.keys():
+        if servers[key].SUPPORT_DDL.get():
+          name = key
+          break
+
+  config = servers[name]
+
+  query_server = {
+      'server_name': name,
+      'server_host': config.SERVER_HOST.get(),
+      'server_port': config.SERVER_PORT.get(),
+      'support_ddl': config.SUPPORT_DDL.get(),
+  }
+
+  return query_server
+
+
+class QueryServerException: pass
+
+class NoSuchObjectException: pass
+
+
+class Dbms:
+  """SQL"""
+
+  def __init__(self, client, server_type):
+    self.client = client
+    self.server_type = server_type
+
+
+  def get_table(self, database, table_name):
+    return self.client.get_table(database, table_name)
+
+
+  def get_tables(self, database='default', table_names='.*'):
+    return self.client.get_tables(database, table_names)
+
+
+  def execute_query(self, query, design):
+    return self.execute_and_watch(query, design=design)
+
+
+  def select_star_from(self, table):
+    hql = "SELECT * FROM `%s` %s" % (table.name, self._get_browse_limit_clause(table))
+    return self.execute_statement(hql)
+
+
+  def execute_statement(self, hql):
+    query = hql_query(hql)
+    return self.execute_and_watch(query)
+
+
+  def fetch(self, query_handle, start_over=False, rows=None):
+    no_start_over_support = [config_variable for config_variable in self.get_default_configuration(False)
+                                             if config_variable.key == 'support_start_over'
+                                               and config_variable.value == 'false']
+    if no_start_over_support:
+      start_over = False
+
+    return self.client.fetch(query_handle, start_over, rows)
+
+
+  def get_sample(self, table):
+    """No samples if it's a view (HUE-526)"""
+    if not table.is_view:
+      limit = min(100, conf.BROWSE_PARTITIONED_TABLE_LIMIT.get())
+      hql = "SELECT * FROM `%s` LIMIT %s" % (table.name, limit)
+      query = hql_query(hql)
+      handle = self.execute_and_wait(query, timeout_sec=5.0)
+
+      if handle:
+        return self.fetch(handle)
+
+
+  def drop_table(self, table):
+    if table.is_view:
+      hql = "DROP VIEW `%s`" % (table.name,)
+    else:
+      hql = "DROP TABLE `%s`" % (table.name,)
+
+    return self.execute_statement(hql)
+
+
+  def get_log(self, query_handle):
+    return self.client.get_log(query_handle)
+
+
+  def get_state(self, handle):
+    return self.client.get_state(handle)
+
+
+  def execute_and_wait(self, query, timeout_sec=30.0):
+    """
+    Run query and check status until it finishes or timeouts.
+    """
+    SLEEP_INTERVAL = 0.5
+
+    handle = self.client.query(query)
+    curr = time.time()
+    end = curr + timeout_sec
+
+    while curr <= end:
+      state = self.client.get_state(handle)
+      if state not in (QueryHistory.STATE.running, QueryHistory.STATE.submitted):
+        return handle
+      time.sleep(SLEEP_INTERVAL)
+      curr = time.time()
+    return None
+
+
+  def execute_and_watch(self, query, design=None, notify=False):
+    """
+    Run query and return a QueryHistory object in order to see its progress on a Web page.
+    """
+    query_statement = query.query['query']
+    query_history = QueryHistory.build(
+                                owner=self.client.user,
+                                query=query_statement,
+                                server_host='%(server_host)s' % self.client.query_server,
+                                server_port='%(server_port)d' % self.client.query_server,
+                                server_name='%(server_name)s' % self.client.query_server,
+                                server_type=self.server_type,
+                                last_state=QueryHistory.STATE.submitted.index,
+                                design=design,
+                                notify=notify)
+    query_history.save()
+
+    LOG.debug("Made new QueryHistory id %s user %s query: %s..." % (query_history.id, self.client.user, query_history.query[:25]))
+
+    try:
+      handle = self.client.query(query)
+      if not handle.is_valid():
+        msg = _("Server returning invalid handle for query id %(id)d [%(query)s]...") % \
+              {'id': query_history.id, 'query': query_statement[:40]}
+        raise BeeswaxException(msg)
+    except BeeswaxException, ex: # TODO HS2
+      LOG.exception(ex)
+      # Kind of expected (hql compile/syntax error, etc.)
+      if ex.handle:
+        query_history.server_id = ex.handle.id
+        query_history.log_context = ex.handle.log_context
+      query_history.save_state(QueryHistory.STATE.failed)
+      raise ex
+
+    # All good
+    query_history.server_id, query_history.server_guid = handle.get()
+    query_history.operation_type = handle.operation_type
+    query_history.has_results = handle.has_result_set
+    query_history.modified_row_count = handle.modified_row_count
+    query_history.log_context = handle.log_context
+
+    query_history.set_to_running()
+    query_history.save()
+
+    return query_history
+
+
+  def get_results_metadata(self, handle):
+    return self.client.get_results_metadata(handle)
+
+
+  def close(self, handle):
+    return self.client.close(handle)
+
+
+  def get_partitions(self, db_name, table, max_parts=None):
+    if max_parts is None or max_parts > conf.BROWSE_PARTITIONED_TABLE_LIMIT.get():
+      max_parts = conf.BROWSE_PARTITIONED_TABLE_LIMIT.get()
+
+    return self.client.get_partitions(db_name, table.name, max_parts)
+
+
+  def explain(self, statement):
+    return self.client.explain(statement)
+
+
+  def echo(self, text):
+    return self.client.echo(text)
+
+
+  def getStatus(self):
+    return self.client.getStatus()
+
+
+  def get_default_configuration(self, include_hadoop):
+    return self.client.get_default_configuration(include_hadoop)
+
+
+  def _get_browse_limit_clause(self, table):
+    """Get the limit clause when browsing a partitioned table"""
+    if table.partition_keys:
+      limit = conf.BROWSE_PARTITIONED_TABLE_LIMIT.get()
+      if limit > 0:
+        return "LIMIT %d" % (limit,)
+    return ""
+
+
+class Table:
+  """
+  Represents the metadata of a Hive Table.
+  """
+  @property
+  def hdfs_link(self):
+    return location_to_url(self.path_location)
+
+
+class DataTable:
+  """
+  Represents the data of a Hive Table.
+
+  If the dataset has more rows, a new fetch should be done in order to return a new data table with the next rows.
+  """
+  pass
+
+
+# TODO decorator?
+def expand_exception(exc, db):
+  try:
+    log = db.get_log(exc)
+  except:
+    # Always show something, even if server has died on the job.
+    log = _("Could not retrieve log.")
+
+  if not exc.message:
+    error_message = _("Unknown exception.")
+  else:
+    error_message = force_unicode(exc.message, strings_only=True, errors='replace')
+  return error_message, log

+ 465 - 0
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -0,0 +1,465 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import thrift
+
+from desktop.lib import thrift_util
+
+from cli_service import TCLIService
+from cli_service.ttypes import TOpenSessionReq, TGetTablesReq, TFetchResultsReq,\
+  TStatusCode, TGetResultSetMetadataReq, TGetColumnsReq, TType,\
+  TExecuteStatementReq, TGetOperationStatusReq, TFetchOrientation,\
+  TCloseSessionReq
+
+from beeswax import conf
+from beeswax.models import Session, HiveServerQueryHandle, HiveServerQueryHistory
+from beeswax.server.dbms import Table, NoSuchObjectException, DataTable
+
+
+class HiveServerTable(Table):
+
+  def __init__(self, table_results, table_schema, desc_results, desc_schema):
+    if not table_results.rows:
+      raise NoSuchObjectException()
+    self.table = table_results.rows and table_results.rows[0] or ''
+    self.table_schema = table_schema
+    self.results = desc_results
+    self.schema = desc_schema
+
+  @property
+  def name(self):
+    return HiveServerTRow(self.table, self.table_schema).col('TABLE_NAME')
+
+  @property
+  def is_view(self):
+    return HiveServerTRow(self.table, self.table_schema).col('TABLE_TYPE') == 'VIRTUAL_VIEW'
+
+  @property
+  def partition_keys(self):
+    # TODO
+    return [][:conf.BROWSE_PARTITIONED_TABLE_LIMIT.get()]
+
+  @property
+  def path_location(self):
+    # TODO
+    return ''
+
+  @property
+  def parameters(self):
+    # TODO
+    return {}
+
+  @property
+  def cols(self):
+    cols = HiveServerTTableSchema(self.results, self.schema).cols()
+    if all([col['col_name'] for col in cols]):
+      return cols
+    else:
+      return cols[:-2] # Drop last 2 lines of Extended describe
+
+  @property
+  def comment(self):
+    # TODO
+    return ''
+
+
+
+class HiveServerTRowSet:
+  def __init__(self, row_set, schema):
+    self.row_set = row_set
+    self.rows = row_set.rows
+    self.schema = schema
+    self.startRowOffset = row_set.startRowOffset
+
+  def is_empty(self):
+    return len(self.rows) == 0
+
+  def cols(self, col_names):
+    cols_rows = []
+    for row in self.rows:
+      row = HiveServerTRow(row, self.schema)
+      cols = {}
+      for col_name in col_names:
+        cols[col_name] = row.col(col_name)
+      cols_rows.append(cols)
+    return cols_rows
+
+  def __iter__(self):
+    return self
+
+  def next(self):
+    if self.rows:
+      return HiveServerTRow(self.rows.pop(0), self.schema)
+    else:
+      raise StopIteration
+
+
+
+class HiveServerDataTable(DataTable):
+  def __init__(self, results, schema):
+    self.schema = schema and schema.schema
+    self.row_set = HiveServerTRowSet(results.results, schema)
+    self.has_more = not self.row_set.is_empty()    # Should be results.hasMoreRows but always True in HS2
+    self.startRowOffset = self.row_set.startRowOffset    # Always 0 in HS2
+
+  @property
+  def ready(self):
+    return True
+
+  def cols(self):
+    if self.schema:
+      return [HiveServerTColumnDesc(col) for col in self.schema.columns]
+    else:
+      return []
+
+  def rows(self):
+    for row in self.row_set:
+      yield row.fields()
+
+
+
+class HiveServerTTableSchema:
+  def __init__(self, columns, schema):
+    self.columns = columns
+    self.schema = schema
+
+  def cols(self):
+    return HiveServerTRowSet(self.columns, self.schema).cols(('col_name', 'data_type', 'comment'))
+
+  def col(self, colName):
+    pos = self._get_col_position(colName)
+    return HiveServerTColumnDesc(self.columns[pos]).val
+
+  def _get_col_position(self, column_name):
+    return filter(lambda col: col.columnName == column_name, self.schema.columns)[0].position - 1
+
+
+class HiveServerTRow:
+  def __init__(self, row, schema):
+    self.row = row
+    self.schema = schema
+
+  def col(self, colName):
+    pos = self._get_col_position(colName)
+    return HiveServerTColumnValue(self.row.colVals[pos]).val
+
+  def _get_col_position(self, column_name):
+    return filter(lambda col: col.columnName == column_name, self.schema.columns)[0].position - 1
+
+  def fields(self):
+    return [HiveServerTColumnValue(field).val for field in self.row.colVals]
+
+
+class HiveServerTColumnValue:
+  def __init__(self, tcolumn_value):
+    self.column_value = tcolumn_value
+
+  @property
+  def val(self):
+    # TODO get index from schema
+    if self.column_value.boolVal is not None:
+      return self.column_value.boolVal.value
+    elif self.column_value.byteVal is not None:
+      return self.column_value.byteVal.value
+    elif self.column_value.i16Val is not None:
+      return self.column_value.i16Val.value
+    elif self.column_value.i32Val is not None:
+      return self.column_value.i32Val.value
+    elif self.column_value.i64Val is not None:
+      return self.column_value.i64Val.value
+    elif self.column_value.doubleVal is not None:
+      return self.column_value.doubleVal.value
+    elif self.column_value.stringVal is not None:
+      return self.column_value.stringVal.value
+
+
+class HiveServerTColumnDesc:
+  def __init__(self, column):
+    self.column = column
+
+  @property
+  def name(self):
+    return self.column.columnName
+
+  @property
+  def comment(self):
+    return self.column.comment
+
+  @property
+  def type(self):
+    return self.get_type(self.column.typeDesc)
+
+  @classmethod
+  def get_type(self, typeDesc):
+    for ttype in typeDesc.types:
+      if ttype.primitiveEntry is not None:
+        return TType._VALUES_TO_NAMES[ttype.primitiveEntry.type]
+      elif ttype.mapEntry is not None:
+        return ttype.mapEntry
+      elif ttype.unionEntry is not None:
+        return ttype.unionEntry
+      elif ttype.arrayEntry is not None:
+        return ttype.arrayEntry
+      elif ttype.structEntry is not None:
+        return ttype.structEntry
+      elif ttype.userDefinedTypeEntry is not None:
+        return ttype.userDefinedTypeEntry
+
+
+class HiveServerClient:
+  """Thrift service client."""
+
+  def __init__(self, query_server, user):
+    self.query_server = query_server
+    self.user = user
+
+    self._client = thrift_util.get_client(TCLIService.Client,
+                                          query_server['server_host'],
+                                          query_server['server_port'],
+                                          service_name='Hive Server 2',
+                                          timeout_seconds=conf.BEESWAX_SERVER_CONN_TIMEOUT.get())
+
+
+  def call(self, fn, req, status=TStatusCode.SUCCESS_STATUS):
+    session = Session.objects.get_session(self.user)
+    if session is None:
+      session = self.open_session(self.user)
+    if hasattr(req, 'sessionHandle') and req.sessionHandle is None:
+      req.sessionHandle = session.get_handle()
+
+    res = fn(req)
+
+    if res.status.statusCode == TStatusCode.ERROR_STATUS: #TODO should be TStatusCode.INVALID_HANDLE_STATUS
+      print 'HS2 Session has expired: %s' % res
+      print 'Retrying with a new sessions...'
+
+      session = self.open_session(self.user)
+      req.sessionHandle = session.get_handle()
+
+      res = fn(req)
+
+    if status is not None and res.status.statusCode not in (
+        TStatusCode.SUCCESS_STATUS, TStatusCode.SUCCESS_WITH_INFO_STATUS, TStatusCode.STILL_EXECUTING_STATUS):
+      raise Exception('Bad status for request %s:\n%s' % (req, res))
+    else:
+      return res
+
+
+  def open_session(self, user):
+    req = TOpenSessionReq(username=user.username)
+    res = self._client.OpenSession(req)
+
+    sessionId = res.sessionHandle.sessionId
+
+    encoded_status, encoded_guid = HiveServerQueryHandle(secret=sessionId.secret, guid=sessionId.guid).get()
+
+    return Session.objects.create(owner=user,
+                                  status_code=res.status.statusCode,
+                                  secret=encoded_status,
+                                  guid=encoded_guid,
+                                  server_protocol_version=res.serverProtocolVersion)
+
+  def close_session(self):
+    session = Session.objects.get_session(self.user).get_handle()
+
+    req = TCloseSessionReq(sessionHandle=session)
+    return self._client.CloseSession(req)
+
+
+  def get_tables(self, database, table_names):
+    req = TGetTablesReq(schemaName=database, tableName=table_names)
+    res = self.call(self._client.GetTables, req)
+
+    results, schema = self.fetch_result(res.operationHandle)
+
+    return HiveServerTRowSet(results.results, schema.schema).cols(('TABLE_NAME',))
+
+
+  def get_table(self, database, table_name):
+    req = TGetTablesReq(schemaName='default', tableName=table_name)
+    res = self.call(self._client.GetTables, req)
+    table_results, table_schema = self.fetch_result(res.operationHandle)
+
+    # Using 'SELECT * from table' does not show column comments in the metadata
+    desc_results, desc_schema = self.execute_statement('DESCRIBE EXTENDED %s' % table_name)
+    return HiveServerTable(table_results.results, table_schema.schema, desc_results.results, desc_schema.schema)
+
+
+  def execute_query(self, query, max_rows=1000):
+    # TODO: Need jars, UDF etc
+    results, schema = self.execute_statement(statement=query.query['query'], conf_overlay={}, max_rows=max_rows)
+    return HiveServerDataTable(results, schema)
+
+
+  def execute_async_query(self, query):
+    return self.execute_async_statement(statement=query.query['query'], conf_overlay={})
+
+
+  def execute_statement(self, statement, conf_overlay=None, max_rows=100):
+    req = TExecuteStatementReq(statement=statement)
+    res = self.call(self._client.ExecuteStatement, req)
+
+    return self.fetch_result(res.operationHandle, max_rows=max_rows)
+
+
+  def execute_async_statement(self, statement, conf_overlay=None):
+    req = TExecuteStatementReq(statement=statement)
+    res = self.call(self._client.ExecuteStatement, req)
+
+    return HiveServerQueryHandle(secret=res.operationHandle.operationId.secret,
+                                 guid=res.operationHandle.operationId.guid,
+                                 operation_type=res.operationHandle.operationType,
+                                 has_result_set=res.operationHandle.hasResultSet,
+                                 modified_row_count=res.operationHandle.modifiedRowCount)
+
+
+  def fetch_data(self, operation_handle, orientation=TFetchOrientation.FETCH_NEXT, max_rows=10000):
+    # The client should check for hasMoreRows and fetch until the result is empty
+    results, schema = self.fetch_result(operation_handle, orientation, max_rows)
+    return HiveServerDataTable(results, schema)
+
+
+  def get_columns(self, table):
+    req = TGetColumnsReq(schemaName='default', tableName=table)
+    res = self.call(self._client.GetColumns, req)
+
+    return self.fetch_result(res.operationHandle)
+
+
+  def fetch_result(self, operation_handle, orientation=TFetchOrientation.FETCH_NEXT, max_rows=10000):
+    fetch_req = TFetchResultsReq(operationHandle=operation_handle, orientation=orientation, maxRows=max_rows)
+    res = self.call(self._client.FetchResults, fetch_req)
+
+    if operation_handle.hasResultSet:
+      meta_req = TGetResultSetMetadataReq(operationHandle=operation_handle)
+      schema = self.call(self._client.GetResultSetMetadata, meta_req)
+    else:
+      schema = None
+
+    return res, schema
+
+
+  def get_operation_status(self, operation_handle):
+    req = TGetOperationStatusReq(operationHandle=operation_handle)
+    res = self.call(self._client.GetOperationStatus, req)
+
+    return res
+
+
+class HiveServerTableCompatible(HiveServerTable):
+  """Same API as Beeswax"""
+
+  def __init__(self, hive_table):
+    self.table = hive_table.table
+    self.table_schema = hive_table.table_schema
+    self.results = hive_table.results
+    self.schema = hive_table.schema
+
+  @property
+  def cols(self):
+    return [type('Col', (object,), {'name': col.get('col_name', ''),
+                                    'type': col.get('data_type', ''),
+                                    'comment': col.get('comment', ''), }) for col in HiveServerTable.cols.fget(self)]
+
+
+class HiveServerClientCompatible:
+  """Same API as Beeswax"""
+
+  def __init__(self, client):
+    self._client = client
+    self.user = client.user
+    self.query_server = client.query_server
+
+
+  def query(self, query):
+    return self._client.execute_async_query(query)
+
+
+  def get_state(self, handle):
+    operationHandle = handle.get_rpc_handle()
+
+    res = self._client.get_operation_status(operationHandle)
+    print res
+    return HiveServerQueryHistory.STATE_MAP[res.operationState]
+
+
+  def explain(self, query):
+    raise NotImplementedError()
+
+
+  def fetch(self, handle, start_over=False, max_rows=None):
+    operationHandle = handle.get_rpc_handle()
+    if max_rows is None:
+      max_rows = 10000
+
+    if start_over:
+      orientation = TFetchOrientation.FETCH_FIRST
+    else:
+      orientation = TFetchOrientation.FETCH_NEXT
+
+    data_table = self._client.fetch_data(operationHandle, orientation=orientation, max_rows=max_rows)
+
+    return type('Result', (object,), {'rows': data_table.rows,
+                                      'columns': [col.name for col in data_table.cols()],
+                                      'has_more': data_table.has_more,
+                                      'start_row': data_table.startRowOffset, })
+
+  def dump_config(self):
+    return 'Does not exist in HS2'
+
+
+  def echo(self, msg):
+    return 'Does not exist in HS2'
+
+
+  def get_log(self, *args, **kwargs):
+    return 'No logs retrieval implemented'
+
+
+  def get_tables(self, database, table_names):
+    return [table['TABLE_NAME'] for table in self._client.get_tables(database, table_names)]
+
+
+  def get_table(self, database, table_name):
+    table = self._client.get_table(database, table_name)
+    return HiveServerTableCompatible(table)
+
+
+  def get_default_configuration(self, *args, **kwargs):
+    return {}
+
+
+  def create_database(self, name, description): raise NotImplementedError()
+
+
+  def get_database(self, *args, **kwargs): raise NotImplementedError()
+
+
+  def alter_table(self, dbname, tbl_name, new_tbl): raise NotImplementedError()
+
+
+  def add_partition(self, new_part): raise NotImplementedError()
+
+
+  def get_partition(self, *args, **kwargs): raise NotImplementedError()
+
+
+  def get_partitions(self, *args, **kwargs): raise NotImplementedError()
+
+
+  def alter_partition(self, db_name, tbl_name, new_part): raise NotImplementedError()

+ 30 - 27
apps/beeswax/src/beeswax/templates/describe_partitions.mako

@@ -14,44 +14,47 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 <%!
-  from urllib import quote
   from filebrowser.views import location_to_url
   from desktop.views import commonheader, commonfooter
   from django.utils.translation import ugettext as _
 %>
+
 <%namespace name="layout" file="layout.mako" />
-${commonheader(_('Beeswax Table Partitions: %(tableName)s') % dict(tableName=table.tableName), "beeswax", user, "100px")}
+
+${commonheader(_('Beeswax Table Partitions: %(tableName)s') % dict(tableName=table.name), "beeswax", user, "100px")}
 ${layout.menubar(section='tables')}
 
 <div class="container-fluid">
 <h1>${_('Partitions')}</h1>
 
-<table>
-<tr>
-  % for field in table.partitionKeys:
-  <th>${field.name}</th>
-  % endfor
-  <th></th>## ${_('Extra column for command links.')}
-</tr>
-% if len(partitions) > 0:
-  % for partition in partitions:
-  <tr>
-    % for key in partition.values:
-    <td>${key}</td>
+<table class="table table-striped table-condensed datatables">
+  % if partitions:
+    <tr>
+      % for field in table.partition_keys:
+        <th>${field.name}</th>
+      % endfor
+      <th>${_('Path')}</th>
+    </tr>
+    % for partition in partitions:
+      <tr>
+        % for key in partition.values:
+          <td>${key}</td>
+        % endfor
+        <td>
+          <% url = location_to_url(partition.sd.location) %>
+          % if url:
+            <a href="${url}">${partition.sd.location}</a>
+          % else:
+            ${partition.sd.location}
+          % endif
+        </td>
+      </tr>
     % endfor
-    <td>
-      <% url = location_to_url(request, partition.sd.location) %>
-      % if url:
-        <a href="${url}">${partition.sd.location}</a>
-      % else:
-        ${partition.sd.location}
-      % endif
-    </td>
-  </tr>
-  % endfor
-% else:
-  <tr><td>${_('Table has no partitions.')}</td></tr>
-% endif
+  % else:
+    <tr><td>${_('Table has no partitions.')}</td></tr>
+  % endif
 </table>
+
 </div>
+
 ${commonfooter(messages)}

+ 123 - 134
apps/beeswax/src/beeswax/templates/describe_table.mako

@@ -22,12 +22,12 @@ from django.utils.translation import ugettext as _
 <%namespace name="comps" file="beeswax_components.mako" />
 
 <%
-  if is_view:
+  if table.is_view:
     view_or_table_noun = _("View")
   else:
     view_or_table_noun = _("Table")
 %>
-${commonheader(_("%s Metadata: %s") % (view_or_table_noun, table.tableName), "beeswax", user, "100px")}
+${commonheader(_("%s Metadata: %s") % (view_or_table_noun, table.name), "beeswax", user, "100px")}
 ${layout.menubar(section='tables')}
 
 <%def name="column_table(cols)">
@@ -53,150 +53,139 @@ ${layout.menubar(section='tables')}
 </%def>
 
 <div class="container-fluid">
-	<h1>${_('Table Metadata:')} ${table.tableName}</h1>
-	<div class="row-fluid">
-		<div class="span3">
-			<div class="well sidebar-nav">
-				<ul class="nav nav-list">
-					<li class="nav-header">${_('Actions')}</li>
-					<li><a href="#importData" data-toggle="modal">${_('Import Data')}</a></li>
-					<li><a href="${ url("beeswax.views.read_table", table=table_name) }">${_('Browse Data')}</a></li>
-			    <li><a href="#dropTable" data-toggle="modal">${_('Drop')} ${view_or_table_noun}</a></li>
-			    <li><a href="${hdfs_link}" rel="${ table.sd.location }">${_('View File Location')}</a></li>
-				</ul>
-			</div>
-      <div id="jumpToColumnAlert" class="alert hide">
-        <button type="button" class="close" data-dismiss="alert">&times;</button>
-        <strong>${_('Did you know?')}</strong> ${_('You can click on a row to select a column you want to jump to.')}
-      </div>
-		</div>
-		<div class="span9">
-			% if table.parameters.get("comment", False):
-		    <h5>${ table.parameters.get("comment") }</h5>
-			% endif
-
-			<ul class="nav nav-tabs">
-				<li class="active"><a href="#columns" data-toggle="tab">${_('Columns')}</a></li>
-		        % if len(table.partitionKeys) > 0:
-					<li><a href="#partitionColumns" data-toggle="tab">${_('Partition Columns')}</a></li>
-		        % endif
-				% if top_rows is not None:
-					<li><a href="#sample" data-toggle="tab">${_('Sample')}</a></li>
-				% endif
-			</ul>
-
-			<div class="tab-content">
-				<div class="active tab-pane" id="columns">
-					${column_table(table.sd.cols)}
-				</div>
-		        % if len(table.partitionKeys) > 0:
-		          <div class="tab-pane" id="partitionColumns">
-		            ${column_table(table.partitionKeys)}
-		            <a href="${ url("beeswax.views.describe_partitions", table=table_name) }">${_('Show Partitions')}</a>
-		          </div>
-		        % endif
-				% if top_rows is not None:
-					<div class="tab-pane" id="sample">
-						<table class="table table-striped table-condensed sampleTable">
-			              <thead>
-			                <tr>
-			                  % for col in table.sd.cols:
-			                    <th style="white-space: nowrap">${col.name}</th>
-			                  % endfor
-			                </tr>
-			              </thead>
-			              <tbody>
-			                % for i, row in enumerate(top_rows):
-			                  <tr>
-			                    % for item in row:
-			                      <td style="white-space: nowrap">${ item }</td>
-			                    % endfor
-			                  </tr>
-			                % endfor
-			              </tbody>
-			            </table>
-		        	</div>
-				% endif
-			</div>
-		</div>
-	</div>
+    <h1>${_('Table Metadata:')} ${table.name}</h1>
+    <div class="row-fluid">
+        <div class="span3">
+            <div class="well sidebar-nav">
+                <ul class="nav nav-list">
+                    <li class="nav-header">${_('Actions')}</li>
+                    <li><a href="#importData" data-toggle="modal">${_('Import Data')}</a></li>
+                    <li><a href="${ url("beeswax.views.read_table", table=table.name) }">${_('Browse Data')}</a></li>
+                    <li><a href="#dropTable" data-toggle="modal">${_('Drop')} ${view_or_table_noun}</a></li>
+                    <li><a href="${ table.hdfs_link }" rel="${ table.path_location }">${_('View File Location')}</a></li>
+                </ul>
+            </div>
+        </div>
+        <div class="span9">
+            % if table.comment is not None:
+                <h5>${ table.comment }</h5>
+            % endif
+
+            <ul class="nav nav-tabs">
+                <li class="active"><a href="#columns" data-toggle="tab">${_('Columns')}</a></li>
+                % if table.partition_keys:
+                    <li><a href="#partitionColumns" data-toggle="tab">${_('Partition Columns')}</a></li>
+                % endif
+                % if sample is not None:
+                    <li><a href="#sample" data-toggle="tab">${_('Sample')}</a></li>
+                % endif
+            </ul>
+
+            <div class="tab-content">
+                <div class="active tab-pane" id="columns">
+                    ${column_table(table.cols)}
+                </div>
+
+                % if table.partition_keys:
+                  <div class="tab-pane" id="partitionColumns">
+                    ${column_table(table.partition_keys)}
+                    <a href="${ url("beeswax.views.describe_partitions", table=table.name) }">${_('Show Partitions')}</a>
+                  </div>
+                % endif
+
+                % if sample is not None:
+                    <div class="tab-pane" id="sample">
+                        <table class="table table-striped table-condensed sampleTable">
+                          <thead>
+                            <tr>
+                              % for col in table.cols:
+                                <th>${col.name}</th>
+                              % endfor
+                            </tr>
+                          </thead>
+                          <tbody>
+                            % for i, row in enumerate(sample):
+                              <tr>
+                                % for item in row:
+                                  <td>${ item }</td>
+                                % endfor
+                              </tr>
+                            % endfor
+                          </tbody>
+                        </table>
+                    </div>
+                % endif
+            </div>
+        </div>
+    </div>
 </div>
 
 
 
 
 <div id="dropTable" class="modal hide fade">
-	<form id="dropTableForm" method="POST" action="${ url("beeswax.views.drop_table", table=table_name) }">
-	<div class="modal-header">
-		<a href="#" class="close" data-dismiss="modal">&times;</a>
-		<h3>${_('Drop Table')}</h3>
-	</div>
-	<div class="modal-body">
-	  <div id="dropTableMessage" class="alert">
-
-	  </div>
-	</div>
-	<div class="modal-footer">
-		<input type="submit" class="btn primary" value="${_('Yes')}"/>
-		<a href="#" class="btn secondary hideModal">${_('No')}</a>
-	</div>
-	</form>
+    <form id="dropTableForm" method="POST" action="${ url("beeswax.views.drop_table", table=table.name) }">
+    <div class="modal-header">
+        <a href="#" class="close" data-dismiss="modal">&times;</a>
+        <h3>${_('Drop Table')}</h3>
+    </div>
+    <div class="modal-body">
+      <div id="dropTableMessage" class="alert">
+      </div>
+    </div>
+    <div class="modal-footer">
+        <input type="submit" class="btn primary" value="${_('Yes')}"/>
+        <a href="#" class="btn secondary hideModal">${_('No')}</a>
+    </div>
+    </form>
 </div>
 
 
 
 <div id="importData" class="modal hide fade">
-	<form method="POST" action="${ url("beeswax.views.load_table", table=table_name) }" class="form-stacked">
-	<div class="modal-header">
-		<a href="#" class="close" data-dismiss="modal">&times;</a>
-		<h3>${_('Import data')}</h3>
-	</div>
-	<div class="modal-body">
-	  <div class="alert">
-	        <p>${_("Note that loading data will move data from its location into the table's storage location.")}</p>
-	  </div>
-
-
-
-	  <div class="clearfix">
-	  ${comps.label(load_form["path"], title_klass='loadPath', attrs=dict(
-        ))}
-    	<div class="input">
-		     ${comps.field(load_form["path"], title_klass='loadPath', attrs=dict(
-		       klass='loadPath input-xlarge'
-		       ))}
-		</div>
-		</div>
-
-      % for pf in load_form.partition_columns:
-		<div class="clearfix">
-			${comps.label(load_form[pf], render_default=True)}
-	    	<div class="input">
-	        	${comps.field(load_form[pf], render_default=True, attrs=dict(
-			       klass='input-xlarge'
-			       ))}
-			</div>
-		</div>
-
-      % endfor
-
-		<div class="clearfix">
-			<div class="input">
-				<input type="checkbox" name="overwrite"/> ${_('Overwrite existing data')}
-			</div>
-		</div>
-
-
-	<div id="filechooser">
-	</div>
-	</div>
-	<div class="modal-footer">
-		<input type="submit" class="btn primary" value="${_('Submit')}"/>
-		<a href="#" class="btn secondary" data-dismiss="modal">${_('Cancel')}</a>
-	</div>
-	</form>
+    <form method="POST" action="${ url("beeswax.views.load_table", table=table.name) }" class="form-stacked">
+        <div class="modal-header">
+            <a href="#" class="close" data-dismiss="modal">&times;</a>
+            <h3>${_('Import data')}</h3>
+        </div>
+        <div class="modal-body">
+            <div class="alert">
+                  <p>${_("Note that loading data will move data from its location into the table's storage location.")}</p>
+            </div>
+
+            <div class="clearfix">
+                ${comps.label(load_form["path"], title_klass='loadPath', attrs={})}
+                <div class="input">
+                    ${comps.field(load_form["path"], title_klass='loadPath', attrs={'klass': 'loadPath input-xlarge'})}
+                </div>
+            </div>
+
+            % for pf in load_form.partition_columns:
+                <div class="clearfix">
+                     ${comps.label(load_form[pf], render_default=True)}
+                     <div class="input">
+                       ${comps.field(load_form[pf], render_default=True, attrs={'klass': 'input-xlarge'})}
+                    </div>
+                </div>
+            % endfor
+
+            <div class="clearfix">
+                <div class="input">
+                    <input type="checkbox" name="overwrite"/> ${_('Overwrite existing data')}
+                </div>
+            </div>
+
+            <div id="filechooser"></div>
+        </div>
+
+        <div class="modal-footer">
+            <input type="submit" class="btn primary" value="${_('Submit')}"/>
+            <a href="#" class="btn secondary" data-dismiss="modal">${_('Cancel')}</a>
+        </div>
+    </form>
 </div>
 </div>
+
 <style>
     #filechooser {
         display:none;
@@ -227,7 +216,7 @@ ${layout.menubar(section='tables')}
             "bFilter": false
         });
 
-        $.getJSON("${ url("beeswax.views.drop_table", table=table_name) }",function(data){
+        $.getJSON("${ url("beeswax.views.drop_table", table=table.name) }", function(data){
             $("#dropTableMessage").text(data.title);
         });
         $(".hideModal").click(function(){

+ 1 - 1
apps/beeswax/src/beeswax/templates/explain.mako

@@ -36,7 +36,7 @@ ${layout.menubar(section='saved queries')}
             <pre>${explanation | h}</pre>
         </div>
         <div class="tab-pane" id="query">
-            <pre>${query | h}</pre>
+            <pre>${query.hql_query | h}</pre>
         </div>
     </div>
 </div>

+ 2 - 0
apps/beeswax/src/beeswax/templates/watch_results.mako

@@ -17,9 +17,11 @@
 from desktop.views import commonheader, commonfooter
 from django.utils.translation import ugettext as _
 %>
+
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="util" file="util.mako" />
 <%namespace name="comps" file="beeswax_components.mako" />
+
 ${commonheader(_('Query Results'), "beeswax", user, "100px")}
 ${layout.menubar(section='query')}
 

+ 2 - 0
apps/beeswax/src/beeswax/templates/watch_wait.mako

@@ -17,8 +17,10 @@
 from desktop.views import commonheader, commonfooter
 from django.utils.translation import ugettext as _
 %>
+
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="util" file="util.mako" />
+
 ${commonheader(_('Waiting for query...'), "beeswax", user, "100px")}
 ${layout.menubar(section='query')}
 

+ 20 - 11
apps/beeswax/src/beeswax/test_base.py

@@ -23,7 +23,6 @@ Common infrastructure for beeswax tests
 
 import atexit
 import logging
-import pwd
 import os
 import re
 import subprocess
@@ -31,14 +30,17 @@ import time
 
 import fb303.ttypes
 from nose.tools import assert_true, assert_false
+from django.contrib.auth.models import User
 
 from desktop.lib.django_test_util import make_logged_in_client
-
 from hadoop import pseudo_hdfs4
-import hadoop.conf
 
 import beeswax.conf
-from beeswax.db_utils import get_query_server
+
+from beeswax.conf import SERVER_INTERFACE
+from beeswax.models import HIVE_SERVER2
+from beeswax.server.dbms import get_query_server
+from beeswax.server import dbms
 
 
 _INITIALIZED = False
@@ -49,6 +51,7 @@ _SHARED_BEESWAX_SERVER_CLOSER = None
 BEESWAXD_TEST_PORT = 6969
 LOG = logging.getLogger(__name__)
 
+
 def _start_server(cluster):
   """
   Start beeswaxd and metastore
@@ -107,9 +110,13 @@ def get_shared_beeswax_server():
     # startup, during which BEESWAX_HIVE_CONF_DIR needs to be set to
     # /my/bogus/path. Hence the step of writing to memory.
     # hive-default.xml will get picked up by the beeswax_server during startup
-    file(cluster._tmpdir+"/conf/hive-default.xml", 'w').write(default_xml)
+    file(cluster._tmpdir + "/conf/hive-default.xml", 'w').write(default_xml)
 
     global _SHARED_BEESWAX_SERVER_PROCESS
+
+    if SERVER_INTERFACE.get() == HIVE_SERVER2:
+      _SHARED_BEESWAX_SERVER_PROCESS = 1
+
     if _SHARED_BEESWAX_SERVER_PROCESS is None:
       p = _start_server(cluster)
       _SHARED_BEESWAX_SERVER_PROCESS = p
@@ -118,18 +125,20 @@ def get_shared_beeswax_server():
         os.kill(p.pid, 9)
         p.wait()
       atexit.register(kill)
+
       # Wait for server to come up, by repeatedly trying.
       start = time.time()
       started = False
       sleep = 0.001
+      make_logged_in_client()
+      user = User.objects.get(username='test')
+      query_server = get_query_server(support_ddl=True)
+      db = dbms.get(user, query_server)
+
       while not started and time.time() - start < 20.0:
         try:
-          query_server = get_query_server(support_ddl=True)
-          client = beeswax.db_utils.db_client(query_server)
-          meta_client = beeswax.db_utils.meta_client()
-
-          client.echo("echo")
-          if meta_client.getStatus() == fb303.ttypes.fb_status.ALIVE:
+          db.echo("echo")
+          if db.getStatus() == fb303.ttypes.fb_status.ALIVE:
             started = True
             break
           time.sleep(sleep)

+ 69 - 81
apps/beeswax/src/beeswax/tests.py

@@ -26,28 +26,33 @@ import re
 import shutil
 import tempfile
 import threading
+
 from nose.tools import assert_true, assert_equal, assert_false
 from nose.plugins.skip import SkipTest
 from django.utils.encoding import smart_str
+from django.contrib.auth.models import User
 
+from beeswaxd import ttypes
 from desktop.lib.django_test_util import make_logged_in_client, assert_equal_mod_whitespace
 from desktop.lib.django_test_util import assert_similar_pages
 from desktop.lib.test_export_csvxls import xls2csv
+from desktop.lib.test_utils import grant_access
 
 import beeswax.create_table
-import beeswax.db_utils
 import beeswax.forms
 import beeswax.hive_site
 import beeswax.models
 import beeswax.views
+
 from beeswax import conf
-from beeswax.views import parse_results, collapse_whitespace
+from beeswax.views import collapse_whitespace
 from beeswax.test_base import make_query, wait_for_query_to_finish, verify_history, get_query_server,\
   BEESWAXD_TEST_PORT
+from beeswax.design import hql_query, _strip_trailing_semicolon
+from beeswax.data_export import download
+from beeswax.server import dbms
+from beeswax.server.beeswax_lib import BeeswaxDataTable
 from beeswax.test_base import BeeswaxSampleProvider
-from beeswaxd import BeeswaxService
-from beeswaxd import ttypes
-from desktop.lib.test_utils import grant_access
 
 
 LOG = logging.getLogger(__name__)
@@ -81,6 +86,10 @@ class TestBeeswaxWithHadoop(BeeswaxSampleProvider):
   """Tests for beeswax that require a running Hadoop"""
   requires_hadoop = True
 
+  def setUp(self):
+    user = User.objects.get(username='test')
+    self.db = dbms.get(user, get_query_server())
+
   def _verify_query_state(self, state):
     """
     Verify the state of the latest query.
@@ -125,8 +134,8 @@ class TestBeeswaxWithHadoop(BeeswaxSampleProvider):
     finish = beeswax.conf.BROWSE_PARTITIONED_TABLE_LIMIT.set_for_testing("90")
     try:
       response = self.client.get("/beeswax/table/test_partitions")
-      assert_true("0x%x" % 89 in response.content)
-      assert_false("0x%x" % 90 in response.content)
+      assert_true("0x%x" % 89 in response.content, response.content)
+      assert_false("0x%x" % 90 in response.content, response.content)
     finally:
       finish()
 
@@ -169,7 +178,7 @@ for x in sys.stdin:
     Test basic query submission
     """
     # Minimal server operation
-    assert_equal("echo", beeswax.db_utils.db_client(get_query_server()).echo("echo"))
+    assert_equal("echo", self.db.echo("echo"))
 
     # Table should have been created
     response = self.client.get("/beeswax/tables")
@@ -218,12 +227,12 @@ for x in sys.stdin:
     response = _make_query(self.client, QUERY, name='select star', local=False)
     response = wait_for_query_to_finish(self.client, response)
     assert_equal(str(response.context['query_context'][0]), 'design')
-    assert_true("<td>99</td>" in response.content)
+    assert_true("99</td>" in response.content)
     assert_true(response.context["has_more"])
     response = self.client.get("/beeswax/results/%d/%d" % (response.context["query"].id, response.context["next_row"]))
-    assert_true("<td>199</td>" in response.content)
+    assert_true("199</td>" in response.content)
     response = self.client.get("/beeswax/results/%d/0" % (response.context["query"].id))
-    assert_true("<td>99</td>" in response.content)
+    assert_true("99</td>" in response.content)
     assert_equal(0, len(response.context["hadoop_jobs"]), "SELECT * shouldn't have started jobs.")
 
     # Download the data
@@ -237,7 +246,7 @@ for x in sys.stdin:
     """
     response = _make_query(self.client, "SELECT my_sqrt(foo), my_power(foo, foo) FROM test WHERE foo=4",
       udfs=[('my_sqrt', 'org.apache.hadoop.hive.ql.udf.UDFSqrt'),
-        ('my_power', 'org.apache.hadoop.hive.ql.udf.UDFPower')], local=False)
+            ('my_power', 'org.apache.hadoop.hive.ql.udf.UDFPower')], local=False)
     response = wait_for_query_to_finish(self.client, response, max=60.0)
     assert_equal(["2.0", "256.0"], response.context["results"][0])
     log = response.context['log']
@@ -272,8 +281,7 @@ for x in sys.stdin:
       assert_true("ParseException" in response.context["error_message"])
       log = response.context['log']
       assert_true(len(log.split('\n')) > 10, 'Captured stack trace')
-      assert_true('org.apache.hadoop.hive.ql.parse.ParseException: line' in log,
-                  'Captured stack trace')
+      assert_true('org.apache.hadoop.hive.ql.parse.ParseException: line' in log, 'Captured stack trace')
 
     hql = "SELECT KITTENS ARE TASTY"
     resp = _make_query(self.client, hql, name='tasty kittens')
@@ -287,40 +295,30 @@ for x in sys.stdin:
   def test_sync_query_exec(self):
     # Execute Query Synchronously, set fetch size and fetch results
     # verify the size of resultset,
-    QUERY = """
+    hql = """
       SELECT foo FROM test;
     """
 
-    query_msg = BeeswaxService.Query()
-    query_msg.query = """
-      SELECT foo FROM test
-    """
-    query_msg.configuration = []
-    query_msg.hadoop_user = "test"
-    handle = beeswax.db_utils.db_client(get_query_server()).executeAndWait(query_msg, "")
+    query = hql_query(hql)
+    handle = self.db.execute_and_wait(query)
 
-    results = beeswax.db_utils.db_client(get_query_server()).fetch(handle, True, 5)
-    row_list = list(parse_results(results.data))
+    results = self.db.fetch(handle, True, 5)
+    row_list = list(results.rows())
     assert_equal(len(row_list), 5)
 
-    beeswax.db_utils.db_client(get_query_server()).close(handle)
-    beeswax.db_utils.db_client(get_query_server()).clean(handle.log_context)
-
+    self.db.close(handle)
 
   def test_sync_query_error(self):
+    # We don't use synchronous queries anywhere.
+    # It used to call BeeswaxService.executeAndWait()
+    raise SkipTest
     # Execute incorrect Query , verify the error code and sqlstate
-    QUERY = """
-      SELECT foo FROM test;
-    """
-
-    query_msg = BeeswaxService.Query()
-    query_msg.query = """
+    hql = """
       SELECT FROM zzzzz
     """
-    query_msg.configuration = []
-    query_msg.hadoop_user = "test"
+    query = hql_query(hql)
     try:
-      handle = beeswax.db_utils.db_client(get_query_server()).executeAndWait(query_msg, "")
+      self.db.execute_and_wait(query)
     except ttypes.BeeswaxException, bex:
       assert_equal(bex.errorCode, 40000)
       assert_equal(bex.SQLState, "42000")
@@ -342,30 +340,30 @@ for x in sys.stdin:
       def __init__(self, **entries):
         self.__dict__.update(entries)
 
-    client = beeswax.db_utils.db_client(get_query_server())
+    client = self.db
 
     prev_get_default_configuration = client.get_default_configuration
-    prev_client = client._client
+    prev_client = client.client
 
     try:
-      client._client = MockClient(True)
+      client.client = MockClient(True)
       client.get_default_configuration = lambda a: []
       client.fetch(None, True, 5)
 
-      client._client = MockClient(False)
+      client.client = MockClient(False)
       client.get_default_configuration = lambda a: []
       client.fetch(None, False, 5)
 
-      client._client = MockClient(True)
+      client.client = MockClient(True)
       client.get_default_configuration = lambda a: [ConfigVariable(key='support_start_over', value='true')]
       client.fetch(None, True, 5)
 
-      client._client = MockClient(False)
+      client.client = MockClient(False)
       client.get_default_configuration = lambda a: [ConfigVariable(key='support_start_over', value='false')]
       client.fetch(None, True, 5)
     finally:
       client.get_default_configuration = prev_get_default_configuration
-      client._client = prev_client
+      client.client = prev_client
 
 
   def test_parameterization(self):
@@ -440,8 +438,7 @@ for x in sys.stdin:
 
     # Describe table should be fine with non-ascii comment
     response = self.client.get('/beeswax/table/test_utf8')
-    assert_equal(response.context['table'].parameters['comment'],
-                 self.get_i18n_table_comment())
+    assert_equal(response.context['table'].parameters['comment'], self.get_i18n_table_comment())
 
   def _parallel_query_helper(self, i, result_holder, lock, num_tasks):
     client = make_logged_in_client()
@@ -488,37 +485,29 @@ for x in sys.stdin:
 
   def test_data_export_limit_clause(self):
     limit = 3
-    query_msg = BeeswaxService.Query()
-    query_msg.query = 'SELECT foo FROM test limit %d' % (limit,)
-    query_msg.configuration = []
-    query_msg.hadoop_user = "test"
-    handle = beeswax.db_utils.db_client(get_query_server()).query(query_msg)
-    query_data = beeswax.models.QueryHistory(server_id=handle.id, log_context=handle.log_context)
-    query_data.server_host = beeswax.conf.QUERY_SERVERS['default'].SERVER_HOST.get() # Needed as we query directly
-    query_data.server_port = beeswax.conf.QUERY_SERVERS['default'].SERVER_PORT.get()
+    hql = 'SELECT foo FROM test limit %d' % (limit,)
+    query = hql_query(hql)
+
+    handle = self.db.execute_and_wait(query)
     # Get the result in csv. Should have 3 + 1 header row.
-    csv_resp = beeswax.data_export.download(query_data, 'csv')
+    csv_resp = download(handle, 'csv', self.db)
     assert_equal(len(csv_resp.content.strip().split('\n')), limit + 1)
 
   def test_data_export(self):
-    query_msg = BeeswaxService.Query()
-    query_msg.query = 'SELECT * FROM test'
-    query_msg.configuration = []
-    query_msg.hadoop_user = "test"
-    handle = beeswax.db_utils.db_client(get_query_server()).query(query_msg)
-    query_data = beeswax.models.QueryHistory(server_id=handle.id, log_context=handle.log_context)
-    query_data.server_host = beeswax.conf.QUERY_SERVERS['default'].SERVER_HOST.get() # Needed as we query directly
-    query_data.server_port = beeswax.conf.QUERY_SERVERS['default'].SERVER_PORT.get()
-    # Get the result in xls. Then translate it into csv.
-    xls_resp = beeswax.data_export.download(query_data, 'xls')
+    hql = 'SELECT * FROM test'
+    query = hql_query(hql)
+
+    # Get the result in xls.
+    handle = self.db.execute_and_wait(query)
+    xls_resp = download(handle, 'xls', self.db)
     translated_csv = xls2csv(xls_resp.content)
     # It should have 257 lines (256 + header)
     assert_equal(len(translated_csv.strip('\r\n').split('\r\n')), 257)
-    handle = beeswax.db_utils.db_client(get_query_server()).query(query_msg)
-    query_data.server_host = beeswax.conf.QUERY_SERVERS['default'].SERVER_HOST.get() # Needed as we query directly
-    query_data.server_port = beeswax.conf.QUERY_SERVERS['default'].SERVER_PORT.get()
+
     # Get the result in csv.
-    csv_resp = beeswax.data_export.download(query_data, 'csv')
+    query = hql_query(hql)
+    handle = self.db.execute_and_wait(query)
+    csv_resp = download(handle, 'csv', self.db)
     assert_equal(csv_resp.content, translated_csv)
 
   def test_designs(self):
@@ -541,8 +530,7 @@ for x in sys.stdin:
 
     resp = cli.get('/beeswax/list_designs')
     nplus_designs = len(resp.context['page'].object_list)
-    assert_true(nplus_designs == n_designs,
-                'Auto design should not show up in list_designs')
+    assert_true(nplus_designs == n_designs, 'Auto design should not show up in list_designs')
 
     # Test explicit save
     query = 'MORE BOGUS JUNKS FROM test'
@@ -1043,16 +1031,16 @@ for x in sys.stdin:
 
     # Check data is in the table (by describing it)
     resp = self.client.get('/beeswax/table/test_create_import')
-    sd = resp.context['table'].sd
-    assert_equal(len(sd.cols), 3)
-    assert_equal([ col.name for col in sd.cols ], [ 'col_a', 'col_b', 'col_c' ])
+    cols = resp.context['table'].cols
+    assert_equal(len(cols), 3)
+    assert_equal([ col.name for col in cols ], [ 'col_a', 'col_b', 'col_c' ])
     assert_true("<td>nada</td>" in resp.content)
     assert_true("<td>sp ace</td>" in resp.content)
 
   def test_describe_view(self):
     resp = self.client.get('/beeswax/table/myview')
-    assert_equal(None, resp.context['top_rows'])
-    assert_true(resp.context['is_view'])
+    assert_equal(None, resp.context['sample'])
+    assert_true(resp.context['table'].is_view)
     assert_true("View Metadata" in resp.content)
     assert_true("Drop View" in resp.content)
 
@@ -1092,8 +1080,8 @@ def test_import_gzip_reader():
 
 def test_parse_results():
   data = ["foo\tbar", "baz\tboom"]
-  assert_equal([["foo", "bar"], ["baz", "boom"]],
-    [ x for x in parse_results(data) ])
+  results = type('Result', (object,), {'has_more': False, 'start_row': False, 'columns': False, 'data': data})
+  assert_equal([["foo", "bar"], ["baz", "boom"]], [ x for x in list(BeeswaxDataTable(results).rows()) ])
 
 
 def test_index_page():
@@ -1135,12 +1123,12 @@ def test_strip_trailing_semicolon():
   # in this file that use semicolons all the way through.
 
   # Single semicolon
-  assert_equal("foo", beeswax.views._strip_trailing_semicolon("foo;\n"))
-  assert_equal("foo\n", beeswax.views._strip_trailing_semicolon("foo\n;\n\n\n"))
+  assert_equal("foo", _strip_trailing_semicolon("foo;\n"))
+  assert_equal("foo\n", _strip_trailing_semicolon("foo\n;\n\n\n"))
   # Multiple semicolons: strip only last one
-  assert_equal("fo;o;", beeswax.views._strip_trailing_semicolon("fo;o;;     "))
+  assert_equal("fo;o;", _strip_trailing_semicolon("fo;o;;     "))
   # No semicolons
-  assert_equal("foo", beeswax.views._strip_trailing_semicolon("foo"))
+  assert_equal("foo", _strip_trailing_semicolon("foo"))
 
 def test_hadoop_extraction():
   sample_log = """

+ 37 - 28
apps/beeswax/src/beeswax/urls.py

@@ -17,32 +17,41 @@
 
 from django.conf.urls.defaults import patterns, url
 
-urlpatterns = patterns('beeswax',
-  url(r'^$', 'views.index'),
-  url(r'^tables$', 'views.show_tables'),
-  url(r'^table/(?P<table>\w+)$', 'views.describe_table'),
-  url(r'^table/(?P<table>\w+)/partitions$', 'views.describe_partitions'),
-  url(r'^table/(?P<table>\w+)/load$', 'views.load_table'),
-  url(r'^table/(?P<table>\w+)/read$', 'views.read_table'),
-  url(r'^table/(?P<table>\w+)/drop$', 'views.drop_table'),
-  url(r'^create$', 'create_table.index'),
-  url(r'^create/create_table$', 'create_table.create_table'),
-  url(r'^create/import_wizard$', 'create_table.import_wizard'),
-  url(r'^create/auto_load$', 'create_table.load_after_create'),
-  url(r'^execute$', 'views.execute_query'),
-  url(r'^execute/(?P<design_id>\d+)$', 'views.execute_query'),
-  url(r'^explain_parameterized/(?P<design_id>\d+)$', 'views.explain_parameterized_query'),
-  url(r'^execute_parameterized/(?P<design_id>\d+)$', 'views.execute_parameterized_query'),
-  url(r'^my_queries$', 'views.my_queries'),
-  url(r'^list_designs$', 'views.list_designs'),
-  url(r'^delete_design/(?P<design_id>\d+)$', 'views.delete_design'),
-  url(r'^clone_design/(?P<design_id>\d+)$', 'views.clone_design'),
-  url(r'^query_history$', 'views.list_query_history'),
-  url(r'^watch/(?P<id>\d+)$', 'views.watch_query'),
-  url(r'^results/(?P<id>\d+)/(?P<first_row>\d+)$', 'views.view_results'),
-  url(r'^download/(?P<id>\d+)/(?P<format>\w+)$', 'views.download'),
-  url(r'^configuration$', 'views.configuration'),
-  url(r'^install_examples$', 'views.install_examples'),
-  url(r'^save_results/(?P<id>\d+)$', 'views.save_results'),
-  url(r'^query_cb/done/(?P<server_id>\S+)$', 'views.query_done_cb'),
+urlpatterns = patterns('beeswax.views',
+  url(r'^$', 'index'),
+
+  url(r'^tables$', 'show_tables'),
+  url(r'^table/(?P<table>\w+)$', 'describe_table'),
+  url(r'^table/(?P<table>\w+)/partitions$', 'describe_partitions'),
+  url(r'^table/(?P<table>\w+)/load$', 'load_table'),
+  url(r'^table/(?P<table>\w+)/read$', 'read_table'),
+  url(r'^table/(?P<table>\w+)/drop$', 'drop_table'),
+
+  url(r'^execute$', 'execute_query'),
+  url(r'^execute/(?P<design_id>\d+)$', 'execute_query'),
+  url(r'^explain_parameterized/(?P<design_id>\d+)$', 'explain_parameterized_query'),
+  url(r'^execute_parameterized/(?P<design_id>\d+)$', 'execute_parameterized_query'),
+  url(r'^watch/(?P<id>\d+)$', 'watch_query'),
+  url(r'^results/(?P<id>\d+)/(?P<first_row>\d+)$', 'view_results'),
+  url(r'^download/(?P<id>\d+)/(?P<format>\w+)$', 'download'),
+  url(r'^save_results/(?P<id>\d+)$', 'save_results'),
+
+  url(r'^my_queries$', 'my_queries'),
+  url(r'^list_designs$', 'list_designs'),
+  url(r'^delete_design/(?P<design_id>\d+)$', 'delete_design'),
+  url(r'^clone_design/(?P<design_id>\d+)$', 'clone_design'),
+  url(r'^query_history$', 'list_query_history'),
+
+  url(r'^configuration$', 'configuration'),
+  url(r'^install_examples$', 'install_examples'),
+  url(r'^query_cb/done/(?P<server_id>\S+)$', 'query_done_cb'),
+)
+
+urlpatterns += patterns(
+  'beeswax.create_table',
+
+  url(r'^create$', 'index'),
+  url(r'^create/create_table$', 'create_table'),
+  url(r'^create/import_wizard$', 'import_wizard'),
+  url(r'^create/auto_load$', 'load_after_create'),
 )

File diff suppressed because it is too large
+ 632 - 519
apps/beeswax/src/beeswax/views.py


+ 992 - 0
apps/beeswax/thrift/cli_service.thrift

@@ -0,0 +1,992 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Coding Conventions for this file:
+//
+// Structs and Unions
+// * Struct and union names begin with a "T", and use a capital letter for
+//   each new word, with no underscores.
+// * All fields should be declared as either optional or required.
+//
+// Functions
+// * Function names start with a capital letter and have a capital letter for
+//   each new word, with no underscores.
+// * Each function should take exactly one parameter, named FunctionNameReq,
+//   and should return either void or FunctionNameResp. This convention allows
+//   incremental updates.
+//
+// Services
+// * Service names should end in the word "Service".
+
+namespace java org.apache.hive.service.cli.thrift
+namespace cpp apache.hive.service.cli.thrift
+
+// List of protocol versions. A new token should be
+// added to the end of this list every time a change is made.
+enum TProtocolVersion {
+  HIVE_CLI_SERVICE_PROTOCOL_V1
+}
+
+enum TType {
+  BOOLEAN_TYPE,
+  TINYINT_TYPE,
+  SMALLINT_TYPE,
+  INT_TYPE,
+  BIGINT_TYPE,
+  FLOAT_TYPE,
+  DOUBLE_TYPE,
+  STRING_TYPE,
+  TIMESTAMP_TYPE,
+  BINARY_TYPE,
+  ARRAY_TYPE,
+  MAP_TYPE,
+  STRUCT_TYPE,
+  UNION_TYPE,
+  USER_DEFINED_TYPE
+}
+  
+const set<TType> PRIMITIVE_TYPES = [
+  TType.BOOLEAN_TYPE
+  TType.TINYINT_TYPE
+  TType.SMALLINT_TYPE
+  TType.INT_TYPE
+  TType.BIGINT_TYPE
+  TType.FLOAT_TYPE
+  TType.DOUBLE_TYPE
+  TType.STRING_TYPE
+  TType.TIMESTAMP_TYPE
+  TType.BINARY_TYPE
+]
+
+const set<TType> COMPLEX_TYPES = [
+  TType.ARRAY_TYPE
+  TType.MAP_TYPE
+  TType.STRUCT_TYPE
+  TType.UNION_TYPE
+  TType.USER_DEFINED_TYPE
+]
+
+const set<TType> COLLECTION_TYPES = [
+  TType.ARRAY_TYPE
+  TType.MAP_TYPE
+]
+
+const map<TType,string> TYPE_NAMES = {
+  TType.BOOLEAN_TYPE: "BOOLEAN",
+  TType.TINYINT_TYPE: "TINYINT",
+  TType.SMALLINT_TYPE: "SMALLINT",
+  TType.INT_TYPE: "INT",
+  TType.BIGINT_TYPE: "BIGINT",
+  TType.FLOAT_TYPE: "FLOAT",
+  TType.DOUBLE_TYPE: "DOUBLE",
+  TType.STRING_TYPE: "STRING",
+  TType.TIMESTAMP_TYPE: "TIMESTAMP",
+  TType.BINARY_TYPE: "BINARY",
+  TType.ARRAY_TYPE: "ARRAY",
+  TType.MAP_TYPE: "MAP",
+  TType.STRUCT_TYPE: "STRUCT",
+  TType.UNION_TYPE: "UNIONTYPE"
+}
+
+// Thrift does not support recursively defined types or forward declarations,
+// which makes it difficult to represent Hive's nested types.
+// To get around these limitations TTypeDesc employs a type list that maps
+// integer "pointers" to TTypeEntry objects. The following examples show
+// how different types are represented using this scheme:
+//
+// "INT":
+// TTypeDesc {
+//   types = [
+//     TTypeEntry.primitive_entry {
+//       type = INT_TYPE
+//     }
+//   ]
+// }
+//
+// "ARRAY<INT>":
+// TTypeDesc {
+//   types = [
+//     TTypeEntry.array_entry {
+//       object_type_ptr = 1
+//     },
+//     TTypeEntry.primitive_entry {
+//       type = INT_TYPE
+//     }
+//   ]
+// }
+//
+// "MAP<INT,STRING>":
+// TTypeDesc {
+//   types = [
+//     TTypeEntry.map_entry {
+//       key_type_ptr = 1
+//       value_type_ptr = 2
+//     },
+//     TTypeEntry.primitive_entry {
+//       type = INT_TYPE
+//     },
+//     TTypeEntry.primitive_entry {
+//       type = STRING_TYPE
+//     }
+//   ]
+// }
+
+typedef i32 TTypeEntryPtr
+
+// Type entry for a primitive type.
+struct TPrimitiveTypeEntry {
+  // The primitive type token. This must satisfy the condition
+  // that type is in the PRIMITIVE_TYPES set.
+  1: required TType type
+}
+
+// Type entry for an ARRAY type.
+struct TArrayTypeEntry {
+  1: required TTypeEntryPtr objectTypePtr
+}
+
+// Type entry for a MAP type.
+struct TMapTypeEntry {
+  1: required TTypeEntryPtr keyTypePtr
+  2: required TTypeEntryPtr valueTypePtr
+}
+
+// Type entry for a STRUCT type.
+struct TStructTypeEntry {
+  1: required map<string, TTypeEntryPtr> nameToTypePtr
+}
+
+// Type entry for a UNIONTYPE type.
+struct TUnionTypeEntry {
+  1: required map<string, TTypeEntryPtr> nameToTypePtr
+}
+
+struct TUserDefinedTypeEntry {
+  // The fully qualified name of the class implementing this type.
+  1: required string typeClassName
+}
+
+// We use a union here since Thrift does not support inheritance.
+union TTypeEntry {
+  1: TPrimitiveTypeEntry primitiveEntry
+  2: TArrayTypeEntry arrayEntry
+  3: TMapTypeEntry mapEntry
+  4: TStructTypeEntry structEntry
+  5: TUnionTypeEntry unionEntry
+  6: TUserDefinedTypeEntry userDefinedTypeEntry
+}
+
+// Type descriptor for columns.
+struct TTypeDesc {
+  // The "top" type is always the first element of the list.
+  // If the top type is an ARRAY, MAP, STRUCT, or UNIONTYPE
+  // type, then subsequent elements represent nested types.
+  1: required list<TTypeEntry> types
+}
+
+// A result set column descriptor.
+struct TColumnDesc {
+  // The name of the column
+  1: required string columnName
+
+  // The type descriptor for this column
+  2: required TTypeDesc typeDesc
+  
+  // The ordinal position of this column in the schema
+  3: required i32 position
+
+  4: optional string comment
+}
+
+// Metadata used to describe the schema (column names, types, comments)
+// of result sets.
+struct TTableSchema {
+  1: required list<TColumnDesc> columns
+}
+
+// A Boolean column value.
+struct TBoolValue {
+  // NULL if value is unset.
+  1: optional bool value
+}
+
+// A Byte column value.
+struct TByteValue {
+  // NULL if value is unset.
+  1: optional byte value
+}
+
+// A signed, 16 bit column value.
+struct TI16Value {
+  // NULL if value is unset
+  1: optional i16 value
+}
+
+// A signed, 32 bit column value
+struct TI32Value {
+  // NULL if value is unset
+  1: optional i32 value
+}
+
+// A signed 64 bit column value
+struct TI64Value {
+  // NULL if value is unset
+  1: optional i64 value
+}
+
+// A floating point 64 bit column value
+struct TDoubleValue {
+  // NULL if value is unset
+  1: optional double value
+}
+
+struct TStringValue {
+  1: optional string value
+}
+
+union TColumn {
+  1: list<TBoolValue> boolColumn
+  2: list<TByteValue> byteColumn
+  3: list<TI16Value> i16Column
+  4: list<TI32Value> i32Column
+  5: list<TI64Value> i64Column
+  6: list<TDoubleValue> doubleColumn
+  7: list<TStringValue> stringColumn
+}
+
+// A single column value in a result set.
+// Note that Hive's type system is richer than Thrift's,
+// so in some cases we have to map multiple Hive types
+// to the same Thrift type. On the client-side this is
+// disambiguated by looking at the Schema of the
+// result set.
+union TColumnValue {
+  1: TBoolValue   boolVal      // BOOLEAN
+  2: TByteValue   byteVal      // TINYINT
+  3: TI16Value    i16Val       // SMALLINT
+  4: TI32Value    i32Val       // INT
+  5: TI64Value    i64Val       // BIGINT, TIMESTAMP
+  6: TDoubleValue doubleVal    // FLOAT, DOUBLE
+  7: TStringValue stringVal    // STRING, LIST, MAP, STRUCT, UNIONTYPE, BINARY
+}
+
+// Represents a row in a rowset.
+struct TRow {
+  1: required list<TColumnValue> colVals
+}
+
+// Represents a rowset
+struct TRowSet {
+  // The starting row offset of this rowset.
+  1: required i64 startRowOffset
+  2: required list<TRow> rows
+  3: optional list<TColumn> columns
+}
+
+// The return status code contained in each response.
+enum TStatusCode {
+  SUCCESS_STATUS,
+  SUCCESS_WITH_INFO_STATUS,
+  STILL_EXECUTING_STATUS,
+  ERROR_STATUS,
+  INVALID_HANDLE_STATUS
+}
+
+// The return status of a remote request
+struct TStatus {
+  1: required TStatusCode statusCode
+
+  // If status is SUCCESS_WITH_INFO, info_msgs may be populated with
+  // additional diagnostic information.
+  2: optional list<string> infoMessages
+
+  // If status is ERROR, then the following fields may be set
+  3: optional string sqlState  // as defined in the ISO/IEF CLI specification
+  4: optional i32 errorCode    // internal error code
+  5: optional string errorMessage
+}
+
+// The state of an operation (i.e. a query or other
+// asynchronous operation that generates a result set)
+// on the server.
+enum TOperationState {
+  // The operation has been initialized
+  INITIALIZED_STATE,
+
+  // The operation is running. In this state the result
+  // set is not available.
+  RUNNING_STATE,
+
+  // The operation has completed. When an operation is in
+  // this state its result set may be fetched.
+  FINISHED_STATE,
+
+  // The operation was canceled by a client
+  CANCELED_STATE,
+
+  // The operation was closed by a client
+  CLOSED_STATE,
+
+  // The operation failed due to an error
+  ERROR_STATE,
+
+  // The operation is in an unrecognized state
+  UKNOWN_STATE,
+}
+
+
+// A string identifier. This is interpreted literally.
+typedef string TIdentifier
+
+// A search pattern.
+//
+// Valid search pattern characters:
+// '_': Any single character.
+// '%': Any sequence of zero or more characters.
+// '\': Escape character used to include special characters,
+//      e.g. '_', '%', '\'. If a '\' precedes a non-special
+//      character it has no special meaning and is interpreted
+//      literally.
+typedef string TPattern
+
+
+// A search pattern or identifier. Used as input
+// parameter for many of the catalog functions.
+typedef string TPatternOrIdentifier
+
+struct THandleIdentifier {
+  // 16 byte globally unique identifier
+  // This is the public ID of the handle and
+  // can be used for reporting.
+  1: required binary guid,
+
+  // 16 byte secret generated by the server
+  // and used to verify that the handle is not
+  // being hijacked by another user.
+  2: required binary secret,
+}
+
+// Client-side handle to persistent
+// session information on the server-side.
+struct TSessionHandle {
+  1: required THandleIdentifier sessionId
+}
+
+// The subtype of an OperationHandle.
+enum TOperationType {
+  EXECUTE_STATEMENT,
+  GET_TYPE_INFO,
+  GET_CATALOGS,
+  GET_SCHEMAS,
+  GET_TABLES,
+  GET_TABLE_TYPES,
+  GET_COLUMNS,
+  GET_FUNCTIONS,
+  UNKNOWN,
+}
+
+// Client-side reference to a task running
+// asynchronously on the server.
+struct TOperationHandle {
+  1: required THandleIdentifier operationId
+  2: required TOperationType operationType
+
+  // If hasResultSet = TRUE, then this operation
+  // generates a result set that can be fetched.
+  // Note that the result set may be empty.
+  //
+  // If hasResultSet = FALSE, then this operation
+  // does not generate a result set, and calling
+  // GetResultSetMetadata or FetchResults against
+  // this OperationHandle will generate an error.
+  3: required bool hasResultSet
+
+  // For operations that don't generate result sets,
+  // modifiedRowCount is either:
+  //
+  // 1) The number of rows that were modified by
+  //    the DML operation (e.g. number of rows inserted,
+  //    number of rows deleted, etc).
+  //
+  // 2) 0 for operations that don't modify or add rows.
+  //
+  // 3) < 0 if the operation is capable of modifiying rows,
+  //    but Hive is unable to determine how many rows were
+  //    modified. For example, Hive's LOAD DATA command
+  //    doesn't generate row count information because
+  //    Hive doesn't inspect the data as it is loaded.
+  //
+  // modifiedRowCount is unset if the operation generates
+  // a result set.
+  4: optional double modifiedRowCount
+}
+
+
+// OpenSession()
+//
+// Open a session (connection) on the server against
+// which operations may be executed. 
+struct TOpenSessionReq {
+  // The version of the HiveServer2 protocol that the client is using.
+  1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1
+  
+  // Username and password for authentication.
+  // Depending on the authentication scheme being used,
+  // this information may instead be provided by a lower
+  // protocol layer, in which case these fields may be
+  // left unset.
+  2: optional string username
+  3: optional string password
+
+  // Configuration overlay which is applied when the session is
+  // first created.
+  4: optional map<string, string> configuration
+}
+
+struct TOpenSessionResp {
+  1: required TStatus status
+
+  // The protocol version that the server is using.
+  2: required TProtocolVersion serverProtocolVersion = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1
+
+  // Session Handle
+  3: optional TSessionHandle sessionHandle
+
+  // The configuration settings for this session.
+  4: optional map<string, string> configuration
+}
+
+
+// CloseSession()
+//
+// Closes the specified session and frees any resources
+// currently allocated to that session. Any open
+// operations in that session will be canceled.
+struct TCloseSessionReq {
+  1: required TSessionHandle sessionHandle
+}
+
+struct TCloseSessionResp {
+  1: required TStatus status
+}
+
+
+
+enum TGetInfoType {
+  CLI_MAX_DRIVER_CONNECTIONS =           0,
+  CLI_MAX_CONCURRENT_ACTIVITIES =        1,
+  CLI_DATA_SOURCE_NAME =                 2,
+  CLI_FETCH_DIRECTION =                  8,
+  CLI_SERVER_NAME =                      13,
+  CLI_SEARCH_PATTERN_ESCAPE =            14,
+  CLI_DBMS_NAME =                        17,
+  CLI_DBMS_VER =                         18,
+  CLI_ACCESSIBLE_TABLES =                19,
+  CLI_ACCESSIBLE_PROCEDURES =            20,
+  CLI_CURSOR_COMMIT_BEHAVIOR =           23,
+  CLI_DATA_SOURCE_READ_ONLY =            25,
+  CLI_DEFAULT_TXN_ISOLATION =            26,
+  CLI_IDENTIFIER_CASE =                  28,
+  CLI_IDENTIFIER_QUOTE_CHAR =            29,
+  CLI_MAX_COLUMN_NAME_LEN =              30,
+  CLI_MAX_CURSOR_NAME_LEN =              31,
+  CLI_MAX_SCHEMA_NAME_LEN =              32,
+  CLI_MAX_CATALOG_NAME_LEN =             34,
+  CLI_MAX_TABLE_NAME_LEN =               35,
+  CLI_SCROLL_CONCURRENCY =               43,
+  CLI_TXN_CAPABLE =                      46,
+  CLI_USER_NAME =                        47,
+  CLI_TXN_ISOLATION_OPTION =             72,
+  CLI_INTEGRITY =                        73,
+  CLI_GETDATA_EXTENSIONS =               81,
+  CLI_NULL_COLLATION =                   85,
+  CLI_ALTER_TABLE =                      86,
+  CLI_ORDER_BY_COLUMNS_IN_SELECT =       90,
+  CLI_SPECIAL_CHARACTERS =               94,
+  CLI_MAX_COLUMNS_IN_GROUP_BY =          97,
+  CLI_MAX_COLUMNS_IN_INDEX =             98,
+  CLI_MAX_COLUMNS_IN_ORDER_BY =          99,
+  CLI_MAX_COLUMNS_IN_SELECT =            100,
+  CLI_MAX_COLUMNS_IN_TABLE =             101,
+  CLI_MAX_INDEX_SIZE =                   102,
+  CLI_MAX_ROW_SIZE =                     104,
+  CLI_MAX_STATEMENT_LEN =                105,
+  CLI_MAX_TABLES_IN_SELECT =             106,
+  CLI_MAX_USER_NAME_LEN =                107,
+  CLI_OJ_CAPABILITIES =                  115,
+
+  CLI_XOPEN_CLI_YEAR =                   10000,
+  CLI_CURSOR_SENSITIVITY =               10001,
+  CLI_DESCRIBE_PARAMETER =               10002,
+  CLI_CATALOG_NAME =                     10003,
+  CLI_COLLATION_SEQ =                    10004,
+  CLI_MAX_IDENTIFIER_LEN =               10005,
+}
+
+union TGetInfoValue {
+  1: string stringValue
+  2: i16 smallIntValue
+  3: i32 integerBitmask
+  4: i32 integerFlag
+  5: i32 binaryValue
+  6: i64 lenValue
+}
+
+// GetInfo()
+//
+// This function is based on ODBC's CLIGetInfo() function.
+// The function returns general information about the data source
+// using the same keys as ODBC.
+struct TGetInfoReq {
+  // The sesssion to run this request against
+  1: required TSessionHandle sessionHandle
+
+  2: required TGetInfoType infoType
+}
+
+struct TGetInfoResp {
+  1: required TStatus status
+
+  2: required TGetInfoValue infoValue
+}
+
+
+// ExecuteStatement()
+//
+// Execute a statement.
+// The returned OperationHandle can be used to check on the
+// status of the statement, and to fetch results once the
+// statement has finished executing.
+struct TExecuteStatementReq {
+  // The session to exexcute the statement against
+  1: required TSessionHandle sessionHandle
+
+  // The statement to be executed (DML, DDL, SET, etc)
+  2: required string statement
+
+  // Configuration properties that are overlayed on top of the
+  // the existing session configuration before this statement
+  // is executed. These properties apply to this statement
+  // only and will not affect the subsequent state of the Session.
+  3: optional map<string, string> confOverlay
+}
+
+struct TExecuteStatementResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+
+
+// GetTypeInfo()
+//
+// Get information about types supported by the HiveServer instance.
+// The information is returned as a result set which can be fetched
+// using the OperationHandle provided in the response.
+//
+// Refer to the documentation for ODBC's CLIGetTypeInfo function for
+// the format of the result set.
+struct TGetTypeInfoReq {
+  // The session to run this request against.
+  1: required TSessionHandle sessionHandle
+}
+
+struct TGetTypeInfoResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}  
+
+
+// GetCatalogs()
+//
+// Returns the list of catalogs (databases) 
+// Results are ordered by TABLE_CATALOG 
+//
+// Resultset columns :
+// col1
+// name: TABLE_CAT
+// type: STRING
+// desc: Catalog name. NULL if not applicable.
+//
+struct TGetCatalogsReq {
+  // Session to run this request against
+  1: required TSessionHandle sessionHandle
+}
+
+struct TGetCatalogsResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+
+
+// GetSchemas()
+//
+// Retrieves the schema names available in this database. 
+// The results are ordered by TABLE_CATALOG and TABLE_SCHEM.
+// col1
+// name: TABLE_SCHEM
+// type: STRING
+// desc: schema name
+// col2
+// name: TABLE_CATALOG
+// type: STRING
+// desc: catalog name
+struct TGetSchemasReq {
+  // Session to run this request against
+  1: required TSessionHandle sessionHandle
+
+  // Name of the catalog. Must not contain a search pattern.
+  2: optional TIdentifier catalogName
+
+  // schema name or pattern
+  3: optional TPatternOrIdentifier schemaName
+}
+
+struct TGetSchemasResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+
+
+// GetTables()
+//
+// Returns a list of tables with catalog, schema, and table
+// type information. The information is returned as a result
+// set which can be fetched using the OperationHandle
+// provided in the response.
+// Results are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM, and TABLE_NAME
+//
+// Result Set Columns:
+//
+// col1
+// name: TABLE_CAT
+// type: STRING
+// desc: Catalog name. NULL if not applicable.
+//
+// col2
+// name: TABLE_SCHEM
+// type: STRING
+// desc: Schema name.
+//
+// col3
+// name: TABLE_NAME
+// type: STRING
+// desc: Table name.
+//
+// col4
+// name: TABLE_TYPE
+// type: STRING
+// desc: The table type, e.g. "TABLE", "VIEW", etc.
+//
+// col5
+// name: REMARKS
+// type: STRING
+// desc: Comments about the table
+//
+struct TGetTablesReq {
+  // Session to run this request against
+  1: required TSessionHandle sessionHandle
+
+  // Name of the catalog or a search pattern.
+  2: optional TPatternOrIdentifier catalogName
+
+  // Name of the schema or a search pattern.
+  3: optional TPatternOrIdentifier schemaName
+
+  // Name of the table or a search pattern.
+  4: optional TPatternOrIdentifier tableName
+
+  // List of table types to match
+  // e.g. "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+  // "LOCAL TEMPORARY", "ALIAS", "SYNONYM", etc.
+  5: optional list<string> tableTypes
+}
+
+struct TGetTablesResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+
+
+// GetTableTypes()
+//
+// Returns the table types available in this database. 
+// The results are ordered by table type. 
+// 
+// col1
+// name: TABLE_TYPE
+// type: STRING
+// desc: Table type name.
+struct TGetTableTypesReq {
+  // Session to run this request against
+  1: required TSessionHandle sessionHandle
+}
+
+struct TGetTableTypesResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+
+
+// GetColumns()
+//
+// Returns a list of columns in the specified tables.
+// The information is returned as a result set which can be fetched
+// using the OperationHandle provided in the response.
+// Results are ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, 
+// and ORDINAL_POSITION. 
+//
+// Result Set Columns are the same as those for the ODBC CLIColumns
+// function.
+//
+struct TGetColumnsReq {
+  // Session to run this request against
+  1: required TSessionHandle sessionHandle
+
+  // Name of the catalog. Must not contain a search pattern.
+  2: optional TIdentifier catalogName
+
+  // Schema name or search pattern
+  3: optional TPatternOrIdentifier schemaName
+
+  // Table name or search pattern
+  4: optional TPatternOrIdentifier tableName
+
+  // Column name or search pattern
+  5: optional TPatternOrIdentifier columnName
+}
+
+struct TGetColumnsResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+
+
+// GetFunctions()
+//
+// Returns a list of functions supported by the data source. The
+// behavior of this function matches
+// java.sql.DatabaseMetaData.getFunctions() both in terms of
+// inputs and outputs.
+//
+// Result Set Columns:
+//
+// col1
+// name: FUNCTION_CAT
+// type: STRING
+// desc: Function catalog (may be null)
+//
+// col2
+// name: FUNCTION_SCHEM
+// type: STRING
+// desc: Function schema (may be null)
+//
+// col3
+// name: FUNCTION_NAME
+// type: STRING
+// desc: Function name. This is the name used to invoke the function.
+//
+// col4
+// name: REMARKS
+// type: STRING
+// desc: Explanatory comment on the function.
+//
+// col5
+// name: FUNCTION_TYPE
+// type: SMALLINT
+// desc: Kind of function. One of:
+//       * functionResultUnknown - Cannot determine if a return value or a table
+//                                 will be returned.
+//       * functionNoTable       - Does not a return a table.
+//       * functionReturnsTable  - Returns a table.
+//
+// col6
+// name: SPECIFIC_NAME
+// type: STRING
+// desc: The name which uniquely identifies this function within its schema.
+//       In this case this is the fully qualified class name of the class
+//       that implements this function.
+//
+struct TGetFunctionsReq {
+  // Session to run this request against
+  1: required TSessionHandle sessionHandle
+
+  // A catalog name; must match the catalog name as it is stored in the
+  // database; "" retrieves those without a catalog; null means
+  // that the catalog name should not be used to narrow the search.
+  2: optional TIdentifier catalogName
+
+  // A schema name pattern; must match the schema name as it is stored
+  // in the database; "" retrieves those without a schema; null means
+  // that the schema name should not be used to narrow the search.
+  3: optional TPatternOrIdentifier schemaName
+
+  // A function name pattern; must match the function name as it is stored
+  // in the database.
+  4: required TPatternOrIdentifier functionName
+}
+
+struct TGetFunctionsResp {
+  1: required TStatus status
+  2: optional TOperationHandle operationHandle
+}
+  
+
+// GetOperationStatus()
+//
+// Get the status of an operation running on the server.
+struct TGetOperationStatusReq {
+  // Session to run this request against
+  1: required TOperationHandle operationHandle
+}
+
+struct TGetOperationStatusResp {
+  1: required TStatus status
+  2: optional TOperationState operationState
+}
+
+
+// CancelOperation()
+//
+// Cancels processing on the specified operation handle and
+// frees any resources which were allocated.
+struct TCancelOperationReq {
+  // Operation to cancel
+  1: required TOperationHandle operationHandle
+}
+
+struct TCancelOperationResp {
+  1: required TStatus status
+}
+
+
+// CloseOperation()
+//
+// Given an operation in the FINISHED, CANCELED,
+// or ERROR states, CloseOperation() will free
+// all of the resources which were allocated on
+// the server to service the operation.
+struct TCloseOperationReq {
+  1: required TOperationHandle operationHandle
+}
+
+struct TCloseOperationResp {
+  1: required TStatus status
+}
+
+
+// GetResultSetMetadata()
+//
+// Retrieves schema information for the specified operation
+struct TGetResultSetMetadataReq {
+  // Operation for which to fetch result set schema information
+  1: required TOperationHandle operationHandle
+}
+
+struct TGetResultSetMetadataResp {
+  1: required TStatus status
+  2: optional TTableSchema schema
+}
+
+
+enum TFetchOrientation {
+  // Get the next rowset. The fetch offset is ignored.
+  FETCH_NEXT,
+
+  // Get the previous rowset. The fetch offset is ignored.
+  // NOT SUPPORTED
+  FETCH_PRIOR,
+
+  // Return the rowset at the given fetch offset relative
+  // to the curren rowset.
+  // NOT SUPPORTED
+  FETCH_RELATIVE,
+
+  // Return the rowset at the specified fetch offset.
+  // NOT SUPPORTED
+  FETCH_ABSOLUTE,
+
+  // Get the first rowset in the result set.
+  FETCH_FIRST,
+
+  // Get the last rowset in the result set.
+  // NOT SUPPORTED
+  FETCH_LAST
+}
+
+// FetchResults()
+//
+// Fetch rows from the server corresponding to
+// a particular OperationHandle.
+struct TFetchResultsReq {
+  // Operation from which to fetch results.
+  1: required TOperationHandle operationHandle
+
+  // The fetch orientation. For V1 this must be either
+  // FETCH_NEXT or FETCH_FIRST. Defaults to FETCH_NEXT.
+  2: required TFetchOrientation orientation = TFetchOrientation.FETCH_NEXT
+  
+  // Max number of rows that should be returned in
+  // the rowset.
+  3: required i64 maxRows
+}
+
+struct TFetchResultsResp {
+  1: required TStatus status
+
+  // TRUE if there are more rows left to fetch from the server.
+  2: optional bool hasMoreRows
+
+  // The rowset. This is optional so that we have the
+  // option in the future of adding alternate formats for
+  // representing result set data, e.g. delimited strings,
+  // binary encoded, etc.
+  3: optional TRowSet results
+}
+
+service TCLIService {
+
+  TOpenSessionResp OpenSession(1:TOpenSessionReq req);
+
+  TCloseSessionResp CloseSession(1:TCloseSessionReq req);
+
+  TGetInfoResp GetInfo(1:TGetInfoReq req);
+
+  TExecuteStatementResp ExecuteStatement(1:TExecuteStatementReq req);
+
+  TGetTypeInfoResp GetTypeInfo(1:TGetTypeInfoReq req);
+
+  TGetCatalogsResp GetCatalogs(1:TGetCatalogsReq req);
+
+  TGetSchemasResp GetSchemas(1:TGetSchemasReq req);
+
+  TGetTablesResp GetTables(1:TGetTablesReq req);
+
+  TGetTableTypesResp GetTableTypes(1:TGetTableTypesReq req);
+
+  TGetColumnsResp GetColumns(1:TGetColumnsReq req);
+
+  TGetFunctionsResp GetFunctions(1:TGetFunctionsReq req);
+
+  TGetOperationStatusResp GetOperationStatus(1:TGetOperationStatusReq req);
+  
+  TCancelOperationResp CancelOperation(1:TCancelOperationReq req);
+
+  TCloseOperationResp CloseOperation(1:TCloseOperationReq req);
+
+  TGetResultSetMetadataResp GetResultSetMetadata(1:TGetResultSetMetadataReq req);
+  
+  TFetchResultsResp FetchResults(1:TFetchResultsReq req);
+}

+ 2 - 2
apps/filebrowser/src/filebrowser/views.py

@@ -1173,7 +1173,7 @@ def status(request):
     return render("status.mako", request, data)
 
 
-def location_to_url(request, location, strict=True):
+def location_to_url(location, strict=True):
     """
     If possible, returns a file browser URL to the location.
     Location is a URI, if strict is True.
@@ -1183,7 +1183,7 @@ def location_to_url(request, location, strict=True):
     """
     if location is None:
       return None
-    split_path = request.fs.urlsplit(location)
+    split_path = Hdfs.urlsplit(location)
     if strict and not split_path[1]:
       # No netloc, not full url
       return None

+ 3 - 3
apps/jobbrowser/src/jobbrowser/templates/job.mako

@@ -71,7 +71,7 @@
                     else:
                       target = "FileBrowser"
                 %>
-                    <a href="${location_to_url(request, val)}" title="${val}" target="${target}">${val}</a>
+                    <a href="${location_to_url(val)}" title="${val}" target="${target}">${val}</a>
                 % if i != len(splitArray) - 1:
                         <br>
                 % endif
@@ -117,7 +117,7 @@ ${commonheader(_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId), "jobbr
 
                     <%
                         output_dir = job.conf_keys.get('mapredOutputDir', "")
-                        location_url = location_to_url(request, output_dir)
+                        location_url = location_to_url(output_dir)
                         basename = os.path.basename(output_dir)
                         dir_name = basename.split('/')[-1]
                     %>
@@ -126,7 +126,7 @@ ${commonheader(_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId), "jobbr
                         <li>
                         <%
                             output_dir = job.conf_keys.get('mapredOutputDir', "")
-                            location_url = location_to_url(request, output_dir)
+                            location_url = location_to_url(output_dir)
                             basename = os.path.basename(output_dir)
                             dir_name = basename.split('/')[-1]
                         %>

+ 2 - 1
apps/jobbrowser/src/jobbrowser/views.py

@@ -109,8 +109,9 @@ def jobs(request):
   state = request.GET.get('state', 'all')
   text = request.GET.get('text', '')
   retired = request.GET.get('retired', '')
+
   return render("jobs.mako", request, {
-    'jobs':matching_jobs,
+    'jobs': matching_jobs,
     'request': request,
     'state_filter': state,
     'user_filter': user,

+ 4 - 0
desktop/conf.dist/hue.ini

@@ -359,6 +359,10 @@
   # visible only to the owner and administrators.
   ## share_saved_queries=true
 
+  # The backend to contact for queries/metadata requests.
+  # Choices are 'beeswax' (default), 'hiveserver2'.
+  ## server_interface=beeswax
+
  # One entry for each Query Server that can execute some SQL queries.
  # This must be in the bottom of the [beewax] section.
  [[query_servers]]

+ 4 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -362,6 +362,10 @@
   # visible only to the owner and administrators.
   ## share_saved_queries=true
 
+  # The backend to contact for queries/metadata requests
+  # Choices are 'beeswax' (default), 'hiveserver2'.
+  ## server_interface=beeswax
+
  # One entry for each Query Server that can execute some SQL queries.
  # This must be in the bottom of the [beewax] section.
  [[query_servers]]

+ 6 - 4
desktop/core/src/desktop/conf.py

@@ -16,15 +16,17 @@
 # limitations under the License.
 """General configuration for core Desktop features (authentication, etc)"""
 
-from desktop import appmanager
-from desktop.lib.conf import Config, ConfigSection, UnspecifiedConfigSection
-from desktop.lib.conf import coerce_bool, validate_path
-from desktop.lib.paths import get_desktop_root
 import os
 import socket
 import stat
+
 from django.utils.translation import ugettext_lazy as _
 
+from desktop.lib.conf import Config, ConfigSection, UnspecifiedConfigSection
+from desktop.lib.conf import coerce_bool, validate_path
+from desktop.lib.paths import get_desktop_root
+
+
 USE_CHERRYPY_SERVER = Config(
   key="use_cherrypy_server",
   help=_("If set to true, CherryPy will be used. Otherwise, Spawning will be used as the webserver."),

+ 2 - 5
desktop/core/src/desktop/lib/thrift_util.py

@@ -228,11 +228,8 @@ def connect_to_thrift(conf):
 
 _connection_pool = ConnectionPooler()
 
-def get_client(klass, host, port, service_name,
-               **kwargs):
-  conf = ConnectionConfig(
-    klass, host, port, service_name,
-    **kwargs)
+def get_client(klass, host, port, service_name, **kwargs):
+  conf = ConnectionConfig(klass, host, port, service_name, **kwargs)
   return PooledClient(conf)
 
 def _grab_transport_from_wrapper(outer_transport):

Some files were not shown because too many files changed in this diff