adriangb commented on code in PR #27524:
URL: https://github.com/apache/datafusion/pull/27524#discussion_r4605141569


##########
datafusion/sql/src/unparser/dialect.rs:
##########
@@ -374,9 +371,25 @@ pub enum DistinctFromStyle {
     Spaceship,
 }
 
+/// `ArrayTypeStyle` to use for unparsing Arrow list types
+#[derive(Clone, Copy, PartialEq, Debug)]
+pub enum ArrayTypeStyle {
+    /// `INT[]`, and `INT[3]` for a fixed-size list, as in PostgreSQL and 
DuckDB
+    SquareBracket,
+    /// `ARRAY<INT>`, as in BigQuery. A fixed-size list and a list of lists are
+    /// not supported.
+    AngleBracket,

Review Comment:
   Agreed. `AngleBracket` no longer restricts nesting itself, and its doc no 
longer mentions it.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -1846,6 +1811,32 @@ impl Unparser<'_> {
         }))
     }
 
+    fn array_to_ast_dtype(
+        &self,
+        data_type: &DataType,
+        inner: &FieldRef,
+        size: Option<i32>,
+    ) -> Result<ast::DataType> {
+        let elem = Box::new(self.arrow_dtype_to_ast_dtype(inner)?);
+        let elem_def = match (self.dialect.array_type_style(), size) {
+            (ArrayTypeStyle::SquareBracket, size) => {
+                ast::ArrayElemTypeDef::SquareBracket(elem, size.map(|s| s as 
u64))
+            }
+            // BigQuery, the only dialect with this style, rejects an array of 
arrays.
+            (ArrayTypeStyle::AngleBracket, None)
+                if !matches!(*elem, ast::DataType::Array(_)) =>
+            {
+                ast::ArrayElemTypeDef::AngleBracket(elem)
+            }

Review Comment:
   Done: added `Dialect::supports_nested_arrays` (default `true`, `false` for 
`BigQueryDialect`) and `CustomDialectBuilder::with_supports_nested_arrays`. The 
check applies to both bracket styles.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



##########
datafusion/sql/src/unparser/expr.rs:
##########


Review Comment:
   Yes, added: `ListView` and `LargeListView` now unparse like `List` and 
`LargeList`, with tests.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to