From be3b855e01eeb3d176cc6ae619c84cf4dcb25890 Mon Sep 17 00:00:00 2001 From: David Li Date: Wed, 19 Jul 2023 12:24:28 -0400 Subject: [PATCH] fix(go/adbc/pkg): export Adbc* symbols on Windows Fixes #898. --- go/adbc/pkg/_tmpl/driver.go.tmpl | 6 +++++- go/adbc/pkg/flightsql/driver.go | 6 +++++- go/adbc/pkg/panicdummy/driver.go | 6 +++++- go/adbc/pkg/snowflake/driver.go | 6 +++++- .../adbc_driver_flightsql/tests/test_lowlevel.py | 14 ++++++++++++++ .../adbc_driver_snowflake/tests/test_lowlevel.py | 8 ++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/go/adbc/pkg/_tmpl/driver.go.tmpl b/go/adbc/pkg/_tmpl/driver.go.tmpl index 248800f7f9..7432f001b9 100644 --- a/go/adbc/pkg/_tmpl/driver.go.tmpl +++ b/go/adbc/pkg/_tmpl/driver.go.tmpl @@ -19,7 +19,11 @@ package main -// #cgo CXXFLAGS: -std=c++11 +// ADBC_EXPORTING is required on Windows, or else the symbols +// won't be accessible to the driver manager + +// #cgo CFLAGS: -DADBC_EXPORTING +// #cgo CXXFLAGS: -std=c++11 -DADBC_EXPORTING // #include "../../drivermgr/adbc.h" // #include "utils.h" // #include diff --git a/go/adbc/pkg/flightsql/driver.go b/go/adbc/pkg/flightsql/driver.go index 2936f90eff..a8a606dd0b 100644 --- a/go/adbc/pkg/flightsql/driver.go +++ b/go/adbc/pkg/flightsql/driver.go @@ -21,7 +21,11 @@ package main -// #cgo CXXFLAGS: -std=c++11 +// ADBC_EXPORTING is required on Windows, or else the symbols +// won't be accessible to the driver manager + +// #cgo CFLAGS: -DADBC_EXPORTING +// #cgo CXXFLAGS: -std=c++11 -DADBC_EXPORTING // #include "../../drivermgr/adbc.h" // #include "utils.h" // #include diff --git a/go/adbc/pkg/panicdummy/driver.go b/go/adbc/pkg/panicdummy/driver.go index 33a4f98424..73c34eae4f 100644 --- a/go/adbc/pkg/panicdummy/driver.go +++ b/go/adbc/pkg/panicdummy/driver.go @@ -21,7 +21,11 @@ package main -// #cgo CXXFLAGS: -std=c++11 +// ADBC_EXPORTING is required on Windows, or else the symbols +// won't be accessible to the driver manager + +// #cgo CFLAGS: -DADBC_EXPORTING +// #cgo CXXFLAGS: -std=c++11 -DADBC_EXPORTING // #include "../../drivermgr/adbc.h" // #include "utils.h" // #include diff --git a/go/adbc/pkg/snowflake/driver.go b/go/adbc/pkg/snowflake/driver.go index 12307b1aae..51b6ce5bc9 100644 --- a/go/adbc/pkg/snowflake/driver.go +++ b/go/adbc/pkg/snowflake/driver.go @@ -21,7 +21,11 @@ package main -// #cgo CXXFLAGS: -std=c++11 +// ADBC_EXPORTING is required on Windows, or else the symbols +// won't be accessible to the driver manager + +// #cgo CFLAGS: -DADBC_EXPORTING +// #cgo CXXFLAGS: -std=c++11 -DADBC_EXPORTING // #include "../../drivermgr/adbc.h" // #include "utils.h" // #include diff --git a/python/adbc_driver_flightsql/tests/test_lowlevel.py b/python/adbc_driver_flightsql/tests/test_lowlevel.py index 149888d4b7..23101c1f2b 100644 --- a/python/adbc_driver_flightsql/tests/test_lowlevel.py +++ b/python/adbc_driver_flightsql/tests/test_lowlevel.py @@ -16,11 +16,25 @@ # under the License. import pyarrow +import pytest import adbc_driver_flightsql import adbc_driver_manager +def test_load_driver(): + # Fails, but in environments where we don't spin up testing + # servers, this checks that we can at least *load* the driver + with pytest.raises( + adbc_driver_manager.OperationalError, match="Error while dialing" + ): + with adbc_driver_flightsql.connect("grpc://127.0.0.100:12345") as db: + with adbc_driver_manager.AdbcConnection(db) as conn: + with adbc_driver_manager.AdbcStatement(conn) as stmt: + stmt.set_sql_query("SELECT 1") + stmt.execute_query() + + def test_query_trivial(dremio): with adbc_driver_manager.AdbcStatement(dremio) as stmt: stmt.set_sql_query("SELECT 1") diff --git a/python/adbc_driver_snowflake/tests/test_lowlevel.py b/python/adbc_driver_snowflake/tests/test_lowlevel.py index 6186f8891a..18d1e778cb 100644 --- a/python/adbc_driver_snowflake/tests/test_lowlevel.py +++ b/python/adbc_driver_snowflake/tests/test_lowlevel.py @@ -29,6 +29,14 @@ def snowflake(snowflake_uri: str): yield conn +def test_load_driver(): + # Fails, but in environments where we don't spin up testing + # servers, this checks that we can at least *load* the driver + with pytest.raises(adbc_driver_manager.ProgrammingError, match="account is empty"): + with adbc_driver_snowflake.connect(""): + pass + + def test_query_trivial(snowflake): with adbc_driver_manager.AdbcStatement(snowflake) as stmt: stmt.set_sql_query("SELECT 1")