Skip to content

Commit

Permalink
fix python script tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelScofield committed Apr 7, 2024
1 parent 9eb6c06 commit 03533ca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
25 changes: 24 additions & 1 deletion src/script/src/python/ffi_types/copr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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::<std::result::Result<Vec<_>, _>>()
.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() {
Expand Down
2 changes: 0 additions & 2 deletions src/script/src/python/ffi_types/pair_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ fn into_recordbatch(input: HashMap<String, VectorRef>) -> 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() {
Expand Down
2 changes: 0 additions & 2 deletions src/script/src/python/rspython/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03533ca

Please sign in to comment.