Struct datafusion_python::common::data_type::DataTypeMap
source · pub struct DataTypeMap {
pub arrow_type: PyDataType,
pub python_type: PythonType,
pub sql_type: SqlType,
}
Expand description
These bindings are tying together several disparate systems. You have SQL types for the SQL strings and RDBMS systems itself. Rust types for the DataFusion code Arrow types which represents the underlying arrow format Python types which represent the type in Python It is important to keep all of those types in a single and managable location. Therefore this structure exists to map those types and provide a simple place for developers to map types from one system to another.
Fields§
§arrow_type: PyDataType
§python_type: PythonType
§sql_type: SqlType
Implementations§
source§impl DataTypeMap
impl DataTypeMap
pub fn map_from_arrow_type(arrow_type: &DataType) -> Result<DataTypeMap, PyErr>
sourcepub fn map_from_scalar_value(
scalar_val: &ScalarValue
) -> Result<DataTypeMap, PyErr>
pub fn map_from_scalar_value( scalar_val: &ScalarValue ) -> Result<DataTypeMap, PyErr>
Generate the DataTypeMap
from a ScalarValue
instance
sourcepub fn map_from_scalar_to_arrow(
scalar_val: &ScalarValue
) -> Result<DataType, PyErr>
pub fn map_from_scalar_to_arrow( scalar_val: &ScalarValue ) -> Result<DataType, PyErr>
Maps a ScalarValue
to an Arrow DataType
source§impl DataTypeMap
impl DataTypeMap
pub fn py_new( arrow_type: PyDataType, python_type: PythonType, sql_type: SqlType ) -> Self
sourcepub fn py_map_from_parquet_type_str(
parquet_str_type: String
) -> PyResult<DataTypeMap>
pub fn py_map_from_parquet_type_str( parquet_str_type: String ) -> PyResult<DataTypeMap>
When using pyarrow.parquet.read_metadata().schema.column(x).physical_type you are presented with a String type for schema rather than an object type. Here we make a best effort to convert that to a physical type.
pub fn py_map_from_arrow_type(arrow_type: &PyDataType) -> PyResult<DataTypeMap>
pub fn py_map_from_arrow_type_str( arrow_type_str: String ) -> PyResult<DataTypeMap>
pub fn py_map_from_sql_type(sql_type: &SqlType) -> PyResult<DataTypeMap>
sourcepub fn friendly_arrow_type_name(&self) -> PyResult<&str>
pub fn friendly_arrow_type_name(&self) -> PyResult<&str>
Unfortunately PyO3 does not allow for us to expose the DataType as an enum since we cannot directly annotae the Enum instance of dependency code. Therefore, here we provide an enum to mimic it.
Trait Implementations§
source§impl Clone for DataTypeMap
impl Clone for DataTypeMap
source§fn clone(&self) -> DataTypeMap
fn clone(&self) -> DataTypeMap
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DataTypeMap
impl Debug for DataTypeMap
source§impl PyClassImpl for DataTypeMap
impl PyClassImpl for DataTypeMap
source§const IS_BASETYPE: bool = true
const IS_BASETYPE: bool = true
source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type Layout = PyCell<DataTypeMap>
type Layout = PyCell<DataTypeMap>
§type ThreadChecker = ThreadCheckerStub<DataTypeMap>
type ThreadChecker = ThreadCheckerStub<DataTypeMap>
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
source§impl PyClassNewTextSignature<DataTypeMap> for PyClassImplCollector<DataTypeMap>
impl PyClassNewTextSignature<DataTypeMap> for PyClassImplCollector<DataTypeMap>
fn new_text_signature(self) -> Option<&'static str>
source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a DataTypeMap
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a DataTypeMap
source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut DataTypeMap
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut DataTypeMap
source§impl PyMethods<DataTypeMap> for PyClassImplCollector<DataTypeMap>
impl PyMethods<DataTypeMap> for PyClassImplCollector<DataTypeMap>
fn py_methods(self) -> &'static PyClassItems
source§impl PyTypeInfo for DataTypeMap
impl PyTypeInfo for DataTypeMap
§type AsRefTarget = PyCell<DataTypeMap>
type AsRefTarget = PyCell<DataTypeMap>
source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
object
is an instance of this type or a subclass of this type.source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
object
is an instance of this type.