You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by al...@apache.org on 2024/10/31 15:15:31 UTC
(datafusion) branch main updated: Fix rendering of dictionary empty string values in SLT tests (#13198)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new cf76421d7f Fix rendering of dictionary empty string values in SLT tests (#13198)
cf76421d7f is described below
commit cf76421d7f3f30a42f0bad473d3ebdc611b83ba3
Author: Piotr Findeisen <pi...@gmail.com>
AuthorDate: Thu Oct 31 16:15:26 2024 +0100
Fix rendering of dictionary empty string values in SLT tests (#13198)
---
datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs | 7 ++++++-
datafusion/sqllogictest/test_files/string/dictionary_utf8.slt | 5 +++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs b/datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs
index a88ee9d08d..8337d2e9a3 100644
--- a/datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs
+++ b/datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs
@@ -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};
@@ -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())
diff --git a/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt b/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
index 04bd00e316..8a2916f669 100644
--- a/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
+++ b/datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
@@ -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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org