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 5045b110b feat(c/driver/postgresql): Implement 
StatementGetParameterSchema (#3579)
5045b110b is described below

commit 5045b110b31b5f11ef98051bdd78f2e3e9799ced
Author: Mandukhai Alimaa <[email protected]>
AuthorDate: Fri Oct 17 05:27:28 2025 -0500

    feat(c/driver/postgresql): Implement StatementGetParameterSchema (#3579)
    
    Closes #2880.
---
 c/driver/postgresql/postgresql_test.cc |  2 +-
 c/driver/postgresql/statement.cc       | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/c/driver/postgresql/postgresql_test.cc 
b/c/driver/postgresql/postgresql_test.cc
index 55ef60019..c8d204bd5 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -947,7 +947,7 @@ class PostgresStatementTest : public ::testing::Test,
   void TearDown() override { ASSERT_NO_FATAL_FAILURE(TearDownTest()); }
 
   void TestSqlPrepareErrorParamCountMismatch() { GTEST_SKIP() << "Not yet 
implemented"; }
-  void TestSqlPrepareGetParameterSchema() { GTEST_SKIP() << "Not yet 
implemented"; }
+
   void TestSqlPrepareSelectParams() { GTEST_SKIP() << "Not yet implemented"; }
 
   void TestConcurrentStatements() {
diff --git a/c/driver/postgresql/statement.cc b/c/driver/postgresql/statement.cc
index 677236ef0..0dec60452 100644
--- a/c/driver/postgresql/statement.cc
+++ b/c/driver/postgresql/statement.cc
@@ -762,7 +762,23 @@ AdbcStatusCode PostgresStatement::GetOptionInt(const char* 
key, int64_t* value,
 
 AdbcStatusCode PostgresStatement::GetParameterSchema(struct ArrowSchema* 
schema,
                                                      struct AdbcError* error) {
-  return ADBC_STATUS_NOT_IMPLEMENTED;
+  if (query_.empty()) {
+    InternalAdbcSetError(error, "[libpq] Must SetSqlQuery before 
GetParameterSchema");
+    return ADBC_STATUS_INVALID_STATE;
+  }
+
+  PqResultHelper helper(connection_->conn(), query_);
+  RAISE_STATUS(error, helper.Prepare());
+  RAISE_STATUS(error, helper.DescribePrepared());
+  PostgresType param_types;
+  RAISE_STATUS(error,
+               helper.ResolveParamTypes(*connection_->type_resolver(), 
&param_types));
+
+  ArrowSchemaInit(schema);
+
+  RAISE_NA(param_types.SetSchema(schema, 
std::string(connection_->VendorName())));
+
+  return ADBC_STATUS_OK;
 }
 
 AdbcStatusCode PostgresStatement::Prepare(struct AdbcError* error) {

Reply via email to