diff --git a/README.md b/README.md index 83252fd..c69f44d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # e6data Python Connector -![version](https://img.shields.io/badge/version-1.0.6-blue.svg) +![version](https://img.shields.io/badge/version-1.0.7-blue.svg) ## Introduction diff --git a/e6xdb/e6x.py b/e6xdb/e6x.py index f5b3fc2..2d5feb2 100644 --- a/e6xdb/e6x.py +++ b/e6xdb/e6x.py @@ -204,9 +204,24 @@ def get_tables_v2(self, catalog_name, database): return self._client.getTablesV2(sessionId=self.get_session_id, catalogName=catalog_name, schema=database) def get_columns(self, database, table): - catalog_name = '' - return self._client.getColumns(sessionId=self.get_session_id, catalogName=catalog_name, schema=database, - table=table) + return self._client.getColumns(sessionId=self.get_session_id, schema=database, table=table) + + def status(self, query_id): + return self._client.status(sessionId=self.get_session_id, queryId=query_id) + + def get_add_catalog_response(self): + """ + Response Type: + AddCatalogsResponse(status='success', failures=[]) + Usage: + response.status: success, in_progress, failed + + Error Usage: + response = conn.get_add_catalog_response() + if response.status == 'error' + print(response.failures[0].reason) + """ + return self._client.getAddCatalogsResponse(sessionId=self.get_session_id) def get_columns_v2(self, catalog_name, database, table): return self._client.getColumnsV2( @@ -501,3 +516,45 @@ class Error(Exception): for type_id in PRIMITIVE_TYPES: name = TypeId._VALUES_TO_NAMES[type_id] setattr(sys.modules[__name__], name, DBAPITypeObject([name])) + + +if __name__ == '__main__': + ip = '54.205.255.188' + conn = Connection( + host=ip, + username='admin', + password='admin', + port=9000 + ) + catalogs = {'catalogs': [{ + "type": 'HIVE', + "name": 'hive', + "hive_ip": '18.233.112.169', + "hive_port": 9084, + "included_schemas": [], + "excluded_schemas": [], + "included_tables": [], + "excluded_tables": [], + "included_columns": [], + "excluded_columns": [], + "is_assumed_role": False, + "assumed_role_arn": '', + "default": True + }]} + import json + import time + start = time.time() + # print(conn.add_catalogs(json.dumps(catalogs))) + add_cat_time = time.time() + print('Add catalog time', add_cat_time - start) + status = 'in_progress' + res = conn.get_add_catalog_response() + print(res) + print(res.failures[0].reason) + # while status == 'in_progress': + # res = conn.get_add_catalog_response() + # status = res.status + # print(res) + # time.sleep(5) + print('get_add_catalog_response time', time.time() - add_cat_time) + diff --git a/e6xdb/server/QueryEngineService-remote b/e6xdb/server/QueryEngineService-remote index 630cd06..d3a1c05 100755 --- a/e6xdb/server/QueryEngineService-remote +++ b/e6xdb/server/QueryEngineService-remote @@ -41,11 +41,13 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print(' getTablesV2(string sessionId, string catalogName, string schema)') print(' getSchemaNames(string sessionId)') print(' getSchemaNamesV2(string sessionId, string catalogName)') - print(' getColumns(string sessionId, string catalogName, string schema, string table)') + print(' getColumns(string sessionId, string schema, string table)') print(' getColumnsV2(string sessionId, string catalogName, string schema, string table)') print(' void updateUsers(string userInfo)') print(' void setProps(string sessionId, string propMap)') + print(' Status status(string sessionId, string queryId)') print(' void addCatalogs(string sessionId, string jsonString)') + print(' AddCatalogsResponse getAddCatalogsResponse(string sessionId)') print('') sys.exit(0) @@ -228,10 +230,10 @@ elif cmd == 'getSchemaNamesV2': pp.pprint(client.getSchemaNamesV2(args[0], args[1],)) elif cmd == 'getColumns': - if len(args) != 4: - print('getColumns requires 4 args') + if len(args) != 3: + print('getColumns requires 3 args') sys.exit(1) - pp.pprint(client.getColumns(args[0], args[1], args[2], args[3],)) + pp.pprint(client.getColumns(args[0], args[1], args[2],)) elif cmd == 'getColumnsV2': if len(args) != 4: @@ -251,12 +253,24 @@ elif cmd == 'setProps': sys.exit(1) pp.pprint(client.setProps(args[0], args[1],)) +elif cmd == 'status': + if len(args) != 2: + print('status requires 2 args') + sys.exit(1) + pp.pprint(client.status(args[0], args[1],)) + elif cmd == 'addCatalogs': if len(args) != 2: print('addCatalogs requires 2 args') sys.exit(1) pp.pprint(client.addCatalogs(args[0], args[1],)) +elif cmd == 'getAddCatalogsResponse': + if len(args) != 1: + print('getAddCatalogsResponse requires 1 args') + sys.exit(1) + pp.pprint(client.getAddCatalogsResponse(args[0],)) + else: print('Unrecognized method %s' % cmd) sys.exit(1) diff --git a/e6xdb/server/QueryEngineService.py b/e6xdb/server/QueryEngineService.py index 747d7d6..a7bd1d6 100644 --- a/e6xdb/server/QueryEngineService.py +++ b/e6xdb/server/QueryEngineService.py @@ -178,11 +178,10 @@ def getSchemaNamesV2(self, sessionId, catalogName): """ pass - def getColumns(self, sessionId, catalogName, schema, table): + def getColumns(self, sessionId, schema, table): """ Parameters: - sessionId - - catalogName - schema - table @@ -217,6 +216,15 @@ def setProps(self, sessionId, propMap): """ pass + def status(self, sessionId, queryId): + """ + Parameters: + - sessionId + - queryId + + """ + pass + def addCatalogs(self, sessionId, jsonString): """ Parameters: @@ -226,6 +234,14 @@ def addCatalogs(self, sessionId, jsonString): """ pass + def getAddCatalogsResponse(self, sessionId): + """ + Parameters: + - sessionId + + """ + pass + class Client(Iface): def __init__(self, iprot, oprot=None): @@ -884,23 +900,21 @@ def recv_getSchemaNamesV2(self): raise result.error2 raise TApplicationException(TApplicationException.MISSING_RESULT, "getSchemaNamesV2 failed: unknown result") - def getColumns(self, sessionId, catalogName, schema, table): + def getColumns(self, sessionId, schema, table): """ Parameters: - sessionId - - catalogName - schema - table """ - self.send_getColumns(sessionId, catalogName, schema, table) + self.send_getColumns(sessionId, schema, table) return self.recv_getColumns() - def send_getColumns(self, sessionId, catalogName, schema, table): + def send_getColumns(self, sessionId, schema, table): self._oprot.writeMessageBegin('getColumns', TMessageType.CALL, self._seqid) args = getColumns_args() args.sessionId = sessionId - args.catalogName = catalogName args.schema = schema args.table = table args.write(self._oprot) @@ -1036,6 +1050,44 @@ def recv_setProps(self): raise result.error2 return + def status(self, sessionId, queryId): + """ + Parameters: + - sessionId + - queryId + + """ + self.send_status(sessionId, queryId) + return self.recv_status() + + def send_status(self, sessionId, queryId): + self._oprot.writeMessageBegin('status', TMessageType.CALL, self._seqid) + args = status_args() + args.sessionId = sessionId + args.queryId = queryId + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_status(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = status_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.error1 is not None: + raise result.error1 + if result.error2 is not None: + raise result.error2 + raise TApplicationException(TApplicationException.MISSING_RESULT, "status failed: unknown result") + def addCatalogs(self, sessionId, jsonString): """ Parameters: @@ -1072,6 +1124,42 @@ def recv_addCatalogs(self): raise result.error2 return + def getAddCatalogsResponse(self, sessionId): + """ + Parameters: + - sessionId + + """ + self.send_getAddCatalogsResponse(sessionId) + return self.recv_getAddCatalogsResponse() + + def send_getAddCatalogsResponse(self, sessionId): + self._oprot.writeMessageBegin('getAddCatalogsResponse', TMessageType.CALL, self._seqid) + args = getAddCatalogsResponse_args() + args.sessionId = sessionId + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_getAddCatalogsResponse(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = getAddCatalogsResponse_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.error1 is not None: + raise result.error1 + if result.error2 is not None: + raise result.error2 + raise TApplicationException(TApplicationException.MISSING_RESULT, "getAddCatalogsResponse failed: unknown result") + class Processor(Iface, TProcessor): def __init__(self, handler): @@ -1098,7 +1186,9 @@ def __init__(self, handler): self._processMap["getColumnsV2"] = Processor.process_getColumnsV2 self._processMap["updateUsers"] = Processor.process_updateUsers self._processMap["setProps"] = Processor.process_setProps + self._processMap["status"] = Processor.process_status self._processMap["addCatalogs"] = Processor.process_addCatalogs + self._processMap["getAddCatalogsResponse"] = Processor.process_getAddCatalogsResponse self._on_message_begin = None def on_message_begin(self, func): @@ -1617,7 +1707,7 @@ def process_getColumns(self, seqid, iprot, oprot): iprot.readMessageEnd() result = getColumns_result() try: - result.success = self._handler.getColumns(args.sessionId, args.catalogName, args.schema, args.table) + result.success = self._handler.getColumns(args.sessionId, args.schema, args.table) msg_type = TMessageType.REPLY except TTransport.TTransportException: raise @@ -1724,6 +1814,35 @@ def process_setProps(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_status(self, seqid, iprot, oprot): + args = status_args() + args.read(iprot) + iprot.readMessageEnd() + result = status_result() + try: + result.success = self._handler.status(args.sessionId, args.queryId) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except QueryProcessingException as error1: + msg_type = TMessageType.REPLY + result.error1 = error1 + except AccessDeniedException as error2: + msg_type = TMessageType.REPLY + result.error2 = error2 + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("status", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_addCatalogs(self, seqid, iprot, oprot): args = addCatalogs_args() args.read(iprot) @@ -1753,6 +1872,35 @@ def process_addCatalogs(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_getAddCatalogsResponse(self, seqid, iprot, oprot): + args = getAddCatalogsResponse_args() + args.read(iprot) + iprot.readMessageEnd() + result = getAddCatalogsResponse_result() + try: + result.success = self._handler.getAddCatalogsResponse(args.sessionId) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except QueryProcessingException as error1: + msg_type = TMessageType.REPLY + result.error1 = error1 + except AccessDeniedException as error2: + msg_type = TMessageType.REPLY + result.error2 = error2 + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("getAddCatalogsResponse", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + # HELPER FUNCTIONS AND STRUCTURES @@ -3951,10 +4099,10 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype10, _size7) = iprot.readListBegin() - for _i11 in range(_size7): - _elem12 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() - self.success.append(_elem12) + (_etype17, _size14) = iprot.readListBegin() + for _i18 in range(_size14): + _elem19 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + self.success.append(_elem19) iprot.readListEnd() else: iprot.skip(ftype) @@ -3981,8 +4129,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter13 in self.success: - oprot.writeString(iter13.encode('utf-8') if sys.version_info[0] == 2 else iter13) + for iter20 in self.success: + oprot.writeString(iter20.encode('utf-8') if sys.version_info[0] == 2 else iter20) oprot.writeListEnd() oprot.writeFieldEnd() if self.error1 is not None: @@ -4130,10 +4278,10 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype17, _size14) = iprot.readListBegin() - for _i18 in range(_size14): - _elem19 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() - self.success.append(_elem19) + (_etype24, _size21) = iprot.readListBegin() + for _i25 in range(_size21): + _elem26 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + self.success.append(_elem26) iprot.readListEnd() else: iprot.skip(ftype) @@ -4160,8 +4308,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter20 in self.success: - oprot.writeString(iter20.encode('utf-8') if sys.version_info[0] == 2 else iter20) + for iter27 in self.success: + oprot.writeString(iter27.encode('utf-8') if sys.version_info[0] == 2 else iter27) oprot.writeListEnd() oprot.writeFieldEnd() if self.error1 is not None: @@ -4285,10 +4433,10 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype24, _size21) = iprot.readListBegin() - for _i25 in range(_size21): - _elem26 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() - self.success.append(_elem26) + (_etype31, _size28) = iprot.readListBegin() + for _i32 in range(_size28): + _elem33 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + self.success.append(_elem33) iprot.readListEnd() else: iprot.skip(ftype) @@ -4315,8 +4463,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter27 in self.success: - oprot.writeString(iter27.encode('utf-8') if sys.version_info[0] == 2 else iter27) + for iter34 in self.success: + oprot.writeString(iter34.encode('utf-8') if sys.version_info[0] == 2 else iter34) oprot.writeListEnd() oprot.writeFieldEnd() if self.error1 is not None: @@ -4452,10 +4600,10 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype31, _size28) = iprot.readListBegin() - for _i32 in range(_size28): - _elem33 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() - self.success.append(_elem33) + (_etype38, _size35) = iprot.readListBegin() + for _i39 in range(_size35): + _elem40 = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + self.success.append(_elem40) iprot.readListEnd() else: iprot.skip(ftype) @@ -4482,8 +4630,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter34 in self.success: - oprot.writeString(iter34.encode('utf-8') if sys.version_info[0] == 2 else iter34) + for iter41 in self.success: + oprot.writeString(iter41.encode('utf-8') if sys.version_info[0] == 2 else iter41) oprot.writeListEnd() oprot.writeFieldEnd() if self.error1 is not None: @@ -4522,16 +4670,14 @@ class getColumns_args(object): """ Attributes: - sessionId - - catalogName - schema - table """ - def __init__(self, sessionId=None, catalogName=None, schema=None, table=None,): + def __init__(self, sessionId=None, schema=None, table=None,): self.sessionId = sessionId - self.catalogName = catalogName self.schema = schema self.table = table @@ -4550,16 +4696,11 @@ def read(self, iprot): else: iprot.skip(ftype) elif fid == 2: - if ftype == TType.STRING: - self.catalogName = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() - else: - iprot.skip(ftype) - elif fid == 3: if ftype == TType.STRING: self.schema = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() else: iprot.skip(ftype) - elif fid == 4: + elif fid == 3: if ftype == TType.STRING: self.table = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() else: @@ -4578,16 +4719,12 @@ def write(self, oprot): oprot.writeFieldBegin('sessionId', TType.STRING, 1) oprot.writeString(self.sessionId.encode('utf-8') if sys.version_info[0] == 2 else self.sessionId) oprot.writeFieldEnd() - if self.catalogName is not None: - oprot.writeFieldBegin('catalogName', TType.STRING, 2) - oprot.writeString(self.catalogName.encode('utf-8') if sys.version_info[0] == 2 else self.catalogName) - oprot.writeFieldEnd() if self.schema is not None: - oprot.writeFieldBegin('schema', TType.STRING, 3) + oprot.writeFieldBegin('schema', TType.STRING, 2) oprot.writeString(self.schema.encode('utf-8') if sys.version_info[0] == 2 else self.schema) oprot.writeFieldEnd() if self.table is not None: - oprot.writeFieldBegin('table', TType.STRING, 4) + oprot.writeFieldBegin('table', TType.STRING, 3) oprot.writeString(self.table.encode('utf-8') if sys.version_info[0] == 2 else self.table) oprot.writeFieldEnd() oprot.writeFieldStop() @@ -4610,9 +4747,8 @@ def __ne__(self, other): getColumns_args.thrift_spec = ( None, # 0 (1, TType.STRING, 'sessionId', 'UTF8', None, ), # 1 - (2, TType.STRING, 'catalogName', 'UTF8', None, ), # 2 - (3, TType.STRING, 'schema', 'UTF8', None, ), # 3 - (4, TType.STRING, 'table', 'UTF8', None, ), # 4 + (2, TType.STRING, 'schema', 'UTF8', None, ), # 2 + (3, TType.STRING, 'table', 'UTF8', None, ), # 3 ) @@ -4643,11 +4779,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype38, _size35) = iprot.readListBegin() - for _i39 in range(_size35): - _elem40 = TFieldInfo() - _elem40.read(iprot) - self.success.append(_elem40) + (_etype45, _size42) = iprot.readListBegin() + for _i46 in range(_size42): + _elem47 = TFieldInfo() + _elem47.read(iprot) + self.success.append(_elem47) iprot.readListEnd() else: iprot.skip(ftype) @@ -4674,8 +4810,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter41 in self.success: - iter41.write(oprot) + for iter48 in self.success: + iter48.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.error1 is not None: @@ -4835,11 +4971,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype45, _size42) = iprot.readListBegin() - for _i46 in range(_size42): - _elem47 = TFieldInfo() - _elem47.read(iprot) - self.success.append(_elem47) + (_etype52, _size49) = iprot.readListBegin() + for _i53 in range(_size49): + _elem54 = TFieldInfo() + _elem54.read(iprot) + self.success.append(_elem54) iprot.readListEnd() else: iprot.skip(ftype) @@ -4866,8 +5002,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter48 in self.success: - iter48.write(oprot) + for iter55 in self.success: + iter55.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.error1 is not None: @@ -5174,6 +5310,166 @@ def __ne__(self, other): ) +class status_args(object): + """ + Attributes: + - sessionId + - queryId + + """ + + + def __init__(self, sessionId=None, queryId=None,): + self.sessionId = sessionId + self.queryId = queryId + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.queryId = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('status_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId.encode('utf-8') if sys.version_info[0] == 2 else self.sessionId) + oprot.writeFieldEnd() + if self.queryId is not None: + oprot.writeFieldBegin('queryId', TType.STRING, 2) + oprot.writeString(self.queryId.encode('utf-8') if sys.version_info[0] == 2 else self.queryId) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + 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) +all_structs.append(status_args) +status_args.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', 'UTF8', None, ), # 1 + (2, TType.STRING, 'queryId', 'UTF8', None, ), # 2 +) + + +class status_result(object): + """ + Attributes: + - success + - error1 + - error2 + + """ + + + def __init__(self, success=None, error1=None, error2=None,): + self.success = success + self.error1 = error1 + self.error2 = error2 + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = Status() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error1 = QueryProcessingException.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.error2 = AccessDeniedException.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('status_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.error1 is not None: + oprot.writeFieldBegin('error1', TType.STRUCT, 1) + self.error1.write(oprot) + oprot.writeFieldEnd() + if self.error2 is not None: + oprot.writeFieldBegin('error2', TType.STRUCT, 2) + self.error2.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__.items()] + 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) +all_structs.append(status_result) +status_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [Status, None], None, ), # 0 + (1, TType.STRUCT, 'error1', [QueryProcessingException, None], None, ), # 1 + (2, TType.STRUCT, 'error2', [AccessDeniedException, None], None, ), # 2 +) + + class addCatalogs_args(object): """ Attributes: @@ -5320,5 +5616,153 @@ def __ne__(self, other): (1, TType.STRUCT, 'error1', [QueryProcessingException, None], None, ), # 1 (2, TType.STRUCT, 'error2', [AccessDeniedException, None], None, ), # 2 ) + + +class getAddCatalogsResponse_args(object): + """ + Attributes: + - sessionId + + """ + + + def __init__(self, sessionId=None,): + self.sessionId = sessionId + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('getAddCatalogsResponse_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId.encode('utf-8') if sys.version_info[0] == 2 else self.sessionId) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + 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) +all_structs.append(getAddCatalogsResponse_args) +getAddCatalogsResponse_args.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', 'UTF8', None, ), # 1 +) + + +class getAddCatalogsResponse_result(object): + """ + Attributes: + - success + - error1 + - error2 + + """ + + + def __init__(self, success=None, error1=None, error2=None,): + self.success = success + self.error1 = error1 + self.error2 = error2 + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = AddCatalogsResponse() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error1 = QueryProcessingException.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.error2 = AccessDeniedException.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('getAddCatalogsResponse_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.error1 is not None: + oprot.writeFieldBegin('error1', TType.STRUCT, 1) + self.error1.write(oprot) + oprot.writeFieldEnd() + if self.error2 is not None: + oprot.writeFieldBegin('error2', TType.STRUCT, 2) + self.error2.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__.items()] + 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) +all_structs.append(getAddCatalogsResponse_result) +getAddCatalogsResponse_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [AddCatalogsResponse, None], None, ), # 0 + (1, TType.STRUCT, 'error1', [QueryProcessingException, None], None, ), # 1 + (2, TType.STRUCT, 'error2', [AccessDeniedException, None], None, ), # 2 +) fix_spec(all_structs) del all_structs diff --git a/e6xdb/server/ttypes.py b/e6xdb/server/ttypes.py index e962f07..0fcb5f0 100644 --- a/e6xdb/server/ttypes.py +++ b/e6xdb/server/ttypes.py @@ -328,6 +328,230 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) + + +class Status(object): + """ + Attributes: + - status + - rowCount + + """ + + + def __init__(self, status=None, rowCount=None,): + self.status = status + self.rowCount = rowCount + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.BOOL: + self.status = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I64: + self.rowCount = iprot.readI64() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('Status') + if self.status is not None: + oprot.writeFieldBegin('status', TType.BOOL, 1) + oprot.writeBool(self.status) + oprot.writeFieldEnd() + if self.rowCount is not None: + oprot.writeFieldBegin('rowCount', TType.I64, 2) + oprot.writeI64(self.rowCount) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + 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 FailedSchemaElement(object): + """ + Attributes: + - name + - type + - reason + + """ + + + def __init__(self, name=None, type=None, reason=None,): + self.name = name + self.type = type + self.reason = reason + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.name = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.type = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.reason = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('FailedSchemaElement') + if self.name is not None: + oprot.writeFieldBegin('name', TType.STRING, 1) + oprot.writeString(self.name.encode('utf-8') if sys.version_info[0] == 2 else self.name) + oprot.writeFieldEnd() + if self.type is not None: + oprot.writeFieldBegin('type', TType.STRING, 2) + oprot.writeString(self.type.encode('utf-8') if sys.version_info[0] == 2 else self.type) + oprot.writeFieldEnd() + if self.reason is not None: + oprot.writeFieldBegin('reason', TType.STRING, 3) + oprot.writeString(self.reason.encode('utf-8') if sys.version_info[0] == 2 else self.reason) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + 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 AddCatalogsResponse(object): + """ + Attributes: + - status + - failures + + """ + + + def __init__(self, status=None, failures=None,): + self.status = status + self.failures = failures + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.status = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.failures = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in range(_size7): + _elem12 = FailedSchemaElement() + _elem12.read(iprot) + self.failures.append(_elem12) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('AddCatalogsResponse') + if self.status is not None: + oprot.writeFieldBegin('status', TType.STRING, 1) + oprot.writeString(self.status.encode('utf-8') if sys.version_info[0] == 2 else self.status) + oprot.writeFieldEnd() + if self.failures is not None: + oprot.writeFieldBegin('failures', TType.LIST, 2) + oprot.writeListBegin(TType.STRUCT, len(self.failures)) + for iter13 in self.failures: + iter13.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__.items()] + 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) all_structs.append(QueryProcessingException) QueryProcessingException.thrift_spec = ( None, # 0 @@ -352,5 +576,24 @@ def __ne__(self, other): (2, TType.STRING, 'userName', 'UTF8', None, ), # 2 (3, TType.LIST, 'tokens', (TType.STRING, 'UTF8', False), None, ), # 3 ) +all_structs.append(Status) +Status.thrift_spec = ( + None, # 0 + (1, TType.BOOL, 'status', None, None, ), # 1 + (2, TType.I64, 'rowCount', None, None, ), # 2 +) +all_structs.append(FailedSchemaElement) +FailedSchemaElement.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'name', 'UTF8', None, ), # 1 + (2, TType.STRING, 'type', 'UTF8', None, ), # 2 + (3, TType.STRING, 'reason', 'UTF8', None, ), # 3 +) +all_structs.append(AddCatalogsResponse) +AddCatalogsResponse.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'status', 'UTF8', None, ), # 1 + (2, TType.LIST, 'failures', (TType.STRUCT, [FailedSchemaElement, None], False), None, ), # 2 +) fix_spec(all_structs) del all_structs diff --git a/server.thrift b/server.thrift index 7d58217..c8dfc4d 100644 --- a/server.thrift +++ b/server.thrift @@ -24,6 +24,24 @@ struct UserAccessInfo 3: list tokens, } +struct Status +{ + 1: bool status + 2: i64 rowCount +} + +struct FailedSchemaElement +{ + 1: string name + 2: string type + 3: string reason +} + +struct AddCatalogsResponse +{ + 1: string status + 2: list failures +} service QueryEngineService { @@ -61,7 +79,7 @@ service QueryEngineService list getSchemaNamesV2(1: string sessionId,2: string catalogName) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2), - list getColumns(1: string sessionId,2: string catalogName, 3: string schema, 4: string table) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2), + list getColumns(1: string sessionId, 2: string schema, 3: string table) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2), list getColumnsV2(1: string sessionId,2: string catalogName, 3: string schema, 4: string table) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2), @@ -69,6 +87,10 @@ service QueryEngineService void setProps(1: string sessionId, 2: string propMap) throws (1: AccessDeniedException error2), + Status status(1: string sessionId, 2: string queryId) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2), + void addCatalogs(1: string sessionId, 2: string jsonString) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2), + AddCatalogsResponse getAddCatalogsResponse(1: string sessionId) throws (1: QueryProcessingException error1, 2: AccessDeniedException error2) + } \ No newline at end of file diff --git a/setup.py b/setup.py index d30722f..19eca19 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ envstring = lambda var: os.environ.get(var) or "" -VERSION = [1, 0, 6] +VERSION = [1, 0, 7] def get_long_desc():