Skip to content

Conversation

@candiduslynx
Copy link
Contributor

@candiduslynx candiduslynx commented May 30, 2023

Rationale for this change

If we store the value of the *array.Map into Go map we can't expect to put the values back in the same order, as the map traversal order in Go is undefined.
This PR extends array.ApproxEqual by allowing map keys to be in different order.

What changes are included in this PR?

New helper functions:

  • array.arrayApproxEqualMap that is now used instead of array.arrayApproxEqualList for map comparison
  • array.arrayApproxEqualSingleMapEntry that checks if the single map entry we have matches to the other one without having keys sorted the same way

Are these changes tested?

  1. Newly added test array.TestArrayApproxEqualMaps
  2. fix(deps): Update github.com/cloudquery/plugin-sdk/v3 to v3.8.1 cloudquery/cloudquery#11078

Are there any user-facing changes?

New array.WithUnorderedMapKeys option for array.ApproxEqual that allows users to control if the entries order is important or not.

@candiduslynx candiduslynx requested a review from zeroshade as a code owner May 30, 2023 12:49
@github-actions
Copy link

Thanks for opening a pull request!

If this is not a minor PR. 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 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}

See also:

candiduslynx added a commit to cloudquery/cloudquery that referenced this pull request May 30, 2023
candiduslynx added a commit to cloudquery/cloudquery that referenced this pull request May 30, 2023
candiduslynx added a commit to cloudquery/cloudquery that referenced this pull request May 30, 2023
@candiduslynx candiduslynx changed the title [Go] array.ApproxEqual allows map entries with different key order MINOR: [Go] array.ApproxEqual allows map entries with different key order May 30, 2023
@candiduslynx
Copy link
Contributor Author

candiduslynx commented May 30, 2023

@zeroshade it seems there's still a flaky test in FlightSQL

@zeroshade
Copy link
Member

@candiduslynx yea, I'm aware. I've been periodically trying to track down the cause of the flakiness but haven't yet been able to do so. I'll kick the tires and re-run it, it should go away. Hopefully I (or someone) is able to track down the cause soon. It's quite annoying.

In the meantime, I'll take a look at this in a bit. Thanks!

@raulcd
Copy link
Member

raulcd commented May 30, 2023

Can we create an issue for this one? It doesn't feel it matches the requirements for a MINOR one as seen here: https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#minor-fixes

@candiduslynx candiduslynx changed the title MINOR: [Go] array.ApproxEqual allows map entries with different key order GH-35828: [Go] array.ApproxEqual allows map entries with different key order May 30, 2023
@candiduslynx
Copy link
Contributor Author

@zeroshade I've opened #35828

@github-actions
Copy link

⚠️ GitHub issue #35828 has been automatically assigned in GitHub to PR creator.

@raulcd
Copy link
Member

raulcd commented May 30, 2023

@zeroshade I've opened #35828

Thank you!

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels May 30, 2023
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels May 30, 2023
@candiduslynx candiduslynx requested a review from zeroshade May 30, 2023 17:51
@candiduslynx candiduslynx changed the title GH-35828: [Go] array.ApproxEqual allows map entries with different key order GH-35828: [Go] Add array.WithUnorderedMapKeys option for array.ApproxEqual May 30, 2023
@candiduslynx
Copy link
Contributor Author

@zeroshade I've moved the control over the new behavior into an option, so the users will not have any breaking changes.

@candiduslynx
Copy link
Contributor Author

@zeroshade is there a chance to get it merged sooner? It's a blocker for cloudquery/cloudquery#11078

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels May 31, 2023
Copy link
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

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

looks good in general to me, just one question about the WithUnorderedMapKeys vs just checking the KeysSorted member of the MapType and deciding to go with the Unordered check if KeysSorted is false.

@candiduslynx
Copy link
Contributor Author

looks good in general to me, just one question about the WithUnorderedMapKeys vs just checking the KeysSorted member of the MapType and deciding to go with the Unordered check if KeysSorted is false.

@zeroshade I've looked at the KeysSorted and it doesn't guarantee anything in the code (as well as the docstring for it states that this value isn't used in comparison in any way).

I believe updating the code to use KeysSorted is a breaking change & it should also imply the need to check for the entries order in the builder. So, I'd rather go with WithUnorderedMapKeys option for now & let someone who is really sure they need this functionality open an issue for this.

@candiduslynx candiduslynx requested a review from zeroshade May 31, 2023 15:30
Copy link
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

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

@candiduslynx that sounds good to me and works fine.

@zeroshade zeroshade merged commit d9c2d59 into apache:main May 31, 2023
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting changes Awaiting changes labels May 31, 2023
@candiduslynx candiduslynx deleted the feat/map-approx-equal branch May 31, 2023 17:52
kodiakhq bot pushed a commit to cloudquery/plugin-sdk that referenced this pull request Jun 1, 2023
candiduslynx added a commit to cloudquery/cloudquery that referenced this pull request Jun 1, 2023
candiduslynx added a commit to cloudquery/cloudquery that referenced this pull request Jun 1, 2023
@ursabot
Copy link

ursabot commented Jun 1, 2023

Benchmark runs are scheduled for baseline = fee8bf9 and contender = d9c2d59. d9c2d59 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.88% ⬆️0.18%] test-mac-arm
[Finished ⬇️1.3% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.27% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] d9c2d596 ec2-t3-xlarge-us-east-2
[Finished] d9c2d596 test-mac-arm
[Finished] d9c2d596 ursa-i9-9960x
[Finished] d9c2d596 ursa-thinkcentre-m75q
[Finished] fee8bf9c ec2-t3-xlarge-us-east-2
[Finished] fee8bf9c test-mac-arm
[Finished] fee8bf9c ursa-i9-9960x
[Finished] fee8bf9c ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

kodiakhq bot pushed a commit to cloudquery/cloudquery that referenced this pull request Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] array.ApproxEqual should allow map entries be presented in any order

4 participants