in src/context.rs [281:310]
fn create_dataframe(
&mut self,
partitions: PyArrowType<Vec<Vec<RecordBatch>>>,
name: Option<&str>,
py: Python,
) -> PyResult<PyDataFrame> {
let schema = partitions.0[0][0].schema();
let table = MemTable::try_new(schema, partitions.0).map_err(DataFusionError::from)?;
// generate a random (unique) name for this table if none is provided
// table name cannot start with numeric digit
let table_name = match name {
Some(val) => val.to_owned(),
None => {
"c".to_owned()
+ Uuid::new_v4()
.simple()
.encode_lower(&mut Uuid::encode_buffer())
}
};
self.ctx
.register_table(&*table_name, Arc::new(table))
.map_err(DataFusionError::from)?;
let table = wait_for_future(py, self._table(&table_name)).map_err(DataFusionError::from)?;
let df = PyDataFrame::new(table);
Ok(df)
}