Skip to content

Commit 1628e02

Browse files
committed
Reproducer
1 parent c6d5520 commit 1628e02

1 file changed

Lines changed: 45 additions & 6 deletions

File tree

  • datafusion/core/tests/dataframe

datafusion/core/tests/dataframe/mod.rs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ mod dataframe_functions;
2020
mod describe;
2121

2222
use arrow::array::{
23-
record_batch, Array, ArrayRef, BooleanArray, DictionaryArray, FixedSizeListArray,
24-
FixedSizeListBuilder, Float32Array, Float64Array, Int32Array, Int32Builder,
25-
Int8Array, LargeListArray, ListArray, ListBuilder, RecordBatch, StringArray,
26-
StringBuilder, StructBuilder, UInt32Array, UInt32Builder, UnionArray,
23+
record_batch, Array, ArrayRef, BooleanArray, DictionaryArray, FixedSizeListArray, FixedSizeListBuilder, Float32Array, Float64Array, Int32Array, Int32Builder, Int8Array, LargeListArray, ListArray, ListBuilder, RecordBatch, StringArray, StringBuilder, StringDictionaryBuilder, StructBuilder, UInt32Array, UInt32Builder, UnionArray
2724
};
2825
use arrow::buffer::ScalarBuffer;
2926
use arrow::datatypes::{
30-
DataType, Field, Float32Type, Int32Type, Schema, SchemaRef, UInt64Type, UnionFields,
31-
UnionMode,
27+
DataType, Field, Float32Type, Int32Type, Int8Type, Schema, SchemaRef, UInt64Type, UnionFields, UnionMode
3228
};
3329
use arrow::error::ArrowError;
3430
use arrow::util::pretty::pretty_format_batches;
@@ -3503,6 +3499,49 @@ async fn test_grouping_set_array_agg_with_overflow() -> Result<()> {
35033499
Ok(())
35043500
}
35053501

3502+
#[tokio::test]
3503+
async fn df_list_of_dict_should_panic() -> Result<()> {
3504+
// build List<Dictionary<Int8,Utf8>>
3505+
let mut dict_builder = StringDictionaryBuilder::<Int8Type>::new();
3506+
for s in ["foo","bar","baz","foo"] { dict_builder.append(s)?; }
3507+
let mut list_builder = ListBuilder::new(dict_builder);
3508+
list_builder.values().append("foo")?;
3509+
list_builder.values().append("bar")?;
3510+
list_builder.append(true);
3511+
list_builder.values().append("baz")?;
3512+
list_builder.append(true);
3513+
let list_dict = list_builder.finish();
3514+
3515+
let schema = Arc::new(Schema::new(vec![
3516+
Field::new("a", DataType::Int32, false),
3517+
Field::new("c", list_dict.data_type().clone(), false),
3518+
]));
3519+
let batch = RecordBatch::try_new(
3520+
schema.clone(),
3521+
vec![Arc::new(Int32Array::from(vec![1,2])), Arc::new(list_dict)],
3522+
)?;
3523+
3524+
let ctx = SessionContext::new();
3525+
ctx.register_batch("x", batch)?;
3526+
3527+
// GROUP BY forces Aggregate (first RowConverter pass)
3528+
// ORDER BY … LIMIT forces TopKExec (second pass)
3529+
let df = ctx.sql(
3530+
r#"
3531+
SELECT c, COUNT(*) AS cnt
3532+
FROM x
3533+
GROUP BY c
3534+
ORDER BY cnt DESC
3535+
LIMIT 10
3536+
"#,
3537+
).await?;
3538+
3539+
// will panic
3540+
df.collect().await?;
3541+
3542+
Ok(())
3543+
}
3544+
35063545
#[tokio::test]
35073546
async fn join_with_alias_filter() -> Result<()> {
35083547
let join_ctx = create_join_context()?;

0 commit comments

Comments
 (0)