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 2025/02/24 15:28:24 UTC
(datafusion) branch main updated: Add support for `Dictionary` & `Interval` to AST datatype (#14783)
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 cec457a240 Add support for `Dictionary` & `Interval` to AST datatype (#14783)
cec457a240 is described below
commit cec457a240d56f89ab90057ad56ce918a90410e2
Author: Peter L <ce...@hotmail.com>
AuthorDate: Tue Feb 25 01:58:18 2025 +1030
Add support for `Dictionary` & `Interval` to AST datatype (#14783)
---
datafusion/sql/src/unparser/expr.rs | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/datafusion/sql/src/unparser/expr.rs b/datafusion/sql/src/unparser/expr.rs
index 7c56969d47..d051cb78a8 100644
--- a/datafusion/sql/src/unparser/expr.rs
+++ b/datafusion/sql/src/unparser/expr.rs
@@ -1585,9 +1585,7 @@ impl Unparser<'_> {
DataType::Duration(_) => {
not_impl_err!("Unsupported DataType: conversion: {data_type:?}")
}
- DataType::Interval(_) => {
- not_impl_err!("Unsupported DataType: conversion: {data_type:?}")
- }
+ DataType::Interval(_) => Ok(ast::DataType::Interval),
DataType::Binary => {
not_impl_err!("Unsupported DataType: conversion: {data_type:?}")
}
@@ -1624,9 +1622,7 @@ impl Unparser<'_> {
DataType::Union(_, _) => {
not_impl_err!("Unsupported DataType: conversion: {data_type:?}")
}
- DataType::Dictionary(_, _) => {
- not_impl_err!("Unsupported DataType: conversion: {data_type:?}")
- }
+ DataType::Dictionary(_, val) => self.arrow_dtype_to_ast_dtype(val),
DataType::Decimal128(precision, scale)
| DataType::Decimal256(precision, scale) => {
let mut new_precision = *precision as u64;
@@ -2804,6 +2800,22 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_dictionary_to_sql() -> Result<()> {
+ let dialect = CustomDialectBuilder::new().build();
+
+ let unparser = Unparser::new(&dialect);
+
+ let ast_dtype = unparser.arrow_dtype_to_ast_dtype(&DataType::Dictionary(
+ Box::new(DataType::Int32),
+ Box::new(DataType::Utf8),
+ ))?;
+
+ assert_eq!(ast_dtype, ast::DataType::Varchar(None));
+
+ Ok(())
+ }
+
#[test]
fn test_utf8_view_to_sql() -> Result<()> {
let dialect = CustomDialectBuilder::new()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org