-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced SQL Analytics Framework #2
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
base: data-analysis-features
Are you sure you want to change the base?
Advanced SQL Analytics Framework #2
Conversation
… vulnerability (#94942) * disable sql expressions remove duckdb ref * Run `make update-workspace` --------- Co-authored-by: Scott Lepper <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 2/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant ExpressionQueryReader
participant SQLCommand
participant DB as sql.DB (Stub)
participant Parser as sql.Parser
User->>ExpressionQueryReader: ReadQuery(QueryTypeSQL)
ExpressionQueryReader->>ExpressionQueryReader: enableSqlExpressions()
Note over ExpressionQueryReader: Always returns false<br/>(broken logic)
ExpressionQueryReader-->>User: Error: "sqlExpressions is not implemented"
Note over User,Parser: If feature flag check was fixed:
User->>SQLCommand: NewSQLCommand(refID, rawSQL)
SQLCommand->>Parser: TablesList(rawSQL)
Parser->>DB: NewInMemoryDB()
activate DB
Parser->>DB: RunCommands([cmd])
DB-->>Parser: Error: "not implemented"
deactivate DB
Parser-->>SQLCommand: Error
SQLCommand-->>User: Error: "error serializing sql"
User->>SQLCommand: Execute(ctx, now, vars)
SQLCommand->>DB: NewInMemoryDB()
activate DB
SQLCommand->>DB: QueryFramesInto(refID, query, frames, frame)
DB-->>SQLCommand: Error: "not implemented"
deactivate DB
SQLCommand-->>User: Results with error
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, 2 comments
| func enableSqlExpressions(h *ExpressionQueryReader) bool { | ||
| enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions) | ||
| if enabled { | ||
| return false | ||
| } | ||
| return false | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: enableSqlExpressions always returns false - the logic is broken
The function negates the feature flag check then returns false regardless. This means SQL expressions will ALWAYS be disabled, even if the feature flag is enabled. The logic should be:
| func enableSqlExpressions(h *ExpressionQueryReader) bool { | |
| enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions) | |
| if enabled { | |
| return false | |
| } | |
| return false | |
| } | |
| func enableSqlExpressions(h *ExpressionQueryReader) bool { | |
| return h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions) | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/expr/reader.go
Line: 194:200
Comment:
**logic:** `enableSqlExpressions` always returns `false` - the logic is broken
The function negates the feature flag check then returns false regardless. This means SQL expressions will ALWAYS be disabled, even if the feature flag is enabled. The logic should be:
```suggestion
func enableSqlExpressions(h *ExpressionQueryReader) bool {
return h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
}
```
How can I resolve this? If you propose a fix, please make it concise.| func (db *DB) TablesList(rawSQL string) ([]string, error) { | ||
| return nil, errors.New("not implemented") | ||
| } | ||
|
|
||
| func (db *DB) RunCommands(commands []string) (string, error) { | ||
| return "", errors.New("not implemented") | ||
| } | ||
|
|
||
| func (db *DB) QueryFramesInto(name string, query string, frames []*data.Frame, f *data.Frame) error { | ||
| return errors.New("not implemented") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: All DB methods return "not implemented" errors
The DB struct methods are stubs that will cause runtime failures. TablesList, RunCommands, and QueryFramesInto all return "not implemented" errors, but parser.go:23 and sql_command.go:96-100 call these methods expecting them to work.
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/expr/sql/db.go
Line: 12:22
Comment:
**logic:** All DB methods return "not implemented" errors
The `DB` struct methods are stubs that will cause runtime failures. `TablesList`, `RunCommands`, and `QueryFramesInto` all return "not implemented" errors, but `parser.go:23` and `sql_command.go:96-100` call these methods expecting them to work.
How can I resolve this? If you propose a fix, please make it concise.
Test 9
Replicated from ai-code-review-evaluation/grafana-greptile#9