This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 7ef4090ecc feat(go/adbc/drivermgr): support GetStatistics and
GetStatisticNames (#4962)
7ef4090ecc is described below
commit 7ef4090ecca695c2827dae630842a6505b25e18b
Author: Matt Topol <[email protected]>
AuthorDate: Wed Oct 28 18:22:19 2026 +0000
feat(go/adbc/drivermgr): support GetStatistics and GetStatisticNames (#4962)
The Go driver manager wrapper didn't implement
`adbc.ConnectionGetStatistics`, so Go callers couldn't reach
`AdbcConnectionGetStatistics` / `AdbcConnectionGetStatisticNames` even
when the loaded driver supports them.
This PR implements both on the connection. Nil catalog/schema/table
filters are passed as NULL, and a compile-time assertion checks the
interface.
Related: #4957 (option getters for the same wrapper).
---------
Co-authored-by: David Li <[email protected]>
---
go/adbc/drivermgr/wrapper.go | 46 ++++++++++++++++++++++++++++++++
go/adbc/drivermgr/wrapper_sqlite_test.go | 34 +++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/go/adbc/drivermgr/wrapper.go b/go/adbc/drivermgr/wrapper.go
index d84f8f84d4..596439d246 100644
--- a/go/adbc/drivermgr/wrapper.go
+++ b/go/adbc/drivermgr/wrapper.go
@@ -288,6 +288,8 @@ type cnxn struct {
conn *C.struct_AdbcConnection
}
+var _ adbc.ConnectionGetStatistics = (*cnxn)(nil)
+
func (c *cnxn) GetInfo(_ context.Context, infoCodes []adbc.InfoCode)
(array.RecordReader, error) {
var (
out C.struct_ArrowArrayStream
@@ -352,6 +354,50 @@ func (c *cnxn) GetObjects(_ context.Context, depth
adbc.ObjectDepth, catalog, db
return getRdr(&out)
}
+func (c *cnxn) GetStatistics(_ context.Context, catalog, dbSchema, tableName
*string, approximate bool) (array.RecordReader, error) {
+ var (
+ out C.struct_ArrowArrayStream
+ err C.struct_AdbcError
+ catalog_ *C.char
+ dbSchema_ *C.char
+ tableName_ *C.char
+ approximate_ C.char
+ )
+
+ if catalog != nil {
+ catalog_ = C.CString(*catalog)
+ defer C.free(unsafe.Pointer(catalog_))
+ }
+ if dbSchema != nil {
+ dbSchema_ = C.CString(*dbSchema)
+ defer C.free(unsafe.Pointer(dbSchema_))
+ }
+ if tableName != nil {
+ tableName_ = C.CString(*tableName)
+ defer C.free(unsafe.Pointer(tableName_))
+ }
+ if approximate {
+ approximate_ = 1
+ }
+
+ if code := adbc.Status(C.AdbcConnectionGetStatistics(c.conn, catalog_,
dbSchema_, tableName_, approximate_, &out, &err)); code != adbc.StatusOK {
+ return nil, toAdbcError(code, &err)
+ }
+ return getRdr(&out)
+}
+
+func (c *cnxn) GetStatisticNames(_ context.Context) (array.RecordReader,
error) {
+ var (
+ out C.struct_ArrowArrayStream
+ err C.struct_AdbcError
+ )
+
+ if code := adbc.Status(C.AdbcConnectionGetStatisticNames(c.conn, &out,
&err)); code != adbc.StatusOK {
+ return nil, toAdbcError(code, &err)
+ }
+ return getRdr(&out)
+}
+
func (c *cnxn) GetTableSchema(_ context.Context, catalog, dbSchema *string,
tableName string) (*arrow.Schema, error) {
var (
schema C.struct_ArrowSchema
diff --git a/go/adbc/drivermgr/wrapper_sqlite_test.go
b/go/adbc/drivermgr/wrapper_sqlite_test.go
index 0e0b3de0a4..253de89cee 100644
--- a/go/adbc/drivermgr/wrapper_sqlite_test.go
+++ b/go/adbc/drivermgr/wrapper_sqlite_test.go
@@ -344,6 +344,40 @@ func (dm *DriverMgrSuite) TestGetObjectsTableType() {
dm.False(rdr.Next())
}
+func (dm *DriverMgrSuite) TestGetStatisticsNotImplemented() {
+ stats, ok := dm.conn.(adbc.ConnectionGetStatistics)
+ dm.Require().True(ok)
+
+ catalog, dbSchema, tableName := "", "main", "test_table"
+ for _, tc := range []struct {
+ name string
+ catalog, schema, table *string
+ approximate bool
+ }{
+ {"unfiltered approximate", nil, nil, nil, true},
+ {"filtered exact", &catalog, &dbSchema, &tableName, false},
+ } {
+ dm.Run(tc.name, func() {
+ rdr, err := stats.GetStatistics(dm.ctx, tc.catalog,
tc.schema, tc.table, tc.approximate)
+ dm.Nil(rdr)
+ var adbcErr adbc.Error
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusNotImplemented, adbcErr.Code)
+ })
+ }
+}
+
+func (dm *DriverMgrSuite) TestGetStatisticNamesNotImplemented() {
+ stats, ok := dm.conn.(adbc.ConnectionGetStatistics)
+ dm.Require().True(ok)
+
+ rdr, err := stats.GetStatisticNames(dm.ctx)
+ dm.Nil(rdr)
+ var adbcErr adbc.Error
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusNotImplemented, adbcErr.Code)
+}
+
func (dm *DriverMgrSuite) TestGetTableSchema() {
schema, err := dm.conn.GetTableSchema(dm.ctx, nil, nil, "test_table")
dm.NoError(err)