Skip to content

Comments

fix string_to_array handle non string delimiter#32081

Merged
ptravers merged 7 commits intoMaterializeInc:mainfrom
ptravers:pt/7101
Apr 3, 2025
Merged

fix string_to_array handle non string delimiter#32081
ptravers merged 7 commits intoMaterializeInc:mainfrom
ptravers:pt/7101

Conversation

@ptravers
Copy link
Contributor

@ptravers ptravers commented Apr 3, 2025

fixes non string handling in string_to_array. currently causing panics.

Motivation

errors in buildkite: https://buildkite.com/materialize/nightly/builds/11690#annotation-0195f3b5-b1bd-440b-8c7e-a445219baf63-error

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@ptravers ptravers requested a review from a team as a code owner April 3, 2025 13:09
@ggevay ggevay self-requested a review April 3, 2025 13:29
Copy link
Contributor

@ParkMyCar ParkMyCar left a comment

Choose a reason for hiding this comment

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

Approving to unblock! Would love to see if changing the function signature would work here though

@ptravers ptravers requested a review from a team as a code owner April 3, 2025 15:58
@ptravers ptravers requested a review from aljoscha April 3, 2025 15:58
@bkirwi bkirwi added release-blocker Critical issue that should block *any* release if not fixed and removed release-blocker Critical issue that should block *any* release if not fixed labels Apr 3, 2025
@doy-materialize doy-materialize mentioned this pull request Apr 3, 2025
5 tasks
@ptravers ptravers merged commit 1d4d92a into MaterializeInc:main Apr 3, 2025
82 checks passed
@ptravers ptravers deleted the pt/7101 branch April 3, 2025 22:53
| Least
| MakeTimestamp
| ArrayIndex { .. }
| StringToArray
Copy link
Contributor

Choose a reason for hiding this comment

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

I think having introduces_nulls return false was correct. Or can you show a case where it returns null despite none of its arguments being null? (true is also ok from a correctness point of view, just not as tight as it could be, so it's better to return false.)

(I admit that the doc comment of introduces_nulls/propagates_nulls is not precise enough. I have a todo to enhance these comments, but it's on page 32 of my 66-page todo doc...)

Copy link
Contributor Author

@ptravers ptravers Apr 10, 2025

Choose a reason for hiding this comment

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

yeah, so basically this is a hack as there's an issue where to return a null at all the function must:

  1. set propagates_null to true
  2. set introduces_null to true

if 1 then for any input parameter being null we auto return null. which is incorrect as parameter two being null does not result in null.

my other solution was to add a third flag to avoid the skipping the function and returning null. @ParkMyCar felt that this was overkill. so we went with this slight hack on introduces_null set to true.

StringToArray => {
ScalarType::Array(Box::new(ScalarType::String)).nullable(input_types[0].nullable)
}
StringToArray => ScalarType::Array(Box::new(ScalarType::String)).nullable(true),
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be missing something, but as far as I can see, it only returns null if the first argument is null. This can only happen if the first argument is nullable. This would mean that the original version was correct.

(Note that some elements of the result array can be null in other cases as well. However, this does not mean that the result itself is nullable.)

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 agree. responded below.

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.

4 participants