You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "yevgenypats (via GitHub)" <gi...@apache.org> on 2023/04/16 14:04:07 UTC
[GitHub] [arrow] yevgenypats opened a new pull request, #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
yevgenypats opened a new pull request, #35161:
URL: https://github.com/apache/arrow/pull/35161
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
### What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
### Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
### Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
-->
<!-- **This PR includes breaking changes to public APIs.** -->
<!--
Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
-->
<!-- **This PR contains a "Critical Fix".** -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35161:
URL: https://github.com/apache/arrow/pull/35161#issuecomment-1510390034
* Closes: #35160
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] yevgenypats commented on a diff in pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "yevgenypats (via GitHub)" <gi...@apache.org>.
yevgenypats commented on code in PR #35161:
URL: https://github.com/apache/arrow/pull/35161#discussion_r1169255815
##########
go/arrow/array/binarybuilder.go:
##########
@@ -319,7 +320,10 @@ func (b *BinaryBuilder) UnmarshalOne(dec *json.Decoder) error {
case string:
data, err := base64.StdEncoding.DecodeString(v)
if err != nil {
- return err
+ data, err = hex.DecodeString(v)
+ if err != nil {
+ return err
+ }
Review Comment:
Hmm....Prob it was in another branch and ended up here. will remove
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] zeroshade commented on a diff in pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #35161:
URL: https://github.com/apache/arrow/pull/35161#discussion_r1168824967
##########
go/arrow/array/binarybuilder.go:
##########
@@ -319,7 +320,10 @@ func (b *BinaryBuilder) UnmarshalOne(dec *json.Decoder) error {
case string:
data, err := base64.StdEncoding.DecodeString(v)
if err != nil {
- return err
+ data, err = hex.DecodeString(v)
+ if err != nil {
+ return err
+ }
Review Comment:
this seems odd to add here. Should we also add this to `AppendValueFromString` and update the docs that you can also use hex to specify binary strings?
##########
go/arrow/array/compare.go:
##########
@@ -630,6 +631,34 @@ func validityBitmapEqual(left, right arrow.Array) bool {
return true
}
+func stripNulls(s string) string {
+ return strings.ReplaceAll(s, "\x00", "")
+}
+
Review Comment:
In the Arrow spec a String array should be all valid utf8. So shouldn't this only be for trimming trailing Nulls? (ie: use `strings.TrimRight` instead of `strings.ReplaceAll` )?
To this end, can you have a test with a string that contains a null inside it that *isn't* at the end and ensure that this approxequal only trims nulls, and doesn't strip them from within the string?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] yevgenypats commented on a diff in pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "yevgenypats (via GitHub)" <gi...@apache.org>.
yevgenypats commented on code in PR #35161:
URL: https://github.com/apache/arrow/pull/35161#discussion_r1170516104
##########
go/arrow/array/compare.go:
##########
@@ -630,6 +631,34 @@ func validityBitmapEqual(left, right arrow.Array) bool {
return true
}
+func stripNulls(s string) string {
+ return strings.ReplaceAll(s, "\x00", "")
+}
+
Review Comment:
Interesting, wasn't aware of the valid utf8 specification. In that case there is no check in `string.Append` [method](https://github.com/cloudquery/arrow/blob/main/go/arrow/array/string.go#L321) to make sure there are no nulls inside the string. Should we add this check or string nulls inside the string? wdyt?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-35160: [Go] Add arrayApproxEqualString to ignore null chars [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35161:
URL: https://github.com/apache/arrow/pull/35161#issuecomment-2319657929
:warning: GitHub issue #35160 **has no components**, please add labels for components.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] yevgenypats closed pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "yevgenypats (via GitHub)" <gi...@apache.org>.
yevgenypats closed pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
URL: https://github.com/apache/arrow/pull/35161
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] zeroshade commented on pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #35161:
URL: https://github.com/apache/arrow/pull/35161#issuecomment-1535117033
@yevgenypats are you still planning on working on this? It still needs the that hex change removed etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] yevgenypats commented on pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "yevgenypats (via GitHub)" <gi...@apache.org>.
yevgenypats commented on PR #35161:
URL: https://github.com/apache/arrow/pull/35161#issuecomment-1535223121
Let's close this for now and I might open this once again a bit later, Im not sure if this is needed after your comment regarding nulls.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] zeroshade commented on a diff in pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #35161:
URL: https://github.com/apache/arrow/pull/35161#discussion_r1171445177
##########
go/arrow/array/compare.go:
##########
@@ -630,6 +631,34 @@ func validityBitmapEqual(left, right arrow.Array) bool {
return true
}
+func stripNulls(s string) string {
+ return strings.ReplaceAll(s, "\x00", "")
+}
+
Review Comment:
So for performance reasons we don't validate the utf8 strings on Append currently and leave it up to the producer to ensure that they are passing valid utf-8 strings when constructing the array (if it's not valid utf-8 they should be using a Binary array).
On my list of things to do eventually is a "Validate" method for each array type like the C++ library has. That "Validate" method would do the UTF-8 validity check on the buffer so that a consumer can choose *when* they take the performance hit for validating the utf-8.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35161:
URL: https://github.com/apache/arrow/pull/35161#issuecomment-1510390048
:warning: GitHub issue #35160 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] yevgenypats commented on a diff in pull request #35161: GH-35160: [Go] Add arrayApproxEqualString to ignore null chars
Posted by "yevgenypats (via GitHub)" <gi...@apache.org>.
yevgenypats commented on code in PR #35161:
URL: https://github.com/apache/arrow/pull/35161#discussion_r1170516104
##########
go/arrow/array/compare.go:
##########
@@ -630,6 +631,34 @@ func validityBitmapEqual(left, right arrow.Array) bool {
return true
}
+func stripNulls(s string) string {
+ return strings.ReplaceAll(s, "\x00", "")
+}
+
Review Comment:
Interesting, wasn't aware of the valid utf8 specification that can't contain NULLs in the middle of the string. In that case there is no check in `string.Append` [method](https://github.com/cloudquery/arrow/blob/main/go/arrow/array/string.go#L321) to make sure there are no nulls inside the string. Should we add this check or string nulls inside the string? wdyt?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org