@@ -32,6 +32,7 @@ use vortex::dtype::FieldNames;
3232use vortex:: error:: VortexExpect ;
3333use vortex:: error:: VortexResult ;
3434use vortex:: error:: vortex_err;
35+ use vortex:: error:: vortex_panic;
3536use vortex:: expr:: Expression ;
3637use vortex:: expr:: and_collect;
3738use vortex:: expr:: col;
@@ -73,6 +74,7 @@ use crate::duckdb::DataChunkRef;
7374use crate :: duckdb:: DuckdbStringMapRef ;
7475use crate :: duckdb:: ExpressionRef ;
7576use crate :: duckdb:: LogicalType ;
77+ use crate :: duckdb:: LogicalTypeRef ;
7678use crate :: duckdb:: PartitionData ;
7779use crate :: duckdb:: TableFilterSetRef ;
7880use crate :: duckdb:: TableFunction ;
@@ -118,6 +120,7 @@ pub struct DataSourceBindData {
118120 data_source : Arc < MultiLayoutDataSource > ,
119121 filter_exprs : Vec < Expression > ,
120122 column_fields : Vec < DuckdbField > ,
123+ //column_casts: Vec<(usize, DType)>,
121124}
122125
123126impl Clone for DataSourceBindData {
@@ -569,6 +572,27 @@ impl<T: DataSourceTableFunction> TableFunction for T {
569572 map. push ( "Filters" , & filters. join ( " /\\ \n " ) ) ;
570573 }
571574 }
575+
576+ fn pushdown_column_type (
577+ bind_data : & mut Self :: BindData ,
578+ column_id : u64 ,
579+ new_type : & LogicalTypeRef ,
580+ ) {
581+ // TODO virtual column count?
582+ let column_id: usize = column_id. as_ ( ) ;
583+ if column_id >= bind_data. column_fields . len ( ) {
584+ vortex_panic ! ( "column_id {column_id} >= {}" , bind_data. column_fields. len( ) ) ;
585+ }
586+ // TODO casting?
587+ let field = & mut bind_data. column_fields [ column_id] ;
588+ let old_dtype = field. dtype . clone ( ) ;
589+ // TODO we don't need a copy?
590+ field. logical_type = LogicalType :: new ( new_type. as_type_id ( ) ) ;
591+ field. dtype = new_type
592+ . try_into ( )
593+ . vortex_expect ( "logical type -> dtype conversion failed" ) ;
594+ println ! ( "Cast {} -> {}" , old_dtype, field. dtype) ;
595+ }
572596}
573597
574598/// Extracts DuckDB column names and logical types from a Vortex struct DType.
0 commit comments