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

fix: added backticks for tags containing dots while generating query … #6727

Merged
merged 10 commits into from
Jan 3, 2025

Conversation

aniketio-ctrl
Copy link
Contributor

@aniketio-ctrl aniketio-ctrl commented Dec 27, 2024

…for v3 and v4 | 6069

Summary

Click house query generated with tags that contains dot in their key name was throwing error, encapsulated that specific keys with backticks.

Related Issues / PR's

#6069

Screenshots

NA

Affected Areas and Manually Tested Areas

Clickhouse queries with tags that have dot in them wont work


Important

Fix ClickHouse query errors by adding backticks to tags with dots in query building and formatting functions.

  • Behavior:
    • Fix ClickHouse query errors by adding backticks to tags with dots in query_builder.go, clauses.go, and sub_query.go.
    • Update AddBackTickToFormatTag and AddBackTickToFormatTags in format.go to handle tags with dots.
  • Functions:
    • Modify groupingSets, groupBy, groupSelect, and orderBy in query_builder.go to use backticks for tags.
    • Update GroupingSetsByAttributeKeyTags, GroupByAttributeKeyTags, and OrderByAttributeKeyTags in clauses.go to add backticks.
    • Adjust PrepareTimeseriesFilterQuery and PrepareTimeseriesFilterQueryV3 in sub_query.go to format tags with backticks.
  • Tests:
    • Add test cases in query_builder_test.go, table_test.go, and timeseries_test.go for cumulative and delta metrics to verify queries with tags containing dots.

This description was created by Ellipsis for ebf50fc. It will automatically update as commits are pushed.

@CLAassistant
Copy link

CLAassistant commented Dec 27, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ srikanthccv
❌ Aniket


Aniket seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the bug Something isn't working label Dec 27, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Reviewed everything up to b409724 in 1 minute and 54 seconds

More details
  • Looked at 153 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/query-service/app/metrics/v3/query_builder.go:220
  • Draft comment:
    Ensure utils.AddBackTickToFormatTags is applied consistently across all functions that handle tags, such as groupingSets, groupBy, groupSelect, and orderBy. This is crucial for SQL syntax correctness when dealing with tags containing dots.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. pkg/query-service/app/metrics/v4/helpers/clauses.go:22
  • Draft comment:
    Ensure utils.AddBackTickToFormatTag is applied consistently across all functions that handle tags, such as GroupingSetsByAttributeKeyTags, GroupByAttributeKeyTags, and OrderByAttributeKeyTags. This is crucial for SQL syntax correctness when dealing with tags containing dots.
  • Reason this comment was not posted:
    Marked as duplicate.
3. pkg/query-service/app/metrics/v4/helpers/sub_query.go:325
  • Draft comment:
    Ensure utils.AddBackTickToFormatTag is applied consistently across all functions that handle tags, such as in PrepareTimeseriesFilterQuery and PrepareTimeseriesFilterQueryV3. This is crucial for SQL syntax correctness when dealing with tags containing dots.
  • Reason this comment was not posted:
    Marked as duplicate.
4. pkg/query-service/app/metrics/v3/query_builder.go:217
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code. This is applicable in other files as well.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_SSyBHF56SP0ESaiE


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@srikanthccv srikanthccv self-requested a review December 27, 2024 07:46
Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

Few comments, also please add tests.

pkg/query-service/utils/format.go Show resolved Hide resolved
pkg/query-service/app/metrics/v4/helpers/clauses.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 0fd63ca in 52 seconds

More details
  • Looked at 284 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/query-service/app/metrics/v4/helpers/clauses.go:48
  • Draft comment:
    Modifying item.ColumnName directly can lead to side effects. Consider using a local variable for the modified column name instead.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    In Go, range loop variables for slices are copies, not references. Modifying item.ColumnName only affects the copy, not the original slice. The modified value is only used immediately after in the fmt.Sprintf() call. There's no evidence of any actual side effects or issues. The suggestion to use a local variable would just add unnecessary verbosity.
    I could be wrong about the scope of usage - perhaps the modified items slice is used elsewhere in the codebase. Also, using a local variable could make the code more readable.
    Even if the items slice is used elsewhere, modifying the loop variable is still safe due to Go's value semantics. The code is already quite readable and a local variable would add unnecessary complexity.
    The comment raises a non-issue since modifying the loop variable is safe in this context and the current code is clear and concise.
