Skip to content

Support fixed_size_list for make_array - #6759

Merged
alamb merged 5 commits into
apache:mainfrom
jayzhan211:fixedsizelist_autocast
Jul 5, 2023
Merged

Support fixed_size_list for make_array#6759
alamb merged 5 commits into
apache:mainfrom
jayzhan211:fixedsizelist_autocast

Conversation

@jayzhan211

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Ref #6560

Rationale for this change

Add FixedSizeList support for array methods

What changes are included in this PR?

Only MakeArray is done for this PR.

  1. Add casting from fixedSizeList to list in analyzer (type_coercion).
  2. Support ScalarValue::FixedSizeList, not all feature is implemented
  3. Able to parse List for sqllogictest.

Are these changes tested?

  1. sqllogictest
    array.slt

  2. unit test in type_coercion.rs

Are there any user-facing changes?

Task

  • MakeArray
  • Other array methods

@github-actionsgithub-actionsBot added core Core DataFusion crate optimizer Optimizer rules sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Jun 24, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I create fixedsizelist parquet from my own script.
Is there any existing way for us to easily create/update this kind of test case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for this contribution @jayzhan211 -- I think other than the patch to crates.io this PR is ready to go.

I left some suggestions, which I think would improve the PR

Comment threadCargo.toml Outdated
parquet = { version = "42.0.0", features = ["arrow", "async", "object_store"] }
sqlparser = { version = "0.35", features = ["visitor"] }

[patch.crates-io]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we will have to wait for this code to be released to crates.io (in about 10 days) before merging this PR

ScalarValue::TimestampNanosecond(e, _) => format_option!(f, e)?,
ScalarValue::Utf8(e) => format_option!(f, e)?,
ScalarValue::LargeUtf8(e) => format_option!(f, e)?,
ScalarValue::Binary(e) => match e {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment threaddatafusion/core/tests/sqllogictests/test_files/array.slt
"Date32" => Token::SimpleType(DataType::Date32),
"Date64" => Token::SimpleType(DataType::Date64),

"List" => Token::List,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@alambalamb added the waiting-on-upstream PR is waiting on an upstream dependency to be updated label Jun 26, 2023
@alamb

Copy link
Copy Markdown
Contributor

FYI @izveigor

@tustvold
tustvold changed the base branch from main to backup-mainJune 27, 2023 11:12
@tustvold
tustvold changed the base branch from backup-main to mainJune 27, 2023 11:12
@alamb
alamb marked this pull request as draft June 28, 2023 18:15
@alamb

Copy link
Copy Markdown
Contributor

Marking as a draft as it looks like this PR is not waiting on review -- it is waiting on an upstream release (scheduled early next week) as well as to address some other comments

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
jayzhan211 referenced this pull request Jul 5, 2023
* feat: supports NULL in arrays
* feat: supports NULL in array functions
* fix: array_fill error
* fix: merge
* fix: cargo fmt
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211
jayzhan211force-pushed the fixedsizelist_autocast branch from ecc93dd to c6ba92aCompareJuly 5, 2023 01:04
@github-actionsgithub-actionsBot added the physical-expr Changes to the physical-expr crates label Jul 5, 2023

let list_data_type =
DataType::List(Arc::new(Field::new("item", data_type, false)));
DataType::List(Arc::new(Field::new("item", data_type, true)));

@jayzhan211jayzhan211Jul 5, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Revert the change from #6662 to avoid failure on the schema mismatch

@jayzhan211
jayzhan211 marked this pull request as ready for review July 5, 2023 02:24
@jayzhan211
jayzhan211 marked this pull request as draft July 5, 2023 07:27
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211
jayzhan211 marked this pull request as ready for review July 5, 2023 08:41

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @jayzhan211

@alamb

alamb commented Jul 5, 2023

Copy link
Copy Markdown
Contributor

cc @izveigor

@alamb
alamb merged commit 658206a into apache:mainJul 5, 2023
2010YOUY01 pushed a commit to 2010YOUY01/arrow-datafusion that referenced this pull request Jul 5, 2023
* support make_array for fixed_size_list
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* add arrow-typeof in test
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* fix schema mismatch
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* cleanup code
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* create array data with correct len
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
---------
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
alamb pushed a commit to alamb/datafusion that referenced this pull request Jul 6, 2023
* support make_array for fixed_size_list
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* add arrow-typeof in test
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* fix schema mismatch
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* cleanup code
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* create array data with correct len
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
---------
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coreCore DataFusion crateoptimizerOptimizer rulesphysical-exprChanges to the physical-expr cratessqlSQL PlannersqllogictestSQL Logic Tests (.slt)waiting-on-upstreamPR is waiting on an upstream dependency to be updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jayzhan211@alamb