Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
duongcongtoai committed Apr 28, 2024
1 parent ed7a7b9 commit 3a4c2b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
let data_type = self.convert_data_type(&field.field_type)?;
let field_name = match &field.field_name{
Some(ident) => ident.clone(),
None => Ident::new(format!("col{idx}"))
None => Ident::new(format!("c{idx}"))
};

Ok(Arc::new(Field::new(
self.normalizer.normalize(field_name),
data_type,
false, // TODO: confirm this
true, // TODO: confirm this
)))
})
.collect::<Result<Vec<_>>>()?;
Expand Down
25 changes: 17 additions & 8 deletions datafusion/sqllogictest/test_files/struct.slt
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,31 @@ CREATE TABLE values(
(3, 3.3, 'c', NULL)
;


# named and named less struct fields
statement ok
CREATE TABLE toai(
s1 struct<int>,
s2 struct<a int,b varchar>
CREATE TABLE struct_values (
s1 struct<INT>,
s2 struct<a INT,b VARCHAR>
) AS VALUES
(struct(1), struct(1, 'string1')),
(struct(2), struct(2, 'string2')),
(struct(3), struct(3, 'string3'))
;

query ??
select * from toai;
---
{col0: 1} {a: 1, b: string1}
{col0: 2} {a: 2, b: string2}
{col0: 3} {a: 3, b: string3}
select * from struct_values;
----
{c0: 1} {a: 1, b: string1}
{c0: 2} {a: 2, b: string2}
{c0: 3} {a: 3, b: string3}

query TT
select arrow_typeof(s1), arrow_typeof(s2) from struct_values;
----
Struct([Field { name: "c0", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]) Struct([Field { name: "a", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "b", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }])
Struct([Field { name: "c0", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]) Struct([Field { name: "a", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "b", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }])
Struct([Field { name: "c0", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]) Struct([Field { name: "a", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "b", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }])


# struct[i]
Expand Down

0 comments on commit 3a4c2b5

Please sign in to comment.