예제 #1
0
    def to_arrow_table(self):
        """Return arrow table object created from the DataTable."""
        from pyarrow import Table, array

        arrow_table = Table.from_arrays(
            [array(column) for column in list(map(list, zip(*self._data)))],
            names=self.columns)
        return arrow_table
예제 #2
0
 def send_data(self, command: bytes, table: Optional[Table]) -> None:
     """
     Send a data batch to the server.
     :param command: a command to in descriptor to pass along, user should take the responsibility to
         deserialize it.
     :param table: a PyArrow.Table of column-stored records.
     """
     descriptor = FlightDescriptor.for_command(command)
     table = Table.from_arrays([]) if table is None else table
     writer, _ = self.do_put(descriptor, table.schema)
     writer: FlightStreamWriter
     with writer:
         writer.write_table(table)
예제 #3
0
 def select(self, columns):
     """ ArrowLoaf: Selected columns in selected order. """
     return type(self)(Table.from_arrays([self[x] for x in columns]))