diff --git a/src/script/src/python/ffi_types/copr.rs b/src/script/src/python/ffi_types/copr.rs index 1af3f416f32e..704b0db77d44 100644 --- a/src/script/src/python/ffi_types/copr.rs +++ b/src/script/src/python/ffi_types/copr.rs @@ -21,8 +21,10 @@ use std::sync::{Arc, Weak}; use common_query::OutputData; use common_recordbatch::{RecordBatch, RecordBatches}; +use datafusion_common::ScalarValue; use datatypes::arrow::compute; use datatypes::data_type::{ConcreteDataType, DataType}; +use datatypes::prelude::Value; use datatypes::schema::{ColumnSchema, Schema, SchemaRef}; use datatypes::vectors::{Helper, VectorRef}; // use crate::python::builtins::greptime_builtin; @@ -42,7 +44,9 @@ use vm::{pyclass as rspyclass, PyObjectRef, PyPayload, PyResult, VirtualMachine} use super::py_recordbatch::PyRecordBatch; use crate::engine::EvalContext; -use crate::python::error::{ensure, ArrowSnafu, OtherSnafu, Result, TypeCastSnafu}; +use crate::python::error::{ + ensure, ArrowSnafu, DataFusionSnafu, OtherSnafu, Result, TypeCastSnafu, +}; use crate::python::ffi_types::PyVector; #[cfg(feature = "pyo3_backend")] use crate::python::pyo3::pyo3_exec_parsed; @@ -179,6 +183,25 @@ impl Coprocessor { /// check if real types and annotation types(if have) is the same, if not try cast columns to annotated type pub(crate) fn check_and_cast_type(&self, cols: &mut [VectorRef]) -> Result<()> { + for col in cols.iter_mut() { + if let ConcreteDataType::List(x) = col.data_type() { + let values = + ScalarValue::convert_array_to_scalar_vec(col.to_arrow_array().as_ref()) + .context(DataFusionSnafu)? + .into_iter() + .flatten() + .map(Value::try_from) + .collect::, _>>() + .context(TypeCastSnafu)?; + + let mut builder = x.item_type().create_mutable_vector(values.len()); + for v in values.iter() { + builder.push_value_ref(v.as_value_ref()); + } + *col = builder.to_vector(); + } + } + let return_types = &self.return_types; // allow ignore Return Type Annotation if return_types.is_empty() { diff --git a/src/script/src/python/ffi_types/pair_tests.rs b/src/script/src/python/ffi_types/pair_tests.rs index 15768f840484..781bae9b9e61 100644 --- a/src/script/src/python/ffi_types/pair_tests.rs +++ b/src/script/src/python/ffi_types/pair_tests.rs @@ -71,8 +71,6 @@ fn into_recordbatch(input: HashMap) -> RecordBatch { RecordBatch::new(schema, columns).unwrap() } -// FIXME(LFC): Enable testing "integrated_py_copr_test" -#[ignore] #[tokio::test] #[allow(clippy::print_stdout)] async fn integrated_py_copr_test() { diff --git a/src/script/src/python/rspython/test.rs b/src/script/src/python/rspython/test.rs index 4d6189aa9c43..310c32f798d8 100644 --- a/src/script/src/python/rspython/test.rs +++ b/src/script/src/python/rspython/test.rs @@ -84,8 +84,6 @@ fn create_sample_recordbatch() -> RecordBatch { .unwrap() } -// FIXME(LFC): Enable testing "run_ron_testcases" -#[ignore] /// test cases which read from a .ron file, deser, /// /// and exec/parse (depending on the type of predicate) then decide if result is as expected