Skip to content

Remove unused sqlexec ExecuteScalar, Result.Scalar and StatementError.SQLState - #8113

Open
denik wants to merge 2 commits into
mainfrom
intdep-sqlexec-unused
Open

denik wants to merge 2 commits into
mainfrom
intdep-sqlexec-unused

Conversation

@denik

@denik denik commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Changes

Removes three parts of libs/sqlexec that no production code uses:

  • Client.ExecuteScalar
  • Result.Scalar
  • the StatementError.SQLState field

Tests that only checked them are removed with them:

test change
integration/libs/sqlexec TestSQLExecScalar deleted: apart from ExecuteScalar, it checks that Execute returns rows, which TestSQLExecColumnsAndRows also checks
integration/libs/sqlexec TestSQLExecNullParameter kept, now calls Execute and checks the row: binding an empty --param x= as NULL is behavior experimental aitools tools query relies on
integration/libs/sqlexec TestSQLExecFailedStatement kept, without the SQLState assertion: the typed error's state, code and message are what the CLI reports
libs/sqlexec unit tests TestResultScalar deleted; TestExecuteScalar (now TestExecute), TestExecutePollsUntilTerminal and TestHTTPExecutePolls check Execute's rows instead of ExecuteScalar; one SQLState assertion and one Scalar() assertion dropped

No user-visible change, so no changelog entry.

Why

Part of moving the deprecated integration tests (integration/README.md) to acceptance tests. #8072 ports the sqlexec facts that shipped commands rely on to Cloud = true acceptance tests through experimental aitools tools query and statement: results, parameters, NULL binding, the FAILED error, submit and cancel. What those tests can't reach is code that nothing ships, so it goes instead of being tested. This PR is separate from #8072 so each is easier to review.

Evidence on main (e5eb6a3) before the change:

  • rg 'ExecuteScalar|\.Scalar\(\)|SQLState': outside _test.go files the only hits are the definitions in libs/sqlexec/sqlexec.go, plus libs/testserver/testsql. That package has its own Error.SQLState, which fills the fake API response's sql_state like the real API does, so it stays.
  • go tool -modfile=tools/go.mod deadcode ./... (no -test, so only code reachable from the CLI's main):
    libs/sqlexec/sqlexec.go:193:18: unreachable func: Result.Scalar
    libs/sqlexec/sqlexec.go:320:18: unreachable func: Client.ExecuteScalar
    
    deadcode doesn't report struct fields. StatementError.SQLState is only written in newStatementError and only read by tests.
  • After the change tools/check_deadcode.py reports no dead code.

Tests

  • go test ./libs/sqlexec/...
  • AWS runs of the two edited integration tests: TestSQLExecNullParameter and TestSQLExecFailedStatement pass.

Gaps and risks

This PR was created by the integration-deprecation loop.

🤖 AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

….SQLState

No production code calls them; only tests did. The unit tests that went
through ExecuteScalar now check Execute's rows directly, and the
integration tests drop the parts that only checked the removed API.

Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 1cd2e02

Run: 46011791729

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 175 17 4:24
💚​ aws-windows-latest-4core-16gb 1 175 17 3:28
💚​ azure linux-2core-8gb 1 174 17 4:48
💚​ azure-windows-latest-4core-16gb 1 174 17 3:01
💚​ gcp linux-2core-8gb 1 175 17 4:10
💚​ gcp-windows-latest-4core-16gb 1 175 17 3:34
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 6 slowest tests (at least 2 minutes):
duration env testname
4:48 azure linux-2core-8gb TestAccept
4:05 aws linux-2core-8gb TestAccept
3:43 gcp linux-2core-8gb TestAccept
3:32 gcp-windows-latest-4core-16gb TestAccept
3:06 aws-windows-latest-4core-16gb TestAccept
2:59 azure-windows-latest-4core-16gb TestAccept

@denik
denik marked this pull request as ready for review November 27, 2026 12:23
@denik
denik requested review from a team as code owners November 27, 2026 12:23
@denik
denik requested review from Sankalp-Mittal, andrewnester and mihaimitrea-db and removed request for mihaimitrea-db November 27, 2026 12:23

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at b26807e. Each finding was verified against the code.

No blocking issues found. 1 non-blocking comment(s) below.

This PR removes Client.ExecuteScalar, Result.Scalar and StatementError.SQLState from libs/sqlexec, since nothing reachable from the CLI uses them, and moves the affected tests to Execute's rows. I traced the rewritten tests. Results leaves Rows nil when the response has no data, so the "no rows" case with a nil want still passes. The kept integration tests still cover NULL binding and the FAILED error. The only leftover I found is test fixtures that still set a SQLSTATE nothing reads.

Comment thread libs/sqlexec/sqlexec_http_test.go Resolved
Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik requested a review from andrewnester November 27, 2026 13:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants