Skip to content

feat(hive): add Hive built-in driver plugin for data export#3314

Closed
actiontech-bot wants to merge 8 commits into
mainfrom
sqle/feat-2859
Closed

feat(hive): add Hive built-in driver plugin for data export#3314
actiontech-bot wants to merge 8 commits into
mainfrom
sqle/feat-2859

Conversation

@actiontech-bot
Copy link
Copy Markdown
Member

Summary

Add the Hive built-in driver plugin in SQLE so the data export workflow can connect to HiveServer2, audit Hive SELECT statements, and list schemas via SHOW DATABASES.

  • New driver type constant DriverTypeHive (sqle/driver/v2/util.go).
  • New sqle/driver/hive package containing the PluginProcessor + Plugin skeleton, real gohive Open/Ping/Close/Schemas implementation, and unit tests.
  • Register the Hive plugin via a blank import in sqle/server/sqled.go.
  • New transitive deps: github.com/beltran/gohive v1.6.0 + apache/thrift, beltran/gosasl, beltran/gssapi, go-zookeeper/zk; vendor synced.

Fixes actiontech/sqle-ee#2859

Test plan

  • go vet -mod=vendor ./sqle/... (golang:1.24.1, offline vendor)
  • go test -mod=vendor -count=1 ./sqle/driver/hive/... (golang:1.24.1)
  • go build -mod=vendor ./sqle/...
  • CI lint + test

Add DriverTypeHive = "Hive" to the driver type constants block in
sqle/driver/v2/util.go, matching DMS-EE's DBTypeHive value exactly.
This enables the SQLE plugin system to recognize Hive as a valid
database driver type.

issue: #2859
Add Hive plugin directory with PluginProcessor and HiveDriverImpl
implementing the full Plugin interface. Features:
- init() registration to BuiltInPluginProcessors
- GetDriverMetas with PluginName="Hive", port=10000
- additionalParams: auth (NOSASL/NONE/LDAP/KERBEROS), transport_mode (binary/http)
- Parse with SQL splitting and keyword-prefix classification (DQL/DML/DDL)
- Audit returning empty results (no rules in skeleton phase)
- Stub implementations for unsupported methods

issue: #2859
Map-case style tests covering:
- Plugin registration in BuiltInPluginProcessors
- GetDriverMetas: PluginName, DefaultPort, auth/transport_mode params,
  empty Rules and EnabledOptionalModule
- classifySQL: DQL (SELECT/WITH/SHOW/DESCRIBE/DESC/EXPLAIN),
  DML (INSERT/UPDATE/DELETE/MERGE/LOAD/EXPORT), DDL (CREATE/ALTER/DROP/GRANT)
- splitSQL: single/multiple/trailing semicolon/empty/whitespace
- Audit returns correct-length empty results
- Parse with single/multiple/empty SQL
- Ping with nil DSN returns error
- Open with nil DSN succeeds (offline mode)

issue: #2859
Add github.com/beltran/gohive v1.6.0 for real HiveServer2 connectivity
in the SQLE Hive plugin. Transitive deps: apache/thrift v0.19.0,
beltran/gosasl, beltran/gssapi, go-zookeeper/zk v1.0.3.

Version aligned with DMS-EE go.mod to avoid dependency conflicts.
Replace placeholder Ping/Close with real gohive connectivity:
- Add newHiveConnection() that creates gohive.Connection from DSN
  parameters (host, port, user, password, database, auth, transport_mode)
  following DMS-EE NewHiveConn pattern
- Update Open() to establish real connection when DSN is provided
- Update Ping() to execute SELECT 1 via gohive cursor
- Update Close() to close gohive connection
- Add HiveDriverImpl.conn field for connection lifecycle
- Add unit tests for nil conn boundary cases

Offline audit mode (nil DSN) continues to work without connection.
The Hive built-in plugin's init() function was never called because
sqle/server/sqled.go only imported the MySQL driver. Adding the blank
import for github.com/actiontech/sqle/sqle/driver/hive ensures the
Hive plugin registers itself into BuiltInPluginProcessors at startup,
making the Hive data source type available in the DMS driver list.

Fixes #2859
…ASES

The Schemas() method was returning an error "hive plugin does not support
Schemas", causing the /v1/projects/{project}/instances/{instance}/schemas
API to return 500. This blocked the data export workflow as users could
not select a database from the dropdown.

Now executes SHOW DATABASES via gohive cursor and returns the result list.

Fixes BUG-2.1-1
Add vendor entries for github.com/beltran/gohive v1.6.0 and its
transitive deps (apache/thrift, beltran/gosasl, beltran/gssapi,
go-zookeeper/zk). Vendor copies match the go.mod entries in the
preceding commit and were validated by go build/vet/test against
the new sqle/driver/hive package.
@BugsGuru BugsGuru closed this May 22, 2026
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