2. pkg/query-service/app/metrics/v4/helpers/clauses.go:54
  • Draft comment:
    Redundant backtick formatting for tag.Key here. It's already formatted in the loop above. Remove this line to avoid unnecessary operations.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_7ogB5F8afupdoRzK


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on df9f630 in 22 seconds

More details
  • Looked at 80 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/query-service/app/metrics/v4/query_builder_test.go:537
  • Draft comment:
    The test case for handling tags with dots in their names is well-structured and ensures that the query is correctly formatted with backticks. This aligns with the intended fix.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The test case added for handling tags with dots in their names is appropriate and follows the pattern of existing test cases. It ensures that the query is correctly formatted with backticks for such tags.
2. pkg/query-service/app/metrics/v4/query_builder_test.go:533
  • Draft comment:
    Use design tokens or predefined color constants instead of hardcoding color values to maintain consistency in design and theming. This applies to the expected query strings in the test cases.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_2WYZ6GfOD85wua3E


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 93864d4 in 55 seconds

More details
  • Looked at 335 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. pkg/query-service/app/metrics/v3/query_builder.go:270
  • Draft comment:
    Consider applying utils.AddBackTickToFormatTags to tags before the loop to ensure all tags are consistently formatted with backticks. This will prevent any potential inconsistencies if tags is used elsewhere without backticks.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The change in the code appears deliberate and actually improves the code by applying backticks at the exact point where each tag is used. The old approach of formatting all tags upfront was less precise. The comment is suggesting to revert to a less optimal approach. The new code is cleaner and there's no evidence of any inconsistency issues.
    Could there be a performance benefit to formatting all tags at once rather than individually? Could there be edge cases where formatting tags individually produces different results?
    The performance difference would be negligible since this is just string manipulation. The individual formatting approach is actually safer as it ensures each tag is formatted exactly when needed, avoiding any potential issues with tags being used in different contexts.
    Delete the comment. The code change is an improvement that formats tags at the point of use, which is cleaner and more precise than formatting all tags upfront.

Workflow ID: wflow_uDDj6CSywdJupZxo


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on ebf50fc in 52 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. frontend/src/constants/env.ts:3
  • Draft comment:
    Optional chaining with process.env is unnecessary since process.env is always defined in Node.js. Consider removing the ?. operators for cleaner code.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is technically correct - in Node.js, process.env is always defined. However, this code is in the frontend directory and appears to be client-side code. In browser environments, process may be undefined unless explicitly provided. The comment makes an incorrect assumption about the execution environment.
    Am I certain this is client-side code? Could this be used in both Node.js and browser environments?
    The file path frontend/src/constants/env.ts strongly indicates this is client-side code. Even if used in both environments, the optional chaining makes the code more robust for browser usage.
    The comment should be deleted because it incorrectly assumes Node.js environment for frontend code where optional chaining is actually beneficial.
2. frontend/src/constants/env.ts:2
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_QhJgSWEohiDR3WNB


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@srikanthccv
Copy link
Member

@aniketio-ctrl please revert unwanted changes.

@aniketio-ctrl
Copy link
Contributor Author

aniketio-ctrl commented Jan 3, 2025

@aniketio-ctrl please revert unwanted changes.

hey already reverted , pushed those by mistakes

@aniketio-ctrl aniketio-ctrl removed the request for review from YounixM January 3, 2025 05:09
@srikanthccv srikanthccv enabled auto-merge (squash) January 3, 2025 05:15
@srikanthccv srikanthccv merged commit c5938b6 into main Jan 3, 2025
15 of 16 checks passed
@srikanthccv srikanthccv deleted the fix/6069 branch January 3, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants