Skip to content

Aggregate value should be true for any_value operator #61

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

Merged
merged 2 commits into from
Jun 13, 2025
Merged

Conversation

mayank0109
Copy link
Contributor

@Copilot Copilot AI review requested due to automatic review settings June 13, 2025 06:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates QueryHelper to ensure that the aggregate value is correctly detected when using the any_value operator.

  • Bumps the library version from 0.4.3 to 0.4.4.
  • Extends the SQL parsing regex to cover the any_value operator by explicitly including both lower- and uppercase variants.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/query_helper/version.rb Version updated to reflect a new release
lib/query_helper/sql_parser.rb Regex altered to recognize any_value aggregate operator

@@ -188,7 +188,7 @@ def find_aliases
ColumnMap.new(
alias_name: sql_alias,
sql_expression: sql_expression.squish,
aggregate: /\b(array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg)\((.*)\)/.match?(sql_expression)
aggregate: /\b(array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg|any_value|ANY_VALUE)\((.*)\)/.match?(sql_expression)
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using a case-insensitive regex flag to handle operator variations (e.g., /i flag), rather than listing both lower and uppercase versions explicitly.

Suggested change
aggregate: /\b(array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg|any_value|ANY_VALUE)\((.*)\)/.match?(sql_expression)
aggregate: /\b(array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg|any_value)\((.*)\)/i.match?(sql_expression)

Copilot uses AI. Check for mistakes.

@@ -188,7 +188,7 @@ def find_aliases
ColumnMap.new(
alias_name: sql_alias,
sql_expression: sql_expression.squish,
aggregate: /\b(array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg)\((.*)\)/.match?(sql_expression)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a search field is fetched using any_value then this regex will return aggregate false for that field due to which filter was applied on where and snowflake query was failing, hence added any_value support in this regex.

@mayank0109 mayank0109 merged commit a9fbb04 into master Jun 13, 2025
6 checks passed
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.

3 participants