def get_tables(service, session_handle, database_name='.*'): req = TGetTablesReq(sessionHandle=session_handle, schemaName=database_name, tableName='.*') log.debug('get_tables: req=%s', req) resp = service.GetTables(req) log.debug('get_tables: resp=%s', resp) err_if_rpc_not_ok(resp) return resp.operationHandle
def table_exists(service, session_handle, hs2_protocol_version, table_name, database_name='.*'): req = TGetTablesReq(sessionHandle=session_handle, schemaName=database_name, tableName=table_name) log.debug('table_exists: req=%s', req) resp = service.GetTables(req) log.debug('table_exists: resp=%s', resp) err_if_rpc_not_ok(resp) operation_handle = resp.operationHandle # this only fetches default max_rows, but there should only be one row # ideally results = fetch_results(service=service, operation_handle=operation_handle, hs2_protocol_version=hs2_protocol_version) exists = False for result in results: if result[2].lower() == table_name.lower(): exists = True close_operation(service, operation_handle) return exists
def get_tables(self, database='.*', table_like='.*'): req = TGetTablesReq(sessionHandle=self.handle, schemaName=database, tableName=table_like) return self._operation('GetTables', req)