Skip to content

Commit 2ce043b

Browse files
committed
Add tests that verify issue is there
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent fe59306 commit 2ce043b

1 file changed

Lines changed: 54 additions & 2 deletions

File tree

vortex-datafusion/src/tests/schema_evolution.rs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,55 @@ async fn test_schema_evolution_struct_field_order() -> anyhow::Result<()> {
483483
Ok(())
484484
}
485485

486+
// https://github.com/vortex-data/vortex/discussions/6264
487+
#[tokio::test]
488+
#[should_panic(expected = "Failed to convert scalar")]
489+
async fn test_schema_evolution_incompatible_types() {
490+
let ctx = TestSessionContext::default();
491+
492+
// File 1: 'code' is UTF8 (string)
493+
ctx.write_arrow_batch(
494+
"files/data_utf8.vortex",
495+
&record_batch!(
496+
("id", Int64, vec![Some(1i64), Some(2), Some(3)]),
497+
("code", Utf8, vec![Some("A100"), Some("B200"), Some("C300")]),
498+
("value", Int64, vec![Some(100i64), Some(200), Some(300)])
499+
)
500+
.unwrap(),
501+
)
502+
.await
503+
.unwrap();
504+
505+
// File 2: 'code' is Int64 (SCHEMA CONFLICT!)
506+
ctx.write_arrow_batch(
507+
"files/data_int64.vortex",
508+
&record_batch!(
509+
("id", Int64, vec![Some(4i64), Some(5), Some(6)]),
510+
("code", Int64, vec![Some(400i64), Some(500), Some(600)]),
511+
("value", Int64, vec![Some(400i64), Some(500), Some(600)])
512+
)
513+
.unwrap(),
514+
)
515+
.await
516+
.unwrap();
517+
518+
// Query both files with the string schema
519+
ctx.session
520+
.sql(
521+
"CREATE EXTERNAL TABLE my_tbl (id BIGINT, code STRING, value BIGINT) \
522+
STORED AS vortex \
523+
LOCATION '/files/'",
524+
)
525+
.await
526+
.unwrap();
527+
528+
let table = ctx.session.table("my_tbl").await.unwrap();
529+
530+
// This should panic due to incompatible schema types
531+
table.collect().await.unwrap();
532+
}
533+
534+
// https://github.com/vortex-data/vortex/issues/6211
486535
#[tokio::test]
487536
async fn test_cast_int_to_string() -> anyhow::Result<()> {
488537
let ctx = TestSessionContext::default();
@@ -506,11 +555,14 @@ async fn test_cast_int_to_string() -> anyhow::Result<()> {
506555
.await?;
507556

508557
// This fails as it pushes string cast to the scan
509-
ctx.session
558+
let result = ctx
559+
.session
510560
.sql(r#"select cast(id as string) from 'example.vortex'"#)
511561
.await?
512562
.collect()
513-
.await?;
563+
.await;
564+
565+
assert!(result.is_err());
514566

515567
Ok(())
516568
}

0 commit comments

Comments
 (0)