Skip to content

refactor: simplify converting List DataTypes to ScalarValue#10675

Merged
jayzhan211 merged 1 commit intoapache:mainfrom
jonahgao:simplify_try_from
May 26, 2024
Merged

refactor: simplify converting List DataTypes to ScalarValue#10675
jayzhan211 merged 1 commit intoapache:mainfrom
jonahgao:simplify_try_from

Conversation

@jonahgao
Copy link
Copy Markdown
Member

Which issue does this PR close?

N/A

Rationale for this change

ScalarValue::try_from(dt: &DataType) is commonly used to create a NULL ScalarValue for a given DataType.
The processing of List DataTypes is a bit complex and can be simplified.

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

No

new_null_array(
&DataType::FixedSizeList(
Arc::new(Field::new("item", field.data_type().clone(), true)),
1,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it should be the fixed length instead of always being 1.

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jonahgao -- this makes sense to me and I think makes the code look much nicer.

@jayzhan211 if you have time can you also give this PR a review?

jayzhan211

This comment was marked as outdated.

@jayzhan211 jayzhan211 merged commit 52c4f3c into apache:main May 26, 2024
jayzhan211 pushed a commit to jayzhan211/datafusion that referenced this pull request May 26, 2024
@jonahgao
Copy link
Copy Markdown
Member Author

Thank you for the reviewing @alamb @jayzhan211 ❤️

@jonahgao jonahgao deleted the simplify_try_from branch May 26, 2024 13:26
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants