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

Concatenate strings with null values doesn't work as expected #6521

Open
iomicifikko opened this issue Apr 9, 2024 · 2 comments
Open

Concatenate strings with null values doesn't work as expected #6521

iomicifikko opened this issue Apr 9, 2024 · 2 comments
Labels
grel The default expression language, GREL, could be improved in many ways! Type: Bug Issues related to software defects or unexpected behavior, which require resolution.

Comments

@iomicifikko
Copy link

  1. Concatanate strings using the sum operator gives always null as output if at least one string is null
  2. The join() function doesn't output null values as expected

Examples

The following code
with("banana", fruit1, with (null, fruit2, fruit1 + ", " + fruit2))
returns
null
instead of
banana,
image

The following code
["banana", null, "apple"].join(", ")
returns
banana, apple
instead of
banana, , apple
image

Reference

https://github.com/OpenRefine/OpenRefine/wiki/Recipes#merging-several-columns
image

Versions

  • Operating System: Windows 11
  • Browser Version: Chrome 123.0.6312.106 (Build ufficiale) (a 64 bit)
  • OpenRefine: 3.7.9 with builtin java
@iomicifikko iomicifikko added Status: Pending Review Indicates that the issue or pull request is awaiting review by project maintainers or collaborators Type: Bug Issues related to software defects or unexpected behavior, which require resolution. labels Apr 9, 2024
@wetneb wetneb added the grel The default expression language, GREL, could be improved in many ways! label Apr 9, 2024
@iomicifikko
Copy link
Author

Other strange behaviors of the JOIN() function with blank / null / empty string values

Image 1
image

Image 2
image

Image 3
image

In my opinion the occurencies of the separator character (the pipe, in the three images above) inside the final string should always be equal to the length of the original array minus one (3 -1 = 2, in the three images above).
The user can easily exclude if necessary any particular values (blanks, nulls...) using the FILTER function on the array before using the JOIN function.

@tfmorris tfmorris removed the Status: Pending Review Indicates that the issue or pull request is awaiting review by project maintainers or collaborators label May 10, 2024
@tfmorris
Copy link
Member

Thanks for the reports. If I could make a request, it would make it much easier to reproduce/fix the issues if you were to:

  • provide the GREL expression and expected result as text rather than an image
  • strip the examples down to the minimum which reproduces the issue (for example, it isn't clear in your last set of examples with the problem is with join() or forEach()
  • put different problems into separate bug reports - this seems to be an amalgam of issues with string concatenation (or with?), join, and, perhaps, forEach. The additional complexity of having them altogether will make it harder for someone to tackle any of the issues.

OpenRefine's treatment of null values has been a little bit uneven (and evolving), as I mentioned in your #3290, which seems like it has a fair bit of overlap with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grel The default expression language, GREL, could be improved in many ways! Type: Bug Issues related to software defects or unexpected behavior, which require resolution.
Projects
None yet
Development

No branches or pull requests

3 participants