Skip to content

Integration tests are not being run #16801

@adriangb

Description

@adriangb

Describe the bug

There's something wrong with datafusion/core/tests/integration_tests/schema_adapter_integration_tests.rs: I don't think it's being run.

Simple examination shows it would not compile:

/// Schema adapter that transforms column names to uppercase
#[derive(Debug)]
struct UppercaseAdapter {
input_schema: SchemaRef,
}
impl SchemaAdapter for UppercaseAdapter {
fn adapt(&self, record_batch: RecordBatch) -> Result<RecordBatch> {
// In a real adapter, we might transform the data too
// For this test, we're just passing through the batch
Ok(record_batch)
}
fn output_schema(&self) -> SchemaRef {
let fields = self
.input_schema
.fields()
.iter()
.map(|f| {
Field::new(
f.name().to_uppercase().as_str(),
f.data_type().clone(),
f.is_nullable(),
)
})
.collect();
Arc::new(Schema::new(fields))
}
}

The methods implemented do not match the trait at all:

pub trait SchemaAdapter: Send + Sync {
/// Map a column index in the table schema to a column index in a particular
/// file schema
///
/// This is used while reading a file to push down projections by mapping
/// projected column indexes from the table schema to the file schema
///
/// Panics if index is not in range for the table schema
fn map_column_index(&self, index: usize, file_schema: &Schema) -> Option<usize>;
/// Creates a mapping for casting columns from the file schema to the table
/// schema.
///
/// This is used after reading a record batch. The returned [`SchemaMapper`]:
///
/// 1. Maps columns to the expected columns indexes
/// 2. Handles missing values (e.g. fills nulls or a default value) for
/// columns in the in the table schema not in the file schema
/// 2. Handles different types: if the column in the file schema has a
/// different type than `table_schema`, the mapper will resolve this
/// difference (e.g. by casting to the appropriate type)
///
/// Returns:
/// * a [`SchemaMapper`]
/// * an ordered list of columns to project from the file
fn map_schema(
&self,
file_schema: &Schema,
) -> datafusion_common::Result<(Arc<dyn SchemaMapper>, Vec<usize>)>;
}

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions