diff --git a/iox_query/src/test.rs b/iox_query/src/test.rs index a99bd2f19c..2c4cc30118 100644 --- a/iox_query/src/test.rs +++ b/iox_query/src/test.rs @@ -16,6 +16,7 @@ use arrow::{ ArrayRef, DictionaryArray, Int64Array, StringArray, TimestampNanosecondArray, UInt64Array, }, datatypes::{DataType, Int32Type, TimeUnit}, + error::ArrowError, record_batch::RecordBatch, }; use async_trait::async_trait; @@ -919,14 +920,24 @@ impl QueryChunk for TestChunk { &self, _ctx: IOxSessionContext, predicate: &Predicate, - _selection: Selection<'_>, + selection: Selection<'_>, ) -> Result { self.check_error()?; // save the predicate self.predicates.lock().push(predicate.clone()); - let batches = self.table_data.clone(); + let batches = match self.schema.df_projection(selection)? { + None => self.table_data.clone(), + Some(projection) => self + .table_data + .iter() + .map(|batch| { + let batch = batch.project(&projection)?; + Ok(Arc::new(batch)) + }) + .collect::, ArrowError>>()?, + }; Ok(stream_from_batches(batches)) } diff --git a/service_grpc_influxrpc/src/service.rs b/service_grpc_influxrpc/src/service.rs index 7794b886b9..6d4e076bf1 100644 --- a/service_grpc_influxrpc/src/service.rs +++ b/service_grpc_influxrpc/src/service.rs @@ -2182,10 +2182,12 @@ mod tests { let db_info = org_and_bucket(); let chunk1 = TestChunk::new("table_a") + .with_time_column() .with_id(0) .with_tag_column("state") .with_one_row_of_data(); let chunk2 = TestChunk::new("table_b") + .with_time_column() .with_id(1) .with_tag_column("state") .with_one_row_of_data();