Skip to content

Commit

Permalink
build(c): Fix linker error with SQLite tests (#2260)
Browse files Browse the repository at this point in the history
Noticed this when compiled via meson:

```base
$ meson setup builddir -Dtests=true -Dsqlite=true
$ meson compile -C builddir

...

/usr/bin/ld: driver/sqlite/adbc-driver-sqlite-test.p/sqlite_test.cc.o: in function `SqliteStatementTest_SqlIngestUInt64_Test::TestBody()':
sqlite_test.cc:(.text+0x802): undefined reference to `void adbc_validation::StatementTest::TestSqlIngestType<unsigned long>(ArrowType, std::vector<std::optional<unsigned long>, std::allocator<std::optional<unsigned long> > > const&, bool)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
```

I'm not sure why the CMake config is OK with this, likely some magic I
don't understand. However, it makes sense to me that the linker is
complaining; the adbc_validation.h header declares this template but the
definition is tucked away in adbc_validation_statement.cc. So I don't
think the TU for sqlite_test.cc would have access to that (?) without
moving the definition to the header.

Alternatively we could provide an explicit template instantiation for
the type (uint64_t) in adbc_validation_statement.cc, though I don't
think that is inline with the intent of this class
  • Loading branch information
WillAyd authored Oct 22, 2024
1 parent 266ee02 commit 0d0ce79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 8 additions & 0 deletions c/validation/adbc_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ class StatementTest {
const char* timezone);
};

template <typename CType>
void StatementTest::TestSqlIngestType(ArrowType type,
const std::vector<std::optional<CType>>& values,
bool dictionary_encode) {
SchemaField field("col", type);
TestSqlIngestType<CType>(field, values, dictionary_encode);
}

#define ADBCV_TEST_STATEMENT(FIXTURE) \
static_assert(std::is_base_of<adbc_validation::StatementTest, FIXTURE>::value, \
ADBCV_STRINGIFY(FIXTURE) " must inherit from StatementTest"); \
Expand Down
8 changes: 0 additions & 8 deletions c/validation/adbc_validation_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@ void StatementTest::TestSqlIngestType(SchemaField field,
ASSERT_THAT(AdbcStatementRelease(&statement, &error), IsOkStatus(&error));
}

template <typename CType>
void StatementTest::TestSqlIngestType(ArrowType type,
const std::vector<std::optional<CType>>& values,
bool dictionary_encode) {
SchemaField field("col", type);
TestSqlIngestType<CType>(field, values, dictionary_encode);
}

template <typename CType>
void StatementTest::TestSqlIngestNumericType(ArrowType type) {
std::vector<std::optional<CType>> values = {
Expand Down

0 comments on commit 0d0ce79

Please sign in to comment.