def grpc_table_op(self, table: Table, op: TableOp): try: result_id = self.session.make_ticket() if table: table_reference = table_pb2.TableReference(ticket=table.ticket) else: table_reference = None stub_func = op.__class__.get_stub_func(self._grpc_table_stub) response = stub_func(op.make_grpc_request( result_id=result_id, source_id=table_reference), metadata=self.session.grpc_metadata) if response.success: return Table(self.session, ticket=response.result_id.ticket, schema_header=response.schema_header, size=response.size, is_static=response.is_static) else: raise DHError( f"Server error received for {op.__class__.__name__}: {response.error_info}" ) except Exception as e: raise DHError( f"failed to finish {op.__class__.__name__} operation") from e
def make_grpc_request(self, result_id, source_id): left_id = source_id right_id = table_pb2.TableReference(ticket=self.table.ticket) return table_pb2.ExactJoinTablesRequest(result_id=result_id, left_id=left_id, right_id=right_id, columns_to_match=self.keys, columns_to_add=self.columns_to_add)
def make_grpc_request(self, result_id, source_id): table_references = [] for tbl in self.tables: table_references.append(table_pb2.TableReference(ticket=tbl.ticket)) return table_pb2.MergeTablesRequest(result_id=result_id, source_ids=table_references, key_column=self.key_column)