Skip to content

Commit

Permalink
Fix rendering of dictionary empty string values in SLT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Oct 31, 2024
1 parent f23360f commit 319d207
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// under the License.

use crate::engines::output::DFColumnType;
use arrow::array::Array;
use arrow::array::{Array, AsArray};
use arrow::datatypes::Fields;
use arrow::util::display::ArrayFormatter;
use arrow::{array, array::ArrayRef, datatypes::DataType, record_batch::RecordBatch};
Expand Down Expand Up @@ -238,6 +238,11 @@ pub fn cell_to_string(col: &ArrayRef, row: usize) -> Result<String> {
col,
row
))),
DataType::Dictionary(_, _) => {
let dict = col.as_any_dictionary();
let key = dict.normalized_keys()[row];
Ok(cell_to_string(dict.values(), key)?)
}
_ => {
let f = ArrayFormatter::try_new(col.as_ref(), &DEFAULT_FORMAT_OPTIONS);
Ok(f.unwrap().value(row).to_string())
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ select arrow_cast(col1, 'Dictionary(Int32, Utf8)') as c1 from test_substr_base;
statement ok
drop table test_source

query T
SELECT arrow_cast('', 'Dictionary(Int32, Utf8)');
----
(empty)

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12637
# Test pattern with wildcard characters
Expand Down

0 comments on commit 319d207

Please sign in to comment.