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 5fdbaf6 feat(go/adbc/driver/pkg/cmake): cmake build for Go shared
library drivers (#356)
5fdbaf6 is described below
commit 5fdbaf694f917171bc21c95d97f87ea2a8c3c248
Author: Matt Topol <[email protected]>
AuthorDate: Mon Jan 23 08:35:21 2023 -0500
feat(go/adbc/driver/pkg/cmake): cmake build for Go shared library drivers
(#356)
Co-authored-by: David Li <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
---
.github/workflows/native-unix.yml | 125 ++++++++++++--
c/cmake_modules/GoUtils.cmake | 190 +++++++++++++++++++++
c/driver/flightsql/CMakeLists.txt | 69 ++++++++
.../driver/flightsql/adbc-driver-flightsql.pc.in | 38 +----
c/driver/flightsql/dremio_flightsql_test.cc | 87 ++++++++++
c/validation/adbc_validation.cc | 73 +++++++-
c/validation/adbc_validation.h | 15 ++
ci/scripts/cpp_build.sh | 5 +
ci/scripts/cpp_test.sh | 5 +
ci/scripts/python_sdist_build.sh | 2 +
ci/scripts/python_sdist_test.sh | 10 +-
ci/scripts/python_util.sh | 24 ++-
docker-compose.yml | 6 +-
go/adbc/driver/flightsql/flightsql_adbc.go | 8 +-
go/adbc/driver/flightsql/flightsql_statement.go | 2 +-
go/adbc/pkg/Makefile | 2 +-
go/adbc/pkg/_tmpl/driver.go.tmpl | 11 +-
go/adbc/pkg/flightsql/driver.go | 13 +-
go/adbc/validation/validation.go | 4 -
19 files changed, 608 insertions(+), 81 deletions(-)
diff --git a/.github/workflows/native-unix.yml
b/.github/workflows/native-unix.yml
index 3c3c62c..7f96ec3 100644
--- a/.github/workflows/native-unix.yml
+++ b/.github/workflows/native-unix.yml
@@ -108,6 +108,7 @@ jobs:
export ADBC_BUILD_TESTS=OFF
export ADBC_USE_ASAN=OFF
export ADBC_USE_UBSAN=OFF
+ export PATH=$RUNNER_TOOL_CACHE/go/1.18.6/x64/bin:$PATH
./ci/scripts/cpp_build.sh "$(pwd)" "$(pwd)/build" "$HOME/local"
- name: Go Build
shell: bash -l {0}
@@ -164,12 +165,6 @@ jobs:
mamba install -c conda-forge \
--file ci/conda_env_cpp.txt
- - name: Start PostgreSQL
- shell: bash -l {0}
- if: matrix.os == 'ubuntu-latest'
- run: |
- docker run --detach --rm -p 5432:5432 -e POSTGRES_DB=tempdb -e
POSTGRES_PASSWORD=password postgres
-
- name: Build SQLite3 Driver
shell: bash -l {0}
run: |
@@ -178,28 +173,134 @@ jobs:
shell: bash -l {0}
run: |
env BUILD_ALL=0 BUILD_DRIVER_SQLITE=1 ./ci/scripts/cpp_test.sh
"$(pwd)" "$(pwd)/build"
+ - name: BuildPostgreSQL Driver
+ shell: bash -l {0}
+ run: |
+ env BUILD_ALL=0 BUILD_DRIVER_POSTGRESQL=1 ./ci/scripts/cpp_build.sh
"$(pwd)" "$(pwd)/build"
+ - name: Build Driver Manager
+ shell: bash -l {0}
+ run: |
+ env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 ./ci/scripts/cpp_build.sh
"$(pwd)" "$(pwd)/build"
+ - name: Test Driver Manager
+ shell: bash -l {0}
+ run: |
+ env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 ./ci/scripts/cpp_build.sh
"$(pwd)" "$(pwd)/build"
+ env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 ./ci/scripts/cpp_test.sh
"$(pwd)" "$(pwd)/build"
+
+ # ------------------------------------------------------------
+ # C/C++ driver service integration tests
+ # ------------------------------------------------------------
+ drivers-integration-conda:
+ name: "C/C++ (Conda) Driver Service Integration Tests"
+ runs-on: ubuntu-latest
+ services:
+ postgres:
+ image: postgres
+ env:
+ POSTGRES_DB: tempdb
+ POSTGRES_PASSWORD: password
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ ports:
+ - 5432:5432
+ dremio:
+ image: dremio/dremio-oss:latest
+ env:
+ DREMIO_JAVA_EXTRA_OPTS: "-Ddebug.addDefaultUser=true
-Ddremio.eula.disabled=true"
+ options: >-
+ --health-cmd "curl --fail http://localhost:9047/ || exit 1"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ ports:
+ - 9047:9047
+ - 32010:32010
+ - 31010:31010
+ - 45678:45678
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+ - name: Get Date
+ id: get-date
+ shell: bash
+ run: |
+ echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
+ - name: Cache Conda
+ uses: actions/cache/restore@v3
+ with:
+ path: ~/conda_pkgs_dir
+ key: conda-${{ runner.os }}-${{ steps.get-date.outputs.today }}-${{
env.CACHE_NUMBER }}-${{ hashFiles('ci/**') }}
+ - uses: conda-incubator/setup-miniconda@v2
+ with:
+ miniforge-variant: Mambaforge
+ miniforge-version: latest
+ use-only-tar-bz2: false
+ use-mamba: true
+ - name: Install Dependencies
+ shell: bash -l {0}
+ run: |
+ mamba install -c conda-forge \
+ --file ci/conda_env_cpp.txt
+ - uses: actions/setup-go@v3
+ with:
+ go-version: 1.18.6
+ check-latest: true
+ cache: true
+ cache-dependency-path: go/adbc/go.sum
- name: Build PostgreSQL Driver
shell: bash -l {0}
run: |
env BUILD_ALL=0 BUILD_DRIVER_POSTGRESQL=1 ./ci/scripts/cpp_build.sh
"$(pwd)" "$(pwd)/build"
- name: Test PostgreSQL Driver
shell: bash -l {0}
- if: matrix.os == 'ubuntu-latest'
env:
BUILD_ALL: "0"
BUILD_DRIVER_POSTGRESQL: "1"
ADBC_POSTGRESQL_TEST_URI:
"postgres://localhost:5432/postgres?user=postgres&password=password"
run: |
./ci/scripts/cpp_test.sh "$(pwd)" "$(pwd)/build"
- - name: Build Driver Manager
+ - name: Login To Dremio
shell: bash -l {0}
+ id: bootstrap
run: |
- env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 ./ci/scripts/cpp_build.sh
"$(pwd)" "$(pwd)/build"
- - name: Test Driver Manager
+ LOGIN=`curl -X POST -H "Content-Type: application/json"
"http://localhost:9047/apiv2/login" \
+ -d '{"userName":"dremio","password":"dremio123"}'`
+ echo "login_resp=$LOGIN" >> $GITHUB_OUTPUT
+ - name: Auth Token
shell: bash -l {0}
+ id: auth
run: |
- env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 ./ci/scripts/cpp_build.sh
"$(pwd)" "$(pwd)/build"
- env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 ./ci/scripts/cpp_test.sh
"$(pwd)" "$(pwd)/build"
+ echo "token=_dremio${{
fromJSON(steps.bootstrap.outputs.login_resp).token }}" >> $GITHUB_OUTPUT
+ - name: Add Samples Catalog
+ shell: bash -l {0}
+ run: |
+ curl -X PUT -H "content-type: application/json" -H "authorization:
${{ steps.auth.outputs.token }}" \
+ "http://localhost:9047/apiv2/source/Samples/" -d
'{"config":{"externalBucketList":["samples.dremio.com"],
+
"credentialType":"NONE","secure":false,"propertyList":[]},"name":"Samples","accelerationRefreshPeriod":3600000,
+
"accelerationGracePeriod":10800000,"accelerationNeverRefresh":true,"accelerationNeverExpire":true,"type":"S3"}'
+ - name: Build FlightSQL Driver
+ shell: bash -l {0}
+ env:
+ BUILD_ALL: "0"
+ BUILD_DRIVER_FLIGHTSQL: "1"
+ run: |
+ ./ci/scripts/cpp_build.sh "$(pwd)" "$(pwd)/build"
+ - name: Test FlightSQL Driver against Dremio
+ shell: bash -l {0}
+ env:
+ BUILD_ALL: "0"
+ BUILD_DRIVER_FLIGHTSQL: "1"
+ ADBC_DREMIO_FLIGHTSQL_URI: "grpc+tcp://localhost:32010"
+ ADBC_DREMIO_FLIGHTSQL_USER: "dremio"
+ ADBC_DREMIO_FLIGHTSQL_PASS: "dremio123"
+ run: |
+ ./ci/scripts/cpp_build.sh "$(pwd)" "$(pwd)/build"
+ ./ci/scripts/cpp_test.sh "$(pwd)" "$(pwd)/build"
# ------------------------------------------------------------
# GLib/Ruby
diff --git a/c/cmake_modules/GoUtils.cmake b/c/cmake_modules/GoUtils.cmake
new file mode 100644
index 0000000..b14e42a
--- /dev/null
+++ b/c/cmake_modules/GoUtils.cmake
@@ -0,0 +1,190 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+find_program(GO_BIN "go" REQUIRED)
+message(STATUS "Detecting Go executable: Found ${GO_BIN}")
+
+function(add_go_lib GO_MOD_DIR GO_LIBNAME)
+ set(options)
+ set(one_value_args
+ BUILD_TAGS
+ SHARED_LINK_FLAGS
+ CMAKE_PACKAGE_NAME
+ PKG_CONFIG_NAME
+ BUILD_STATIC
+ BUILD_SHARED)
+ set(multi_value_args SOURCES OUTPUTS)
+
+ cmake_parse_arguments(ARG
+ "${options}"
+ "${one_value_args}"
+ "${multi_value_args}"
+ ${ARGN})
+
+ if(ARG_UNPARSED_ARGUMENTS)
+ message(SEND_ERROR "Error: unrecognized arguments:
${ARG_UNPARSED_ARGUMENTS}")
+ endif()
+
+ if(ARG_OUTPUTS)
+ set(${ARG_OUTPUTS})
+ endif()
+
+ # Allow overriding ADBC_BUILD_SHARED and ADBC_BUILD_STATIC
+ if(DEFINED ARG_BUILD_SHARED)
+ set(BUILD_SHARED ${ARG_BUILD_SHARED})
+ else()
+ set(BUILD_SHARED ${ADBC_BUILD_SHARED})
+ endif()
+ if(DEFINED ARG_BUILD_STATIC)
+ set(BUILD_STATIC ${ARG_BUILD_STATIC})
+ else()
+ set(BUILD_STATIC ${ADBC_BUILD_STATIC})
+ endif()
+
+ if(DEFINED ARG_BUILD_TAGS)
+ set(GO_BUILD_TAGS "-tags=${ARG_BUILD_TAGS}")
+ endif()
+
+ list(TRANSFORM ARG_SOURCES PREPEND "${GO_MOD_DIR}/")
+
+ if(BUILD_SHARED)
+ set(LIB_NAME_SHARED
+
"${CMAKE_SHARED_LIBRARY_PREFIX}${GO_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+
+ if(NOT APPLE)
+ set(ARG_SHARED_LINK_FLAGS
+ "${ARG_SHARED_LINK_FLAGS} -extldflags
-Wl,-soname,${LIB_NAME_SHARED}.${ADBC_SO_VERSION}"
+ )
+ endif()
+
+ if(DEFINED ARG_SHARED_LINK_FLAGS)
+ separate_arguments(ARG_SHARED_LINK_FLAGS NATIVE_COMMAND
"${ARG_SHARED_LINK_FLAGS}")
+ set(GO_LDFLAGS "-ldflags=\"${ARG_SHARED_LINK_FLAGS}\"")
+ endif()
+
+ set(LIBOUT_SHARED "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME_SHARED}")
+
+ add_custom_command(OUTPUT "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}"
+ WORKING_DIRECTORY ${GO_MOD_DIR}
+ DEPENDS ${ARG_SOURCES}
+ COMMAND ${GO_BIN} build "${GO_BUILD_TAGS}" -o
+ "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}"
+ -buildmode=c-shared "${GO_LDFLAGS}" .
+ COMMAND ${CMAKE_COMMAND} -E remove -f
+ "${LIBOUT_SHARED}.${ADBC_SO_VERSION}.0.h"
+ COMMENT "Building Go Shared lib ${GO_LIBNAME}"
+ COMMAND_EXPAND_LISTS)
+
+ add_custom_command(OUTPUT "${LIBOUT_SHARED}.${ADBC_SO_VERSION}"
"${LIBOUT_SHARED}"
+ DEPENDS "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
+ "${LIB_NAME_SHARED}.${ADBC_FULL_SO_VERSION}"
+ "${LIB_NAME_SHARED}.${ADBC_SO_VERSION}"
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
+ "${LIB_NAME_SHARED}.${ADBC_SO_VERSION}"
+ "${LIB_NAME_SHARED}")
+
+ add_custom_target(${GO_LIBNAME}_target ALL
+ DEPENDS "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}"
+ "${LIBOUT_SHARED}.${ADBC_SO_VERSION}"
"${LIBOUT_SHARED}")
+ add_library(${GO_LIBNAME}_shared SHARED IMPORTED)
+ set_target_properties(${GO_LIBNAME}_shared
+ PROPERTIES IMPORTED_LOCATION
+ "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}"
+ IMPORTED_SONAME "${LIB_NAME_SHARED}")
+ add_dependencies(${GO_LIBNAME}_shared ${GO_LIBNAME}_target)
+ if(ARG_OUTPUTS)
+ list(APPEND ${ARG_OUTPUTS} ${GO_LIBNAME}_shared)
+ endif()
+
+ if(ADBC_RPATH_ORIGIN)
+ if(APPLE)
+ set(_lib_install_rpath "@loader_path")
+ else()
+ set(_lib_install_rpath "\$ORIGIN")
+ endif()
+ set_target_properties(${GO_LIBNAME}_shared PROPERTIES INSTALL_RPATH
+
${_lib_install_rpath})
+ endif()
+
+ if(APPLE)
+ if(ADBC_INSTALL_NAME_RPATH)
+ set(_lib_install_name "@rpath")
+ else()
+ set(_lib_install_name
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+ endif()
+ set_target_properties(${GO_LIBNAME}_shared PROPERTIES INSTALL_NAME_DIR
+
"${_lib_install_name}")
+ endif()
+
+ install(IMPORTED_RUNTIME_ARTIFACTS
+ ${GO_LIBNAME}_shared
+ ${INSTALL_IS_OPTIONAL}
+ RUNTIME
+ DESTINATION
+ ${RUNTIME_INSTALL_DIR}
+ LIBRARY
+ DESTINATION
+ ${CMAKE_INSTALL_LIBDIR})
+ install(FILES "${LIBOUT_SHARED}.${ADBC_SO_VERSION}" TYPE LIB)
+ endif()
+
+ if(BUILD_STATIC)
+ set(LIBNAME_STATIC
+
"${CMAKE_STATIC_LIBRARY_PREFIX}${GO_LIBNAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ set(LIBOUT_STATIC "${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME_STATIC}")
+ cmake_path(REPLACE_EXTENSION
+ LIBOUT_STATIC
+ ".h"
+ OUTPUT_VARIABLE
+ LIBOUT_HEADER)
+ add_custom_command(OUTPUT "${LIBOUT_STATIC}"
+ WORKING_DIRECTORY ${GO_MOD_DIR}
+ DEPENDS ${ARG_SOURCES}
+ COMMAND ${GO_BIN} build "${GO_BUILD_TAGS}" -o
"${LIBOUT_STATIC}"
+ -buildmode=c-archive .
+ COMMAND ${CMAKE_COMMAND} -E remove -f "${LIBOUT_HEADER}"
+ COMMENT "Building Go Static lib ${GO_LIBNAME}"
+ COMMAND_EXPAND_LISTS)
+
+ add_custom_target(${GO_LIBNAME}_static_target ALL DEPENDS
"${LIBOUT_STATIC}")
+ add_library(${GO_LIBNAME}_static STATIC IMPORTED)
+ set_target_properties(${GO_LIBNAME}_static PROPERTIES IMPORTED_LOCATION
+ "${LIBOUT_STATIC}")
+ add_dependencies(${GO_LIBNAME}_static ${GO_LIBNAME}_static_target)
+ if(ARG_OUTPUTS)
+ list(APPEND ${ARG_OUTPUTS} ${GO_LIBNAME}_static)
+ endif()
+
+ install(FILES "${LIBOUT_STATIC}" TYPE LIB)
+ endif()
+ # if(ARG_CMAKE_PACKAGE_NAME)
+ # install_cmake_package(${ARG_CMAKE_PACKAGE_NAME} ${GO_LIBNAME}_export)
+ # endif()
+
+ if(ARG_PKG_CONFIG_NAME)
+ arrow_add_pkg_config("${ARG_PKG_CONFIG_NAME}")
+ endif()
+
+ # Modify variable in calling scope
+ if(ARG_OUTPUTS)
+ set(${ARG_OUTPUTS}
+ ${${ARG_OUTPUTS}}
+ PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/c/driver/flightsql/CMakeLists.txt
b/c/driver/flightsql/CMakeLists.txt
new file mode 100644
index 0000000..a450fd9
--- /dev/null
+++ b/c/driver/flightsql/CMakeLists.txt
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+cmake_minimum_required(VERSION 3.18)
+get_filename_component(REPOSITORY_ROOT "../../../" ABSOLUTE)
+list(APPEND CMAKE_MODULE_PATH "${REPOSITORY_ROOT}/c/cmake_modules/")
+include(AdbcDefines)
+include(BuildUtils)
+include(GoUtils)
+
+project(adbc_driver_flightsql
+ VERSION "${ADBC_BASE_VERSION}"
+ LANGUAGES C CXX)
+include(CTest)
+
+set(LDFLAGS "$<$<CONFIG:Release>:-s> $<$<CONFIG:Release>:-w>")
+add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/flightsql/"
+ adbc_driver_flightsql
+ SOURCES
+ driver.go
+ utils.h
+ utils.c
+ BUILD_TAGS
+ driverlib
+ PKG_CONFIG_NAME
+ adbc-driver-flightsql
+ SHARED_LINK_FLAGS
+ ${LDFLAGS})
+
+include_directories(SYSTEM ${REPOSITORY_ROOT})
+include_directories(SYSTEM ${REPOSITORY_ROOT}/c/)
+
+if(ADBC_TEST_LINKAGE STREQUAL "shared")
+ set(TEST_LINK_LIBS adbc_driver_flightsql_shared)
+else()
+ set(TEST_LINK_LIBS adbc_driver_flightsql_static)
+endif()
+
+if(ADBC_BUILD_TESTS)
+ add_test_case(driver_flightsql_test
+ PREFIX
+ adbc
+ SOURCES
+ dremio_flightsql_test.cc
+ ../../validation/adbc_validation.cc
+ ../../validation/adbc_validation_util.cc
+ EXTRA_LINK_LIBS
+ nanoarrow
+ ${TEST_LINK_LIBS})
+ target_compile_features(adbc-driver-flightsql-test PRIVATE cxx_std_17)
+ adbc_configure_target(adbc-driver-flightsql-test)
+endif()
+
+validate_config()
+config_summary_message()
diff --git a/ci/scripts/python_sdist_test.sh
b/c/driver/flightsql/adbc-driver-flightsql.pc.in
old mode 100755
new mode 100644
similarity index 52%
copy from ci/scripts/python_sdist_test.sh
copy to c/driver/flightsql/adbc-driver-flightsql.pc.in
index 2171ee6..31a63c9
--- a/ci/scripts/python_sdist_test.sh
+++ b/c/driver/flightsql/adbc-driver-flightsql.pc.in
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -17,33 +15,11 @@
# specific language governing permissions and limitations
# under the License.
-set -e
-set -x
-set -o pipefail
-
-if [ "$#" -ne 2 ]; then
- echo "Usage: $0 <arch> <adbc-src-dir>"
- exit 1
-fi
-
-arch=${1}
-source_dir=${2}
-build_dir="${source_dir}/build"
-script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-source "${script_dir}/python_util.sh"
-
-echo "=== Set up platform variables ==="
-setup_build_vars "${arch}"
-
-echo "=== Building C/C++ driver components ==="
-build_drivers "${source_dir}" "${build_dir}"
-
-echo "=== Installing sdists ==="
-for component in ${COMPONENTS}; do
- pip install --no-deps --force-reinstall
${source_dir}/python/${component}/dist/*.tar.gz
-done
-pip install pytest pyarrow pandas
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@ADBC_PKG_CONFIG_LIBDIR@
-echo "=== (${PYTHON_VERSION}) Testing sdists ==="
-test_packages
+Name: Apache Arrow Database Connectivity (ADBC) Flight SQL driver
+Description: The ADBC Flight SQL driver provides an ADBC driver for Flight SQL.
+URL: https://github.com/apache/arrow-adbc
+Version: @ADBC_VERSION@
+Libs: -L${libdir} -ladbc_driver_flightsql
diff --git a/c/driver/flightsql/dremio_flightsql_test.cc
b/c/driver/flightsql/dremio_flightsql_test.cc
new file mode 100644
index 0000000..f9ee56d
--- /dev/null
+++ b/c/driver/flightsql/dremio_flightsql_test.cc
@@ -0,0 +1,87 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <adbc.h>
+#include <gmock/gmock-matchers.h>
+#include <gtest/gtest-matchers.h>
+#include <gtest/gtest-param-test.h>
+#include <gtest/gtest.h>
+#include <nanoarrow/nanoarrow.h>
+#include "validation/adbc_validation.h"
+#include "validation/adbc_validation_util.h"
+
+using adbc_validation::IsOkStatus;
+
+class DremioFlightSQLQuirks : public adbc_validation::DriverQuirks {
+ public:
+ AdbcStatusCode SetupDatabase(struct AdbcDatabase* database,
+ struct AdbcError* error) const override {
+ const char* uri = std::getenv("ADBC_DREMIO_FLIGHTSQL_URI");
+ const char* user = std::getenv("ADBC_DREMIO_FLIGHTSQL_USER");
+ const char* pass = std::getenv("ADBC_DREMIO_FLIGHTSQL_PASS");
+ EXPECT_THAT(AdbcDatabaseSetOption(database, "uri", uri, error),
IsOkStatus(error));
+ EXPECT_THAT(AdbcDatabaseSetOption(database, "username", user, error),
+ IsOkStatus(error));
+ EXPECT_THAT(AdbcDatabaseSetOption(database, "password", pass, error),
+ IsOkStatus(error));
+ return ADBC_STATUS_OK;
+ }
+
+ std::string BindParameter(int index) const override { return "?"; }
+ bool supports_concurrent_statements() const override { return true; }
+ bool supports_transactions() const override { return false; }
+ bool supports_get_sql_info() const override { return false; }
+ bool supports_get_objects() const override { return false; }
+ bool supports_bulk_ingest() const override { return false; }
+ bool supports_partitioned_data() const override { return true; }
+ bool supports_dynamic_parameter_binding() const override { return false; }
+};
+
+class DremioFlightSQLTest : public ::testing::Test, public
adbc_validation::DatabaseTest {
+ public:
+ const adbc_validation::DriverQuirks* quirks() const override { return
&quirks_; }
+ void SetUp() override { ASSERT_NO_FATAL_FAILURE(SetUpTest()); }
+ void TearDown() override { ASSERT_NO_FATAL_FAILURE(TearDownTest()); }
+
+ protected:
+ DremioFlightSQLQuirks quirks_;
+};
+ADBCV_TEST_DATABASE(DremioFlightSQLTest)
+
+class DremioFlightSQLConnectionTest : public ::testing::Test,
+ public adbc_validation::ConnectionTest {
+ public:
+ const adbc_validation::DriverQuirks* quirks() const override { return
&quirks_; }
+ void SetUp() override { ASSERT_NO_FATAL_FAILURE(SetUpTest()); }
+ void TearDown() override { ASSERT_NO_FATAL_FAILURE(TearDownTest()); }
+
+ protected:
+ DremioFlightSQLQuirks quirks_;
+};
+ADBCV_TEST_CONNECTION(DremioFlightSQLConnectionTest)
+
+class DremioFlightSQLStatementTest : public ::testing::Test,
+ public adbc_validation::StatementTest {
+ public:
+ const adbc_validation::DriverQuirks* quirks() const override { return
&quirks_; }
+ void SetUp() override { ASSERT_NO_FATAL_FAILURE(SetUpTest()); }
+ void TearDown() override { ASSERT_NO_FATAL_FAILURE(TearDownTest()); }
+
+ protected:
+ DremioFlightSQLQuirks quirks_;
+};
+ADBCV_TEST_STATEMENT(DremioFlightSQLStatementTest)
diff --git a/c/validation/adbc_validation.cc b/c/validation/adbc_validation.cc
index 1bade32..605f0f1 100644
--- a/c/validation/adbc_validation.cc
+++ b/c/validation/adbc_validation.cc
@@ -173,6 +173,9 @@ void ConnectionTest::TestAutocommitDefault() {
void ConnectionTest::TestAutocommitToggle() {
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
+ if (!quirks()->supports_transactions()) {
+ GTEST_SKIP();
+ }
// It is OK to enable autocommit when it is already enabled
ASSERT_THAT(AdbcConnectionSetOption(&connection,
ADBC_CONNECTION_OPTION_AUTOCOMMIT,
@@ -218,6 +221,10 @@ void ConnectionTest::TestMetadataGetInfo() {
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
+ if (!quirks()->supports_get_sql_info()) {
+ GTEST_SKIP();
+ }
+
StreamReader reader;
std::vector<uint32_t> info = {
ADBC_INFO_DRIVER_NAME,
@@ -275,6 +282,9 @@ void ConnectionTest::TestMetadataGetInfo() {
}
void ConnectionTest::TestMetadataGetTableSchema() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
@@ -376,6 +386,10 @@ void ConnectionTest::TestMetadataGetObjectsCatalogs() {
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
+ if (!quirks()->supports_get_objects()) {
+ GTEST_SKIP();
+ }
+
{
StreamReader reader;
ASSERT_THAT(AdbcConnectionGetObjects(&connection,
ADBC_OBJECT_DEPTH_CATALOGS, nullptr,
@@ -420,6 +434,10 @@ void ConnectionTest::TestMetadataGetObjectsDbSchemas() {
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
+ if (!quirks()->supports_get_objects()) {
+ GTEST_SKIP();
+ }
+
{
// Expect at least one catalog, at least one schema, and tables should be
null
StreamReader reader;
@@ -491,6 +509,10 @@ void ConnectionTest::TestMetadataGetObjectsDbSchemas() {
void ConnectionTest::TestMetadataGetObjectsTables() {
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
+ if (!quirks()->supports_get_objects()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
ASSERT_NO_FATAL_FAILURE(IngestSampleTable(&connection, &error));
@@ -567,6 +589,10 @@ void ConnectionTest::TestMetadataGetObjectsTables() {
void ConnectionTest::TestMetadataGetObjectsTablesTypes() {
ASSERT_THAT(AdbcConnectionNew(&connection, &error), IsOkStatus(&error));
ASSERT_THAT(AdbcConnectionInit(&connection, &database, &error),
IsOkStatus(&error));
+ if (!quirks()->supports_get_objects()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
ASSERT_NO_FATAL_FAILURE(IngestSampleTable(&connection, &error));
@@ -634,6 +660,9 @@ void ConnectionTest::TestMetadataGetObjectsTablesTypes() {
}
void ConnectionTest::TestMetadataGetObjectsColumns() {
+ if (!quirks()->supports_get_objects()) {
+ GTEST_SKIP();
+ }
// TODO: test could be more robust if we ingested a few tables
ASSERT_EQ(ADBC_OBJECT_DEPTH_COLUMNS, ADBC_OBJECT_DEPTH_ALL);
@@ -800,6 +829,10 @@ void StatementTest::TestRelease() {
}
void StatementTest::TestSqlIngestInts() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
@@ -851,6 +884,10 @@ void StatementTest::TestSqlIngestInts() {
}
void StatementTest::TestSqlIngestAppend() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
+
// Ingest
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
@@ -926,6 +963,10 @@ void StatementTest::TestSqlIngestAppend() {
}
void StatementTest::TestSqlIngestErrors() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
+
// Ingest without bind
ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
ASSERT_THAT(AdbcStatementSetOption(&statement,
ADBC_INGEST_OPTION_TARGET_TABLE,
@@ -1002,6 +1043,10 @@ void StatementTest::TestSqlIngestErrors() {
}
void StatementTest::TestSqlIngestMultipleConnections() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
@@ -1077,7 +1122,7 @@ void StatementTest::TestSqlPartitionedInts() {
ASSERT_THAT(AdbcStatementExecutePartitions(&statement, &schema.value,
&partitions.value,
&rows_affected, &error),
IsStatus(ADBC_STATUS_NOT_IMPLEMENTED, &error));
- return;
+ GTEST_SKIP();
}
ASSERT_THAT(AdbcStatementExecutePartitions(&statement, &schema.value,
&partitions.value,
@@ -1125,6 +1170,10 @@ void StatementTest::TestSqlPartitionedInts() {
}
void StatementTest::TestSqlPrepareGetParameterSchema() {
+ if (!quirks()->supports_dynamic_parameter_binding()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
std::string query = "SELECT ";
query += quirks()->BindParameter(0);
@@ -1178,6 +1227,10 @@ void StatementTest::TestSqlPrepareSelectNoParams() {
}
void StatementTest::TestSqlPrepareSelectParams() {
+ if (!quirks()->supports_dynamic_parameter_binding()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
std::string query = "SELECT ";
query += quirks()->BindParameter(0);
@@ -1235,6 +1288,10 @@ void StatementTest::TestSqlPrepareSelectParams() {
}
void StatementTest::TestSqlPrepareUpdate() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
@@ -1309,6 +1366,10 @@ void StatementTest::TestSqlPrepareUpdateNoParams() {
}
void StatementTest::TestSqlPrepareUpdateStream() {
+ if (!quirks()->supports_bulk_ingest()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
@@ -1406,6 +1467,10 @@ void StatementTest::TestSqlPrepareErrorNoQuery() {
// TODO: need test of overlapping reads - make sure behavior is as described
void StatementTest::TestSqlPrepareErrorParamCountMismatch() {
+ if (!quirks()->supports_dynamic_parameter_binding()) {
+ GTEST_SKIP();
+ }
+
Handle<struct ArrowSchema> schema;
Handle<struct ArrowArray> array;
struct ArrowError na_error;
@@ -1478,7 +1543,7 @@ void StatementTest::TestSqlQueryInts() {
void StatementTest::TestSqlQueryFloats() {
ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
- ASSERT_THAT(AdbcStatementSetSqlQuery(&statement, "SELECT CAST(1.0 AS REAL)",
&error),
+ ASSERT_THAT(AdbcStatementSetSqlQuery(&statement, "SELECT CAST(1.0 AS
FLOAT)", &error),
IsOkStatus(&error));
{
@@ -1571,6 +1636,10 @@ void StatementTest::TestSqlQueryErrors() {
}
void StatementTest::TestTransactions() {
+ if (!quirks()->supports_transactions()) {
+ GTEST_SKIP();
+ }
+
ASSERT_THAT(quirks()->DropTable(&connection, "bulk_ingest", &error),
IsOkStatus(&error));
diff --git a/c/validation/adbc_validation.h b/c/validation/adbc_validation.h
index aa3f62d..c57602b 100644
--- a/c/validation/adbc_validation.h
+++ b/c/validation/adbc_validation.h
@@ -53,6 +53,21 @@ class DriverQuirks {
/// \brief Whether AdbcStatementExecutePartitions should work
virtual bool supports_partitioned_data() const { return false; }
+
+ /// \brief Whether transaction methods are implemented
+ virtual bool supports_transactions() const { return true; }
+
+ /// \brief Whether GetSqlInfo is implemented
+ virtual bool supports_get_sql_info() const { return true; }
+
+ /// \brief Whether GetObjects is implemented
+ virtual bool supports_get_objects() const { return true; }
+
+ /// \brief Whether bulk ingest is supported
+ virtual bool supports_bulk_ingest() const { return true; }
+
+ /// \brief Whether dynamic parameter bindings are supported for prepare
+ virtual bool supports_dynamic_parameter_binding() const { return true; }
};
class DatabaseTest {
diff --git a/ci/scripts/cpp_build.sh b/ci/scripts/cpp_build.sh
index 12d8044..2841c2e 100755
--- a/ci/scripts/cpp_build.sh
+++ b/ci/scripts/cpp_build.sh
@@ -22,6 +22,7 @@ set -e
: ${BUILD_DRIVER_MANAGER:=${BUILD_ALL}}
: ${BUILD_DRIVER_POSTGRESQL:=${BUILD_ALL}}
: ${BUILD_DRIVER_SQLITE:=${BUILD_ALL}}
+: ${BUILD_DRIVER_FLIGHTSQL:=${BUILD_ALL}}
: ${ADBC_BUILD_SHARED:=ON}
: ${ADBC_BUILD_STATIC:=OFF}
@@ -83,6 +84,10 @@ main() {
if [[ "${BUILD_DRIVER_SQLITE}" -gt 0 ]]; then
build_subproject "${source_dir}" "${build_dir}" "${install_dir}"
driver/sqlite
fi
+
+ if [[ "${BUILD_DRIVER_FLIGHTSQL}" -gt 0 ]]; then
+ build_subproject "${source_dir}" "${build_dir}" "${install_dir}"
driver/flightsql
+ fi
}
main "$@"
diff --git a/ci/scripts/cpp_test.sh b/ci/scripts/cpp_test.sh
index 9bd989f..a62d30e 100755
--- a/ci/scripts/cpp_test.sh
+++ b/ci/scripts/cpp_test.sh
@@ -22,6 +22,7 @@ set -e
: ${BUILD_DRIVER_MANAGER:=${BUILD_ALL}}
: ${BUILD_DRIVER_POSTGRESQL:=${BUILD_ALL}}
: ${BUILD_DRIVER_SQLITE:=${BUILD_ALL}}
+: ${BUILD_DRIVER_FLIGHTSQL:=${BUILD_ALL}}
test_subproject() {
local -r build_dir="${1}"
@@ -60,6 +61,10 @@ main() {
if [[ "${BUILD_DRIVER_SQLITE}" -gt 0 ]]; then
test_subproject "${build_dir}" driver/sqlite
fi
+
+ if [[ "${BUILD_DRIVER_FLIGHTSQL}" -gt 0 ]]; then
+ test_subproject "${build_dir}" driver/flightsql
+ fi
}
main "$@"
diff --git a/ci/scripts/python_sdist_build.sh b/ci/scripts/python_sdist_build.sh
index eca67fd..a153503 100755
--- a/ci/scripts/python_sdist_build.sh
+++ b/ci/scripts/python_sdist_build.sh
@@ -22,6 +22,8 @@ set -ex
source_dir=${1}
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+git config --global --add safe.directory ${source_dir}
+
source "${script_dir}/python_util.sh"
echo "=== (${PYTHON_VERSION}) Building ADBC sdists ==="
diff --git a/ci/scripts/python_sdist_test.sh b/ci/scripts/python_sdist_test.sh
index 2171ee6..baaacf7 100755
--- a/ci/scripts/python_sdist_test.sh
+++ b/ci/scripts/python_sdist_test.sh
@@ -21,14 +21,18 @@ set -e
set -x
set -o pipefail
-if [ "$#" -ne 2 ]; then
- echo "Usage: $0 <arch> <adbc-src-dir>"
+if [ "$#" -lt 2 ]; then
+ echo "Usage: $0 <arch> <adbc-src-dir> <adbc-build-dir>"
exit 1
fi
arch=${1}
source_dir=${2}
-build_dir="${source_dir}/build"
+if [ "$#" -ge 3 ]; then
+ build_dir=${3}
+else
+ build_dir="${source_dir}/build"
+fi
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${script_dir}/python_util.sh"
diff --git a/ci/scripts/python_util.sh b/ci/scripts/python_util.sh
index 827c7e6..ad67612 100644
--- a/ci/scripts/python_util.sh
+++ b/ci/scripts/python_util.sh
@@ -35,13 +35,13 @@ function build_drivers {
export VCPKG_OVERLAY_TRIPLETS="${source_dir}/ci/vcpkg/triplets/"
if [[ $(uname) == "Linux" ]]; then
- export
ADBC_FLIGHTSQL_LIBRARY=${source_dir}/go/adbc/pkg/libadbc_driver_flightsql.so
+ export
ADBC_FLIGHTSQL_LIBRARY=${build_dir}/lib/libadbc_driver_flightsql.so
export
ADBC_POSTGRESQL_LIBRARY=${build_dir}/lib/libadbc_driver_postgresql.so
export ADBC_SQLITE_LIBRARY=${build_dir}/lib/libadbc_driver_sqlite.so
export VCPKG_DEFAULT_TRIPLET="${VCPKG_ARCH}-linux-static-release"
export CMAKE_ARGUMENTS=""
else # macOS
- export
ADBC_FLIGHTSQL_LIBRARY=${source_dir}/go/adbc/pkg/libadbc_driver_flightsql.dylib
+ export
ADBC_FLIGHTSQL_LIBRARY=${build_dir}/lib/libadbc_driver_flightsql.dylib
export
ADBC_POSTGRESQL_LIBRARY=${build_dir}/lib/libadbc_driver_postgresql.dylib
export ADBC_SQLITE_LIBRARY=${build_dir}/lib/libadbc_driver_sqlite.dylib
export VCPKG_DEFAULT_TRIPLET="${VCPKG_ARCH}-osx-static-release"
@@ -55,6 +55,23 @@ function build_drivers {
fi
fi
+ echo "=== Building driver/flightsql ==="
+ mkdir -p ${build_dir}/driver/flightsql
+ pushd ${build_dir}/driver/flightsql
+ cmake \
+ -DADBC_BUILD_SHARED=ON \
+ -DADBC_BUILD_STATIC=OFF \
+ -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DCMAKE_INSTALL_PREFIX=${build_dir} \
+ -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} \
+ ${CMAKE_ARGUMENTS} \
+ ${source_dir}/c/driver/flightsql
+ cmake --build . --target install --verbose -j
+ popd
+
+ echo "=== Setup VCPKG ==="
+
pushd "${VCPKG_ROOT}"
# XXX: patch an odd issue where the path of some file is inconsistent
between builds
patch -N -p1 <
"${source_dir}/ci/vcpkg/0001-Work-around-inconsistent-path.patch" || true
@@ -68,9 +85,6 @@ function build_drivers {
--overlay-triplets "${VCPKG_OVERLAY_TRIPLETS}" \
--triplet "${VCPKG_DEFAULT_TRIPLET}"
- echo "=== Building driver/flightsql ==="
- make -C ${source_dir}/go/adbc/pkg all
-
echo "=== Building driver/postgresql ==="
mkdir -p ${build_dir}/driver/postgresql
pushd ${build_dir}/driver/postgresql
diff --git a/docker-compose.yml b/docker-compose.yml
index fc45e97..0ce9286 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -44,7 +44,7 @@ services:
image: ${ARCH}/python:${PYTHON}
volumes:
- .:/adbc:delegated
- command: /adbc/ci/scripts/python_sdist_build.sh /adbc
+ command: "/bin/bash -c 'git config --global --add safe.directory /adbc &&
source /adbc/ci/scripts/python_sdist_build.sh /adbc'"
python-sdist-test:
image:
${REPO}:${ARCH}-python-${PYTHON}-wheel-manylinux-${MANYLINUX}-vcpkg-${VCPKG}-adbc
@@ -52,7 +52,7 @@ services:
- python-wheel-manylinux # shared image
volumes:
- .:/adbc:delegated
- command: "'/adbc/ci/scripts/python_sdist_test.sh ${ARCH} /adbc'"
+ command: "'git config --global --add safe.directory /adbc && source
/adbc/ci/scripts/python_sdist_test.sh ${ARCH} /adbc /adbcbuild'"
############################ Python wheels ##################################
@@ -71,7 +71,7 @@ services:
VCPKG: ${VCPKG}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- - .:/adbc:delegated
+ - .:/adbc
# Must set safe.directory so miniver won't error when calling git
command: "'git config --global --add safe.directory /adbc && git config
--global --get safe.directory && /adbc/ci/scripts/python_wheel_unix_build.sh
${ARCH} /adbc /adbc/build'"
diff --git a/go/adbc/driver/flightsql/flightsql_adbc.go
b/go/adbc/driver/flightsql/flightsql_adbc.go
index 8209187..b959f32 100644
--- a/go/adbc/driver/flightsql/flightsql_adbc.go
+++ b/go/adbc/driver/flightsql/flightsql_adbc.go
@@ -564,20 +564,24 @@ func (c *cnxn) GetTableTypes(ctx context.Context)
(array.RecordReader, error) {
// only be used if autocommit is disabled.
//
// Behavior is undefined if this is mixed with SQL transaction statements.
+// When not supported, the convention is that it should act as if autocommit
+// is enabled and return INVALID_STATE errors.
func (c *cnxn) Commit(_ context.Context) error {
return adbc.Error{
Msg: "[Flight SQL] Transaction methods are not implemented
yet",
- Code: adbc.StatusNotImplemented}
+ Code: adbc.StatusInvalidState}
}
// Rollback rolls back any pending transactions. Only used if autocommit
// is disabled.
//
// Behavior is undefined if this is mixed with SQL transaction statements.
+// When not supported, the convention is that it should act as if autocommit
+// is enabled and return INVALID_STATE errors.
func (c *cnxn) Rollback(_ context.Context) error {
return adbc.Error{
Msg: "[Flight SQL] Transaction methods are not implemented
yet",
- Code: adbc.StatusNotImplemented}
+ Code: adbc.StatusInvalidState}
}
// NewStatement initializes a new statement object tied to this connection
diff --git a/go/adbc/driver/flightsql/flightsql_statement.go
b/go/adbc/driver/flightsql/flightsql_statement.go
index 5aeaa06..94486f2 100644
--- a/go/adbc/driver/flightsql/flightsql_statement.go
+++ b/go/adbc/driver/flightsql/flightsql_statement.go
@@ -141,7 +141,7 @@ func (s *statement) Prepare(ctx context.Context) error {
if s.query == "" {
return adbc.Error{
Msg: "[FlightSQL Statement] must call SetSqlQuery
before Prepare",
- Code: adbc.StatusInvalidArgument,
+ Code: adbc.StatusInvalidState,
}
}
diff --git a/go/adbc/pkg/Makefile b/go/adbc/pkg/Makefile
index 337d804..b7a41d5 100644
--- a/go/adbc/pkg/Makefile
+++ b/go/adbc/pkg/Makefile
@@ -29,7 +29,7 @@ all: $(DRIVERS)
libadbc_driver_%.$(SUFFIX): %
$(GO_BUILD) -tags driverlib -o $@ -buildmode=c-shared -ldflags "-s -w"
./$<
- rm *.h
+ rm $(basename $@).h
clean:
rm $(DRIVERS)
diff --git a/go/adbc/pkg/_tmpl/driver.go.tmpl b/go/adbc/pkg/_tmpl/driver.go.tmpl
index da7191a..67e592c 100644
--- a/go/adbc/pkg/_tmpl/driver.go.tmpl
+++ b/go/adbc/pkg/_tmpl/driver.go.tmpl
@@ -177,10 +177,6 @@ func {{.Prefix}}DatabaseRelease(db *C.struct_AdbcDatabase,
err *C.struct_AdbcErr
h := (*(*cgo.Handle)(db.private_data))
cdb := h.Value().(*cDatabase)
- if cdb.db == nil {
- setErr(err, "AdbcDatabaseRelease: attempting to release
uninitialized database")
- return C.ADBC_STATUS_INVALID_STATE
- }
cdb.db = nil
cdb.opts = nil
C.free(unsafe.Pointer(db.private_data))
@@ -274,16 +270,15 @@ func {{.Prefix}}ConnectionRelease(cnxn
*C.struct_AdbcConnection, err *C.struct_A
h := (*(*cgo.Handle)(cnxn.private_data))
conn := h.Value().(*cConn)
- if conn.cnxn == nil {
- setErr(err, "AdbcConnectionRelease: attempting to release
uninitialized connection")
- return C.ADBC_STATUS_INVALID_STATE
- }
defer func() {
conn.cnxn = nil
C.free(unsafe.Pointer(cnxn.private_data))
cnxn.private_data = nil
h.Delete()
}()
+ if conn.cnxn == nil {
+ return C.ADBC_STATUS_OK
+ }
return C.AdbcStatusCode(errToAdbcErr(err, conn.cnxn.Close()))
}
diff --git a/go/adbc/pkg/flightsql/driver.go b/go/adbc/pkg/flightsql/driver.go
index 74d7a66..ac5b399 100644
--- a/go/adbc/pkg/flightsql/driver.go
+++ b/go/adbc/pkg/flightsql/driver.go
@@ -178,12 +178,7 @@ func FlightSQLDatabaseRelease(db *C.struct_AdbcDatabase,
err *C.struct_AdbcError
return C.ADBC_STATUS_INVALID_STATE
}
h := (*(*cgo.Handle)(db.private_data))
-
cdb := h.Value().(*cDatabase)
- if cdb.db == nil {
- setErr(err, "AdbcDatabaseRelease: attempting to release
uninitialized database")
- return C.ADBC_STATUS_INVALID_STATE
- }
cdb.db = nil
cdb.opts = nil
C.free(unsafe.Pointer(db.private_data))
@@ -277,16 +272,16 @@ func FlightSQLConnectionRelease(cnxn
*C.struct_AdbcConnection, err *C.struct_Adb
h := (*(*cgo.Handle)(cnxn.private_data))
conn := h.Value().(*cConn)
- if conn.cnxn == nil {
- setErr(err, "AdbcConnectionRelease: attempting to release
uninitialized connection")
- return C.ADBC_STATUS_INVALID_STATE
- }
defer func() {
conn.cnxn = nil
C.free(unsafe.Pointer(cnxn.private_data))
cnxn.private_data = nil
h.Delete()
}()
+ if conn.cnxn == nil {
+ return C.ADBC_STATUS_OK
+ }
+
return C.AdbcStatusCode(errToAdbcErr(err, conn.cnxn.Close()))
}
diff --git a/go/adbc/validation/validation.go b/go/adbc/validation/validation.go
index 47d0d72..c94a3f6 100644
--- a/go/adbc/validation/validation.go
+++ b/go/adbc/validation/validation.go
@@ -141,10 +141,6 @@ func (c *ConnectionTests) TestAutocommitDefault() {
defer cnxn.Close()
expectedCode := adbc.StatusInvalidState
- if !c.Quirks.SupportsTransactions() {
- expectedCode = adbc.StatusNotImplemented
- }
-
var adbcError adbc.Error
err := cnxn.Commit(ctx)
c.ErrorAs(err, &adbcError)