diff --git a/vortex-datafusion/src/lib.rs b/vortex-datafusion/src/lib.rs index 00aafe0f946..fefa8433af3 100644 --- a/vortex-datafusion/src/lib.rs +++ b/vortex-datafusion/src/lib.rs @@ -46,3 +46,47 @@ where } } } + +#[cfg(test)] +mod tests { + + use std::sync::Arc; + + use datafusion::{ + execution::SessionStateBuilder, + prelude::{SessionConfig, SessionContext}, + }; + + use crate::VortexFormatFactory; + + // https://github.com/vortex-data/vortex/issues/6211 + #[tokio::test] + async fn test_cast_int_to_string() -> anyhow::Result<()> { + let ctx = { + let s = SessionStateBuilder::new() + .with_file_formats(vec![Arc::new(VortexFormatFactory::new())]) + .with_config(SessionConfig::from_env()?) + .with_runtime_env(Default::default()) + .with_default_features() + .build(); + SessionContext::new_with_state(s).enable_url_table() + }; + + ctx.sql(r#"copy (select 1 as id) to 'example.vortex'"#) + .await? + .show() + .await?; + + ctx.sql(r#"select cast(id as string) as sid from 'example.vortex' where id > 0"#) + .await? + .show() + .await?; + + ctx.sql(r#"select id from 'example.vortex' where cast (id as string) == '1'"#) + .await? + .show() + .await?; + + Ok(()) + } +}