Skip to content

fix incorrect split for select query #754

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

Open
wants to merge 6 commits into
base: v2
Choose a base branch
from

Conversation

LYHuang
Copy link

@LYHuang LYHuang commented Apr 16, 2025

  • add new split function for brackets and quotes selection
  • should only affect SELECT section in search component
  • add test
image

Ref: hdx-1587

Copy link

changeset-bot bot commented Apr 16, 2025

⚠️ No Changeset found

Latest commit: a4ab3c1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -699,7 +702,7 @@ function mergeSelectWithPrimaryAndPartitionKey(
primaryKeys.trim() !== '' ? splitAndTrimCSV(primaryKeys) : [];
const allKeys = [...partitionKeyArr, ...primaryKeyArr];
if (typeof select === 'string') {
const selectSplit = splitAndTrimCSV(select);
Copy link
Author

Choose a reason for hiding this comment

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

This is the root cause, make input:
JSONExtractString(Body, 'object', 'c'),JSONExtractString(Body, 'object', 'note')
become
["JSONExtractString(Body", "'object'", "'c')", "'note')"]
after dedupe set(selectColumns).

Copy link
Member

@wrn14897 wrn14897 Apr 16, 2025

Choose a reason for hiding this comment

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

Good find! have we thought about using module like csv-parse? (https://www.npmjs.com/package/csv-parse)

Copy link
Author

@LYHuang LYHuang Apr 17, 2025

Choose a reason for hiding this comment

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

I checked the csv-parse, however it does not work well with parentheses and brackets.
Parsing option quote only works for same character such as: "content", and it must at the beginning of the string, ex: "good", err"or".

Copy link
Member

Choose a reason for hiding this comment

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

got it. in this case, I think we want to make sure the unit tests cover all use cases. Does it work with the select field like "foo,bar",field2,field3 as well?

Copy link
Author

Choose a reason for hiding this comment

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

It will split it to:

[
  '"foo',
  'bar"',
  'field2',
  'field3'
]

It should works fine if we don't get the input like: "foo,bar","foo,differentBar",field2,field3 and also doing the dedupe.

Copy link
Author

Choose a reason for hiding this comment

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

I will work on quote stuff, will update PR later.

Copy link
Member

Choose a reason for hiding this comment

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

cool, I'd imagine the return value from the example above is ["foo,bar", "field2", "field3"] although it's a corner case

Copy link
Author

Choose a reason for hiding this comment

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

update the split function to support single quote and double quote, feel free to check test case.

@LYHuang LYHuang marked this pull request as ready for review April 16, 2025 05:34
@LYHuang LYHuang requested a review from wrn14897 April 17, 2025 02:59
Copy link

vercel bot commented Apr 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hyperdx-v2-oss-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2025 10:54am

@wrn14897
Copy link
Member

We should also replace splitAndTrimCSV with new function

Copy link
Member

@wrn14897 wrn14897 left a comment

Choose a reason for hiding this comment

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

Great fix. Thank you!

@kodiakhq kodiakhq bot removed the automerge label Apr 18, 2025
Copy link

kodiakhq bot commented Apr 18, 2025

This PR currently has a merge conflict. Please resolve this and then re-add the automerge label.

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.

2 participants