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

remove regex based normalization #14

Merged
merged 4 commits into from
Oct 17, 2023
Merged

remove regex based normalization #14

merged 4 commits into from
Oct 17, 2023

Conversation

lu-zhengda
Copy link
Collaborator

@lu-zhengda lu-zhengda commented Oct 13, 2023

This PR removes all regex uses in normalization including

  • regex based obfuscated value group. e.g. (?,?) -> (?)
  • regex based sql alias discard

Although regex implementation is easy to write (with help from ChatGPT) and understand, the non-regex approach yields better performance.

Additionally, the PR also pass token pointer to normalizeSQL function to reduce memory usage.

@lu-zhengda lu-zhengda requested a review from a team as a code owner October 13, 2023 20:17
Copy link

@alexandre-normand alexandre-normand 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, just one small question.

normalizer.go Outdated
@@ -60,6 +60,10 @@ type StatementMetadata struct {
Commands []string
}

type GroupablePlaceholder struct {

Choose a reason for hiding this comment

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

Does this need to be an exported type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call. no need to be exportable

@lu-zhengda lu-zhengda merged commit 7efea94 into main Oct 17, 2023
3 checks passed
@lu-zhengda lu-zhengda deleted the zhengda.lu/no-regex branch October 17, 2023 17:57
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