alexandreyc commented on code in PR #1883: URL: https://github.com/apache/arrow-adbc/pull/1883#discussion_r1639665685
########## rust/drivers/dummy/tests/driver_exporter_dummy.rs: ########## @@ -0,0 +1,655 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/// This integration test compares the output of the dummy driver when it's used +/// directly using the Rust API (native) and trough the exported driver via the +/// driver manager (exported). That allows us to test that data correctly round-trip +/// between C and Rust. +use std::ops::Deref; +use std::sync::Arc; + +use arrow::array::{Array, Float64Array, Int64Array, StringArray}; +use arrow::compute::concat_batches; +use arrow::datatypes::{DataType, Field, Schema}; +use arrow::record_batch::{RecordBatch, RecordBatchReader}; + +use adbc_core::driver_manager::{ + ManagedConnection, ManagedDatabase, ManagedDriver, ManagedStatement, +}; +use adbc_core::options::{ + AdbcVersion, InfoCode, IngestMode, IsolationLevel, ObjectDepth, OptionConnection, + OptionDatabase, OptionStatement, +}; +use adbc_core::Statement; +use adbc_core::{schemas, Connection, Database, Driver, Optionable}; + +use adbc_dummy::{DummyConnection, DummyDatabase, DummyDriver, DummyStatement, SingleBatchReader}; + +const OPTION_STRING_LONG: &str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; +const OPTION_BYTES_LONG: &[u8] = b"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +pub fn concat_reader(reader: impl RecordBatchReader) -> RecordBatch { + let schema = reader.schema(); + let batches: Vec<RecordBatch> = reader.map(|b| b.unwrap()).collect(); + concat_batches(&schema, &batches).unwrap() +} Review Comment: Yes these two functions are duplicated. The logic behind this is to avoid having them in the core crate because they're only useful for tests. For `concat_reader`, we could potentially upstream it to `arrow-rs` since there is already a similar function [`concat_batches`](https://docs.rs/arrow/latest/arrow/compute/fn.concat_batches.html). For `sample_batch`, we don't have any other choice than to duplicate or move to the core crate. As a middle ground, we could put them in the core crate and disable documentation. What's your opinion? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
