Skip to content

Commit

Permalink
Bump to ADBC 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Feb 18, 2024
1 parent a9274eb commit 94bb08e
Show file tree
Hide file tree
Showing 36 changed files with 7,655 additions and 6,498 deletions.
44 changes: 44 additions & 0 deletions 3rd_party/apache-arrow-adbc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,47 @@
### Refactor

- **r/adbcdrivermanager**: Use C++ base driver to implement test drivers (#1269)

## ADBC Libraries 0.10.0 (2024-02-18)

### Feat

- **java/driver/flight-sql**: implement getObjects (#1517)
- **go/adbc/driver/snowflake**: add '[ADBC]' to snowflake application name (#1525)
- **python/adbc_driver_manager**: handle KeyboardInterrupt (#1509)
- **csharp/src/Drivers/BigQuery**: add override for excluding table constraints (#1512)
- **java/driver/flight-sql**: add basic auth (#1487)
- **c/driver/postgresql**: Add enum type support (#1485)
- **go/adbc/driver/flightsql**: propagate cookies to sub-clients (#1497)
- **go/adbc/driver/snowflake**: improve bulk ingestion speed (#1456)
- **glib**: Add Apache Arrow GLib integration library (#1459)
- **go/adbc/driver/flightsql**: enable incremental queries (#1457)
- **go/adbc**: close database explicitly (#1460)

### Refactor

- **c/validation**: split up large test file (#1541)
- **c/driver/postgresql**: update with C++17 conventions (#1540)
- **c/driver/postgresql**: No naked new in copy/reader.h (#1503)
- **c/driver/postgresql**: No naked new in copy writer (#1498)
- **c/driver/postgresql**: start C++17 (#1472)
- **csharp/test/Drivers/Interop/Snowflake**: Updated the metadata tests to work without the db name (#1352)
- **c/driver/postgresql**: Split postgres_copy_reader.h into reader/writer headers (#1432)

### Fix

- **python/adbc_driver_manager**: return 'real' reader in fetch_record_batch (#1530)
- **go/adbc/driver/flightsql**: use atomic for progress (#1520)
- **c/driver/postgresql**: add postgres type to cols created for numeric (#1516)
- **csharp/src/Drivers/BigQuery**: fix support for large results (#1507)
- **c/driver/postgresql**: fix numeric to str (#1502)
- **go/adbc/driver/snowflake**: Make SHOW WAREHOUSES test less flaky (#1494)
- **csharp/src/Drivers/BigQuery**: add support for scopes (#1482)
- **r/adbcpostgresql**: Link -lcrypt32 on Windows (#1471)
- **csharp/src/Drivers/BigQuery**: improved support for ARRAY columns (#1356)
- **java/driver/jdbc**: improve error messages thrown from JdbcDataSource connect failures (#1466)
- **ci**: remove invalid --version=14 clang-format argument (#1462)
- **r/adbcdrivermanager**: Use std::vector<uint8_t> instead of std::basic_string<uint8_t> (#1453)
- **dev/release**: remove gtest without prompting on Windows (#1439)
- **dev/release,glib**: set library path to run example (#1436)
- **dev/release,go**: ensure temporary directory removable (#1438)
11 changes: 10 additions & 1 deletion 3rd_party/apache-arrow-adbc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ $ cargo test

## Opening a Pull Request

Before opening a pull request:

1. Please check if there is a corresponding issue (_and if not, please make one_).
2. Assign the issue to yourself by commenting "take" in the issue.
(_Here's an [example](https://github.com/apache/arrow-adbc/issues/1505#issuecomment-1920134722)._)
3. At the bottom of the PR description, add `Closes #NNNN` where `NNNN` is the
issue number, so that the issue gets linked to your PR properly. ("Fixes"
and other keywords that GitHub recognizes are also OK, of course.)

Before opening a pull request, please run the static checks, which are
enforced via [`pre-commit`](https://pre-commit.com/). This will run
linters, formatters, and other analysis. For example:
Expand Down Expand Up @@ -347,7 +356,7 @@ $ cd go/adbc && go-licenses report ./... \
--ignore github.com/apache/arrow/go/v11 \
--ignore github.com/apache/arrow/go/v12 \
--ignore github.com/apache/arrow/go/v13 \
--ignore github.com/apache/arrow/go/v14 \
--ignore github.com/apache/arrow/go/v15 \
--template ../../license.tpl > ../../LICENSE.txt 2> /dev/null
```

Expand Down
2 changes: 2 additions & 0 deletions 3rd_party/apache-arrow-adbc/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ include(BuildUtils)
project(adbc
VERSION "${ADBC_BASE_VERSION}"
LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(CTest)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# ------------------------------------------------------------
# Version definitions

set(ADBC_VERSION "0.9.0")
set(ADBC_VERSION "0.10.0")
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" ADBC_BASE_VERSION "${ADBC_VERSION}")
string(REPLACE "." ";" _adbc_version_list "${ADBC_BASE_VERSION}")
list(GET _adbc_version_list 0 ADBC_VERSION_MAJOR)
Expand Down
23 changes: 22 additions & 1 deletion 3rd_party/apache-arrow-adbc/c/driver/postgresql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ if(ADBC_BUILD_TESTS)
driver-postgresql
SOURCES
postgres_type_test.cc
postgres_copy_reader_test.cc
postgresql_test.cc
EXTRA_LINK_LIBS
adbc_driver_common
Expand All @@ -91,6 +90,28 @@ if(ADBC_BUILD_TESTS)
${REPOSITORY_ROOT}/c/vendor
${REPOSITORY_ROOT}/c/driver)
adbc_configure_target(adbc-driver-postgresql-test)

add_test_case(driver_postgresql_copy_test
PREFIX
adbc
EXTRA_LABELS
driver-postgresql
SOURCES
copy/postgres_copy_reader_test.cc
copy/postgres_copy_writer_test.cc
EXTRA_LINK_LIBS
adbc_driver_common
adbc_validation
nanoarrow
${TEST_LINK_LIBS})
target_compile_features(adbc-driver-postgresql-copy-test PRIVATE cxx_std_17)
target_include_directories(adbc-driver-postgresql-copy-test SYSTEM
PRIVATE ${REPOSITORY_ROOT}
${REPOSITORY_ROOT}/c/
${LIBPQ_INCLUDE_DIRS}
${REPOSITORY_ROOT}/c/vendor
${REPOSITORY_ROOT}/c/driver)
adbc_configure_target(adbc-driver-postgresql-copy-test)
endif()

if(ADBC_BUILD_BENCHMARKS)
Expand Down
32 changes: 13 additions & 19 deletions 3rd_party/apache-arrow-adbc/c/driver/postgresql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_

for (PqResultRow row : result_helper) {
auto reltuples = row[5].ParseDouble();
if (!reltuples.first) {
if (!reltuples) {
SetError(error, "[libpq] Invalid double value in reltuples: '%s'", row[5].data);
return ADBC_STATUS_INTERNAL;
}
Expand All @@ -946,8 +946,7 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
CHECK_NA(INTERNAL,
ArrowArrayAppendInt(statistics_key_col, ADBC_STATISTIC_ROW_COUNT_KEY),
error);
CHECK_NA(INTERNAL, ArrowArrayAppendDouble(value_float64_col, reltuples.second),
error);
CHECK_NA(INTERNAL, ArrowArrayAppendDouble(value_float64_col, *reltuples), error);
CHECK_NA(INTERNAL,
ArrowArrayFinishUnionElement(statistics_value_col, kStatsVariantFloat64),
error);
Expand All @@ -957,7 +956,7 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
}

auto null_frac = row[2].ParseDouble();
if (!null_frac.first) {
if (!null_frac) {
SetError(error, "[libpq] Invalid double value in null_frac: '%s'", row[2].data);
return ADBC_STATUS_INTERNAL;
}
Expand All @@ -973,18 +972,16 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
CHECK_NA(INTERNAL,
ArrowArrayAppendInt(statistics_key_col, ADBC_STATISTIC_NULL_COUNT_KEY),
error);
CHECK_NA(
INTERNAL,
ArrowArrayAppendDouble(value_float64_col, null_frac.second * reltuples.second),
error);
CHECK_NA(INTERNAL,
ArrowArrayAppendDouble(value_float64_col, *null_frac * *reltuples), error);
CHECK_NA(INTERNAL,
ArrowArrayFinishUnionElement(statistics_value_col, kStatsVariantFloat64),
error);
CHECK_NA(INTERNAL, ArrowArrayAppendInt(statistics_is_approximate_col, 1), error);
CHECK_NA(INTERNAL, ArrowArrayFinishElement(db_schema_statistics_items), error);

auto average_byte_width = row[3].ParseDouble();
if (!average_byte_width.first) {
if (!average_byte_width) {
SetError(error, "[libpq] Invalid double value in avg_width: '%s'", row[3].data);
return ADBC_STATUS_INTERNAL;
}
Expand All @@ -1001,8 +998,7 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
INTERNAL,
ArrowArrayAppendInt(statistics_key_col, ADBC_STATISTIC_AVERAGE_BYTE_WIDTH_KEY),
error);
CHECK_NA(INTERNAL,
ArrowArrayAppendDouble(value_float64_col, average_byte_width.second),
CHECK_NA(INTERNAL, ArrowArrayAppendDouble(value_float64_col, *average_byte_width),
error);
CHECK_NA(INTERNAL,
ArrowArrayFinishUnionElement(statistics_value_col, kStatsVariantFloat64),
Expand All @@ -1011,7 +1007,7 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
CHECK_NA(INTERNAL, ArrowArrayFinishElement(db_schema_statistics_items), error);

auto n_distinct = row[4].ParseDouble();
if (!n_distinct.first) {
if (!n_distinct) {
SetError(error, "[libpq] Invalid double value in avg_width: '%s'", row[4].data);
return ADBC_STATUS_INTERNAL;
}
Expand All @@ -1031,13 +1027,11 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
// > the column. If less than zero, the negative of the number of
// > distinct values divided by the number of rows.
// https://www.postgresql.org/docs/current/view-pg-stats.html
CHECK_NA(
INTERNAL,
ArrowArrayAppendDouble(value_float64_col,
n_distinct.second > 0
? n_distinct.second
: (std::fabs(n_distinct.second) * reltuples.second)),
error);
CHECK_NA(INTERNAL,
ArrowArrayAppendDouble(
value_float64_col,
*n_distinct > 0 ? *n_distinct : (std::fabs(*n_distinct) * *reltuples)),
error);
CHECK_NA(INTERNAL,
ArrowArrayFinishUnionElement(statistics_value_col, kStatsVariantFloat64),
error);
Expand Down
45 changes: 45 additions & 0 deletions 3rd_party/apache-arrow-adbc/c/driver/postgresql/copy/copy_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.

#pragma once

// Windows
#define NOMINMAX

#include <cstdint>

// R 3.6 / Windows builds on a very old toolchain that does not define ENODATA
#if defined(_WIN32) && !defined(MSVC) && !defined(ENODATA)
#define ENODATA 120
#endif

namespace adbcpq {

// "PGCOPY\n\377\r\n\0"
static int8_t kPgCopyBinarySignature[] = {0x50, 0x47, 0x43, 0x4F,
0x50, 0x59, 0x0A, static_cast<int8_t>(0xFF),
0x0D, 0x0A, 0x00};

// The maximum value in microseconds that can be converted into nanoseconds
// without overflow
constexpr int64_t kMaxSafeMicrosToNanos = 9223372036854775L;

// The minimum value in microseconds that can be converted into nanoseconds
// without overflow
constexpr int64_t kMinSafeMicrosToNanos = -9223372036854775L;

} // namespace adbcpq
Loading

0 comments on commit 94bb08e

Please sign in to comment.