Skip to content

Automated Test: advanced-sql-analytics #339

Closed

Conversation

admin-coderabbit
Copy link
Owner

@admin-coderabbit admin-coderabbit commented Feb 4, 2026

This pull request was automatically created by @coderabbitai/e2e-reviewer.

Batch created pull request.

Summary by CodeRabbit

  • Chores
    • Removed external SQL database-related dependencies and consolidated SQL processing functionality into a new lightweight internal in-memory implementation. This improves code maintainability and provides enhanced control over SQL feature management.
    • Implemented runtime validation for the SQL expressions feature to ensure proper availability verification during execution.

… vulnerability (#94942)

* disable sql expressions

remove duckdb ref

* Run `make update-workspace`

---------

Co-authored-by: Scott Lepper <scott.lepper@gmail.com>
@coderabbit-eval
Copy link

coderabbit-eval bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

This PR removes an external DuckDB dependency and replaces it with a local in-memory SQL database implementation. Additionally, a runtime check is introduced to gate SQL expression functionality, currently returning "not implemented" to block the feature.

Changes

Cohort / File(s) Summary
Dependency Cleanup
go.mod
Removed 8 dependencies including direct dependency on github.com/scottlepp/go-duck and indirect dependencies (overflow, Apache Thrift, MinIO tooling, etc.). No new dependencies added.
SQL Database Abstraction
pkg/expr/sql/db.go
Introduced new in-memory database skeleton with DB type and stub methods: TablesList(), RunCommands(), QueryFramesInto(), and NewInMemoryDB() constructor. All methods currently return "not implemented" errors.
External to Local Migration
pkg/expr/sql/parser.go, pkg/expr/sql_command.go
Replaced external duck.NewInMemoryDB() calls with local sql.NewInMemoryDB(). Removed duck package imports and updated variable naming for consistency.
SQL Expression Runtime Gating
pkg/expr/reader.go
Added enableSqlExpressions() helper function (currently returns false) to gate SQL expression processing in QueryTypeSQL handler, returning "sqlExpressions is not implemented" error when disabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop away, old Duck—we've built our own!
Local databases now fully grown,
Stub methods wait for features to bloom,
While gates keep SQL safe in its room. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Automated Test: advanced-sql-analytics' is vague and does not clearly describe the actual changes made in the pull request. Use a more descriptive title that summarizes the primary change, such as 'Replace external DuckDB dependency with local in-memory SQL database implementation' or 'Implement local SQL database backend and disable SQL expressions by default'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch advanced-sql-analytics

Comment @coderabbit eval help to get the list of available commands and usage tips.

@coderabbit-eval coderabbit-eval bot closed this Feb 4, 2026
Copy link

@coderabbit-eval coderabbit-eval bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/expr/sql_command.go (1)

110-118: ⚠️ Potential issue | 🟠 Major

Dead code: NoData branch is immediately overwritten.

When frame.Rows() == 0, lines 111-113 set rsp.Values to NoData, but execution falls through to lines 116-118 which unconditionally overwrite rsp.Values with TableData. The NoData case is never returned. This appears to be a pre-existing bug — likely a missing else or early return.

Proposed fix
 	if frame.Rows() == 0 {
 		rsp.Values = mathexp.Values{
 			mathexp.NoData{Frame: frame},
 		}
-	}
-
-	rsp.Values = mathexp.Values{
-		mathexp.TableData{Frame: frame},
+	} else {
+		rsp.Values = mathexp.Values{
+			mathexp.TableData{Frame: frame},
+		}
 	}
🤖 Fix all issues with AI agents
In `@pkg/expr/reader.go`:
- Around line 194-200: The function enableSqlExpressions currently always
returns false and inverts the feature flag; fix it by either (A) making the
intent explicit to permanently block SQL expressions by replacing the body with
a single unambiguous return false, or (B) gating correctly on the feature flag
by returning the direct result of
h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions) so
enableSqlExpressions(h *ExpressionQueryReader) reflects the flag; update the
implementation of enableSqlExpressions and remove the inverted logic to avoid
future confusion.
🧹 Nitpick comments (1)
pkg/expr/reader.go (1)

128-138: Gate correctly blocks the SQL path, but error message could be more informative.

The gate works as intended since enableSqlExpressions always returns false. Minor suggestion: include a hint that this is behind a feature flag so operators know it's intentionally disabled.

-		return eq, fmt.Errorf("sqlExpressions is not implemented")
+		return eq, fmt.Errorf("SQL expressions are not enabled; this feature is not yet implemented")

Comment on lines +194 to +200
func enableSqlExpressions(h *ExpressionQueryReader) bool {
enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
if enabled {
return false
}
return false
}

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

enableSqlExpressions always returns false — logic is misleading and likely buggy.

This function unconditionally returns false regardless of the feature flag state:

  1. enabled := !h.features.IsEnabledGlobally(...) — the negation inverts the meaning, so enabled is true when the flag is off.
  2. Both the if enabled branch and the fallthrough return false.

If the intent is to permanently block SQL expressions for now, simplify to return false to make the intent clear. If the intent is to eventually gate on the feature flag, the correct implementation would be:

func enableSqlExpressions(h *ExpressionQueryReader) bool {
    return h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
}

The current code is a maintenance hazard — a future developer removing one of the return false statements would still face the inverted boolean, resulting in the feature being enabled when the flag is off and disabled when it's on.

Proposed fix (if intent is to always block)
 func enableSqlExpressions(h *ExpressionQueryReader) bool {
-	enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
-	if enabled {
-		return false
-	}
 	return false
 }
Proposed fix (if intent is to respect the feature flag)
 func enableSqlExpressions(h *ExpressionQueryReader) bool {
-	enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
-	if enabled {
-		return false
-	}
-	return false
+	return h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
 }
🤖 Prompt for AI Agents
In `@pkg/expr/reader.go` around lines 194 - 200, The function enableSqlExpressions
currently always returns false and inverts the feature flag; fix it by either
(A) making the intent explicit to permanently block SQL expressions by replacing
the body with a single unambiguous return false, or (B) gating correctly on the
feature flag by returning the direct result of
h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions) so
enableSqlExpressions(h *ExpressionQueryReader) reflects the flag; update the
implementation of enableSqlExpressions and remove the inverted logic to avoid
future confusion.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant