Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions vortex-datafusion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Loading