Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix make_array null handling, update tests #6900

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jul 10, 2023

Which issue does this PR close?

Closes #6887

Rationale for this change

Fix a bug (see #6887)

What changes are included in this PR?

NOTE this PR looks large, but has only 4 lines of code changes. The rest of it is doc comments and tests

  1. Check for null when creating new arrays
  2. Add tests
  3. Add docstrings / ASCII art

Are these changes tested?

yes

Are there any user-facing changes?

fix regression

@github-actions github-actions bot added physical-expr Physical Expressions core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jul 10, 2023
Comment on lines +101 to +105
if arr.is_valid(index) {
builder.values().append_value(arr.value(index));
} else {
builder.values().append_null();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lines are the only actual code change; The rest of this PR is doc comments and tests

(6, 11, NULL, 7.7, 'consectetur'),
(7, 13, 14, NULL, 'adipiscing'),
(8, 15, 16, 8.8, NULL)
(1, 1, 2, 1.1, 'Lorem', 'A'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adds a new column, e and whitespace OCD

# make_array with columns #2
# make_array with 1 columns
query ???
select make_array(a), make_array(d), make_array(e) from values;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke out the tests for make_array with a single column from the tests of make_array with 2 column

@alamb
Copy link
Contributor Author

alamb commented Jul 10, 2023

cc @izveigor

/// │ │ [C, Z] │ │ │ │ NULL │ │ │ │ [C, Z, NULL] │ │
/// │ └──────────┘ │ │ └──────────┘ │ │ └────────────────────┘ │
/// └──────────────┘ └──────────────┘ └────────────────────────┘
/// col1 col2 output
Copy link
Contributor

Choose a reason for hiding this comment

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

There are good comments 👍
I think we can make a custom template for all array functions.

Copy link
Contributor

@izveigor izveigor left a comment

Choose a reason for hiding this comment

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

LGTM!

@alamb alamb merged commit 311e8c7 into apache:main Jul 11, 2023
@alamb alamb deleted the alamb/make_array_null branch July 11, 2023 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make_array does not properly support nulls
2 participants