lidavidm commented on code in PR #711:
URL: https://github.com/apache/arrow-adbc/pull/711#discussion_r1207122381


##########
c/driver/postgresql/connection.cc:
##########
@@ -126,6 +126,181 @@ class PqResultHelper {
   std::string query_;
 };
 
+class PqGetObjectsHelper {
+ public:
+  PqGetObjectsHelper(PGconn* conn, int depth, const char* catalog, const char* 
db_schema,
+                     const char* table_name, const char** table_types,
+                     const char* column_name, struct ArrowSchema* schema,
+                     struct ArrowArray* array, struct AdbcError* error)
+      : conn_(conn),
+        depth_(depth),
+        catalog_(catalog),
+        db_schema_(db_schema),
+        table_name_(table_name),
+        table_types_(table_types),
+        column_name_(column_name),
+        schema_(schema),
+        array_(array),
+        error_(error) {}
+
+  AdbcStatusCode GetObjects() {
+    RAISE_ADBC(AdbcInitConnectionObjectsSchema(schema_, error_));
+
+    na_error_ = {0};

Review Comment:
   if you want though, this sort of initialization can just go in the 
constructor



##########
c/driver/postgresql/connection.cc:
##########
@@ -126,6 +126,181 @@ class PqResultHelper {
   std::string query_;
 };
 
+class PqGetObjectsHelper {
+ public:
+  PqGetObjectsHelper(PGconn* conn, int depth, const char* catalog, const char* 
db_schema,
+                     const char* table_name, const char** table_types,
+                     const char* column_name, struct ArrowSchema* schema,
+                     struct ArrowArray* array, struct AdbcError* error)
+      : conn_(conn),
+        depth_(depth),
+        catalog_(catalog),
+        db_schema_(db_schema),
+        table_name_(table_name),
+        table_types_(table_types),
+        column_name_(column_name),
+        schema_(schema),
+        array_(array),
+        error_(error) {}
+
+  AdbcStatusCode GetObjects() {
+    RAISE_ADBC(AdbcInitConnectionObjectsSchema(schema_, error_));

Review Comment:
   We should avoid aborts if possible; I think it can stay here (if it's only 
used here, it makes sense as a method IMO)



##########
c/driver/postgresql/connection.cc:
##########
@@ -126,6 +126,181 @@ class PqResultHelper {
   std::string query_;
 };
 
+class PqGetObjectsHelper {
+ public:
+  PqGetObjectsHelper(PGconn* conn, int depth, const char* catalog, const char* 
db_schema,
+                     const char* table_name, const char** table_types,
+                     const char* column_name, struct ArrowSchema* schema,
+                     struct ArrowArray* array, struct AdbcError* error)
+      : conn_(conn),
+        depth_(depth),
+        catalog_(catalog),
+        db_schema_(db_schema),
+        table_name_(table_name),
+        table_types_(table_types),
+        column_name_(column_name),
+        schema_(schema),
+        array_(array),
+        error_(error) {}
+
+  AdbcStatusCode GetObjects() {
+    RAISE_ADBC(AdbcInitConnectionObjectsSchema(schema_, error_));
+
+    na_error_ = {0};
+    CHECK_NA_DETAIL(INTERNAL, ArrowArrayInitFromSchema(array_, schema_, 
&na_error_),
+                    &na_error_, error_);
+    CHECK_NA(INTERNAL, ArrowArrayStartAppending(array_), error_);
+
+    catalog_name_col_ = array_->children[0];
+    catalog_db_schemas_col_ = array_->children[1];
+
+    catalog_db_schemas_items_ = catalog_db_schemas_col_->children[0];
+    db_schema_name_col_ = catalog_db_schemas_items_->children[0];
+    db_schema_tables_col_ = catalog_db_schemas_items_->children[1];
+
+    PqResultHelper curr_db_helper = PqResultHelper{conn_, "SELECT 
current_database()"};

Review Comment:
   I believe you need a connection to list databases.
   
   That said eventually this needs generalization since there may be multiple 
databases within a server instance.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to