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

[Aggregate] Correctly handle ordering multiple fields; don't crash on nil #174

Merged
merged 3 commits into from
Mar 10, 2024

Conversation

ohaibbq
Copy link
Contributor

@ohaibbq ohaibbq commented Feb 21, 2024

Closes #145
Closes goccy/bigquery-emulator#198
Closes #144

@codecov-commenter
Copy link

codecov-commenter commented Feb 21, 2024

Codecov Report

Merging #174 (f57922e) into main (961ce06) will increase coverage by 0.76%.
Report is 12 commits behind head on main.
The diff coverage is 85.36%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #174      +/-   ##
==========================================
+ Coverage   46.39%   47.15%   +0.76%     
==========================================
  Files          47       47              
  Lines       17828    17876      +48     
==========================================
+ Hits         8271     8430     +159     
+ Misses       8111     7983     -128     
- Partials     1446     1463      +17     

query_test.go Outdated
name: "array_concat_agg with null in order by",
query: `WITH toks AS (SELECT ['1'] AS x, '1' as y UNION ALL SELECT ['2', '3'], null) SELECT ARRAY_CONCAT_AGG(x ORDER BY y) FROM toks`,
expectedRows: [][]interface{}{{
[]interface{}{"3", "2", "1"},
Copy link
Owner

Choose a reason for hiding this comment

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

I tried this query in the BigQuery Console and got results 2, 3, 1 .
What do you think about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2, 3, 1 seems correct. I'll take a look at what's going on.

@goccy goccy added the reviewed label Mar 9, 2024
@ohaibbq
Copy link
Contributor Author

ohaibbq commented Mar 9, 2024

It looks like there was also previously a bug with ARRAY_CONCAT_AGG(... LIMIT 1). The LIMIT clause affects the number of arrays aggregated, not the number of elements in the result array.

Copy link
Owner

@goccy goccy left a comment

Choose a reason for hiding this comment

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

Thank you for your awesome PR !! LGTM 👍

@goccy goccy merged commit 7fc7b7c into goccy:main Mar 10, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants