-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the Go ADBC Interface and build script #865
base: develop
Are you sure you want to change the base?
Conversation
* **ADBC Interface** - Implement the Go ADBC Interface in `adbc_driver.go` - Adhere to the ADBC specifications * **Build Script** - Add `build.sh` to compile the Go ADBC Interface as a C shared object - Use the existing SDK for compilation
@@ -0,0 +1,65 @@ | |||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file seems wrong? there's nothing here and it's using the wrong library version
#include <adbc.h> | ||
#include <adbc_driver_manager.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include paths should be <arrow-adbc/adbc.h>
and <arrow-adbc/adbc_driver_manager.h>
// Initialize the ADBC driver manager | ||
AdbcStatusCode status = AdbcDriverManagerInitialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this function defined? There is no AdbcDriverManagerInitialize()
in adbc_driver_manager.h`
// Initialize the ADBC driver manager | ||
AdbcStatusCode status = AdbcDriverManagerInitialize(); | ||
if (status != ADBC_STATUS_OK) { | ||
std::cerr << "Failed to initialize ADBC driver manager: " << AdbcStatusCodeToString(status) << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AdbcStatusCodeMessage
not AdbcStatusCodeToString
} | ||
|
||
// Register the Arrow Flight SQL driver | ||
status = AdbcDriverManagerRegisterDriver("arrow-flight-sql", &arrow_flight_sql_driver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function doesn't exist either, did you mean AdbcLoadDriver
?
Also, if you are only using the flightsql driver, why use the driver manager? Why not just link against libadbc_driver_flightsql.so
directly?
std::shared_ptr<arrow::Table> ExecuteQuery(const std::string& query) { | ||
// Create a connection to the Arrow Flight SQL server | ||
AdbcConnection connection; | ||
AdbcStatusCode status = AdbcConnectionInitialize(&connection, "arrow-flight-sql", nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AdbcConnectionNew
and AdbcConnectionInit
?
|
||
// Execute the query | ||
AdbcStatement statement; | ||
status = AdbcStatementInitialize(&statement, &connection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AdbcStatementNew
and AdbcStatementInit
AdbcDriverManagerCleanup(); | ||
} | ||
|
||
std::shared_ptr<arrow::Table> ExecuteQuery(const std::string& query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should return an std::shared_ptr<arrow::RecordBatchReader>
to stream the results instead
AdbcResult result; | ||
status = AdbcStatementExecuteQuery(&statement, &result); | ||
if (status != ADBC_STATUS_OK) { | ||
std::cerr << "Failed to execute query: " << AdbcStatusCodeToString(status) << std::endl; | ||
throw std::runtime_error("Failed to execute query"); | ||
} | ||
|
||
// Convert the result to an Arrow Table | ||
std::shared_ptr<arrow::Table> table; | ||
arrow::Status arrow_status = arrow::flight::sql::ResultToTable(result, &table); | ||
if (!arrow_status.ok()) { | ||
std::cerr << "Failed to convert result to Arrow Table: " << arrow_status.ToString() << std::endl; | ||
throw std::runtime_error("Failed to convert result to Arrow Table"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execute query uses an ArrowArrayStream
there is no AdbcResult
ADBC Interface
adbc_driver.go
Build Script
build.sh
to compile the Go ADBC Interface as a C shared object