This is an automated email from the ASF dual-hosted git repository.
lidavidm 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 a0b9b1e6a feat(c/driver/postgresql): include xdbc_type_name in
GetObjects (#4457)
a0b9b1e6a is described below
commit a0b9b1e6a8111cee848dfadbc6bc5b46ef56e008
Author: Shubham Pandey <[email protected]>
AuthorDate: Wed Jul 8 04:55:08 2026 +0530
feat(c/driver/postgresql): include xdbc_type_name in GetObjects (#4457)
Closes #4456
---
c/driver/postgresql/connection.cc | 10 +++++++++-
c/driver/postgresql/postgresql_test.cc | 3 +++
c/driver/postgresql/validation/tests/postgresql.py | 2 +-
glib/test/test-connection.rb | 6 +++---
4 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/c/driver/postgresql/connection.cc
b/c/driver/postgresql/connection.cc
index 86a61fc7a..1acbf3c9b 100644
--- a/c/driver/postgresql/connection.cc
+++ b/c/driver/postgresql/connection.cc
@@ -91,10 +91,12 @@ static const char* kTablesQueryAll =
// Parameterized on schema_name, table_name
static const char* kColumnsQueryAll =
"SELECT attr.attname, attr.attnum, "
- "pg_catalog.col_description(cls.oid, attr.attnum) "
+ "pg_catalog.col_description(cls.oid, attr.attnum), "
+ "typ.typname "
"FROM pg_catalog.pg_attribute AS attr "
"INNER JOIN pg_catalog.pg_class AS cls ON attr.attrelid = cls.oid "
"INNER JOIN pg_catalog.pg_namespace AS nsp ON nsp.oid = cls.relnamespace "
+ "INNER JOIN pg_catalog.pg_type AS typ ON attr.atttypid = typ.oid "
"WHERE attr.attnum > 0 AND NOT attr.attisdropped "
"AND nsp.nspname LIKE $1 AND cls.relname LIKE $2";
@@ -307,6 +309,12 @@ class PostgresGetObjectsHelper : public
adbc::driver::GetObjectsHelper {
if (!next_column_[2].is_null) {
col.remarks = next_column_[2].value();
}
+ if (!next_column_[3].is_null) {
+ if (!col.xdbc) {
+ col.xdbc = adbc::driver::GetObjectsHelper::ColumnXdbc();
+ }
+ col.xdbc->xdbc_type_name = next_column_[3].value();
+ }
return col;
}
diff --git a/c/driver/postgresql/postgresql_test.cc
b/c/driver/postgresql/postgresql_test.cc
index ef9308331..e81f47ac4 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -475,6 +475,9 @@ TEST_F(PostgresConnectionTest,
GetObjectsGetAllFindsPrimaryKey) {
struct AdbcGetObjectsColumn* column =
InternalAdbcGetObjectsDataGetColumnByName(
*get_objects_data, "postgres", "public", "adbc_pkey_test", "id");
ASSERT_NE(column, nullptr) << "could not find id column on adbc_pkey_test
table";
+ auto xdbc_type_name =
+ std::string(column->xdbc_type_name.data,
column->xdbc_type_name.size_bytes);
+ ASSERT_EQ(xdbc_type_name, "int4");
ASSERT_EQ(table->n_table_constraints, 1)
<< "expected 1 constraint on adbc_pkey_test table, found: "
diff --git a/c/driver/postgresql/validation/tests/postgresql.py
b/c/driver/postgresql/validation/tests/postgresql.py
index b46226f38..84148a0fa 100644
--- a/c/driver/postgresql/validation/tests/postgresql.py
+++ b/c/driver/postgresql/validation/tests/postgresql.py
@@ -46,7 +46,7 @@ class PostgreSQLQuirks(model.DriverQuirks):
statement_rows_affected_ddl=False,
current_catalog="postgres",
current_schema="public",
- supported_xdbc_fields=[],
+ supported_xdbc_fields=["xdbc_type_name"],
)
setup = model.DriverSetup(
database={
diff --git a/glib/test/test-connection.rb b/glib/test/test-connection.rb
index e76c72d1d..1b336e644 100644
--- a/glib/test/test-connection.rb
+++ b/glib/test/test-connection.rb
@@ -349,7 +349,7 @@ class ConnectionTest < Test::Unit::TestCase
"xdbc_scope_schema" => nil,
"xdbc_scope_table" => nil,
"xdbc_sql_data_type" => nil,
- "xdbc_type_name" => nil,
+ "xdbc_type_name" => "int4",
},
{
"column_name" => "string",
@@ -370,7 +370,7 @@ class ConnectionTest < Test::Unit::TestCase
"xdbc_scope_schema" => nil,
"xdbc_scope_table" => nil,
"xdbc_sql_data_type" => nil,
- "xdbc_type_name" => nil,
+ "xdbc_type_name" => "text",
},
],
"table_constraints" => [],
@@ -419,7 +419,7 @@ class ConnectionTest < Test::Unit::TestCase
"xdbc_scope_schema" => nil,
"xdbc_scope_table" => nil,
"xdbc_sql_data_type" => nil,
- "xdbc_type_name" => nil,
+ "xdbc_type_name" => "int4",
},
],
"table_constraints" => [],