alamb commented on code in PR #14381:
URL: https://github.com/apache/datafusion/pull/14381#discussion_r1937223203


##########
datafusion/sqllogictest/test_files/case.slt:
##########
@@ -308,3 +308,84 @@ NULL NULL false
 
 statement ok
 drop table foo
+
+####
+#### Case with structs with subfields that need to be coerced
+#####
+
+statement ok
+create table t as values
+(
+ true,                                       -- column1 boolean (so the case 
isn't constant folded)
+ [{ 'foo': 'bar' }],                         -- column2 has List of Struct w/ 
Utf8
+ [{ 'foo': arrow_cast('bar', 'Utf8View') }]  -- column3 has List of Struct w/ 
Utf8View
+)
+
+query B?
+select column1, column2 from t;
+----
+true [{foo: bar}]
+
+query TT
+select arrow_typeof(column1), arrow_typeof(column2) from t;
+----
+Boolean List(Field { name: "item", data_type: Struct([Field { name: "foo", 
data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: 
{} }]), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })
+
+# Force coercion of column2 to Utf8View
+query ??
+select
+  case when column1     then column2 else column3 end,
+  case when not column1 then column2 else column3 end
+from t;
+----
+[{c0: bar}] [{c0: bar}]

Review Comment:
   this is clearly wrong -- it should have 'foo' as the field name



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to