Skip to content

feat: add support for 'WITH' clause in SQL parsing#1124

Open
mirackara wants to merge 1 commit intodevelopfrom
sqlfixes
Open

feat: add support for 'WITH' clause in SQL parsing#1124
mirackara wants to merge 1 commit intodevelopfrom
sqlfixes

Conversation

@mirackara
Copy link
Contributor

Add support for "WITH" clause in SQL parsing

Addresses #1121

@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.07%. Comparing base (1401b37) to head (70ddc32).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1124      +/-   ##
===========================================
- Coverage    79.08%   79.07%   -0.01%     
===========================================
  Files          159      159              
  Lines        14935    14935              
===========================================
- Hits         11811    11810       -1     
- Misses        2712     2713       +1     
  Partials       412      412              

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1401b37...70ddc32. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@cade-conklin cade-conklin left a comment

Choose a reason for hiding this comment

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

Make sure to rebase to develop

}
}
}
func TestParseSQLWith(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test case using WHERE as not the first word to be parsed and check if proper operation is picked up. Could be as a subquery added to TestParseSQLSubQuery or add a test checking WITH and operations where Input contains multiple queries i.e.

{Input: "Select * FROM cte; WITH cte AS (SELECT * FROM users) SELECT * FROM cte;", Operation: "select", Table: "cte"}

}
func TestParseSQLWith(t *testing.T) {
for _, tc := range []sqlTestcase{
{Input: "WITH cte AS (SELECT * FROM users) SELECT * FROM cte", Operation: "with", Table: ""},
Copy link
Contributor

Choose a reason for hiding this comment

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

Does Table (newrelic.DatastoreSegment.Collection) not get populated in this case?

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