Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ jobs:
ARROW_DATASET: ON
ARROW_FLIGHT: ON
ARROW_FLIGHT_SQL: ON
ARROW_FLIGHT_SQL_ODBC: ON
ARROW_GANDIVA: ON
ARROW_GCS: ON
ARROW_HDFS: OFF
Expand Down
43 changes: 43 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2290,3 +2290,46 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--------------------------------------------------------------------------------
The files cpp/src/arrow/vendored/whereami/whereami.h,
cpp/src/arrow/vendored/whereami/whereami.cc are adapted from
Grégory Pakosz's whereami library (https://github.com/gpakosz/whereami)
It is dual licensed under both the WTFPLv2 and MIT licenses.
Comment on lines +2294 to +2298
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied both WTFPLv2 and MIT licenses from gpakosz/whereami@e64e8b3


The WTFPLv2 License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
1. Bla bla bla
2. Montesqieu et camembert, vive la France, zut alors!

The MIT License (MIT)
Copyright Gregory Pakosz

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"cacheVariables": {
"ARROW_BUILD_EXAMPLES": "ON",
"ARROW_BUILD_UTILITIES": "ON",
"ARROW_FLIGHT_SQL_ODBC": "ON",
"ARROW_SKYHOOK": "ON",
"ARROW_TENSORFLOW": "ON",
"PARQUET_BUILD_EXAMPLES": "ON",
Expand Down
3 changes: 3 additions & 0 deletions cpp/build-support/lint_cpp_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def lint_file(path):

EXCLUSIONS = _paths('''\
arrow/arrow-config.cmake
arrow/flight/sql/odbc/flight_sql/get_info_cache.h
arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/blocking_queue.h
arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h
Comment on lines +80 to +82
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need them?
Are they copied from somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arrow/flight/sql/odbc code are part of the flightsql-odbc contribution.

CLI/C++ support is being removed (#45810) to allow usage of std::mutex, so adding the lint ignore here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. Let's work on #45810 (remove CLI/C++ support) before this.

Do you want to work on #45810 or do you want me to work on #45810?

arrow/python/iterators.h
arrow/util/hashing.h
arrow/util/macros.h
Expand Down
7 changes: 7 additions & 0 deletions cpp/cmake_modules/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ takes precedence over ccache if a storage backend is configured" ON)
DEPENDS
ARROW_FLIGHT)

define_option(ARROW_FLIGHT_SQL_ODBC
"Build the Arrow Flight SQL ODBC extension"
OFF
DEPENDS
ARROW_FLIGHT_SQL
ARROW_COMPUTE)

define_option(ARROW_GANDIVA
"Build the Gandiva libraries"
OFF
Expand Down
13 changes: 12 additions & 1 deletion cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ if(ARROW_AZURE)
set(ARROW_WITH_AZURE_SDK ON)
endif()

if(ARROW_JSON)
if(ARROW_JSON OR ARROW_FLIGHT_SQL_ODBC)
set(ARROW_WITH_RAPIDJSON ON)
endif()

Expand Down Expand Up @@ -1261,6 +1261,7 @@ endif()
if(ARROW_BUILD_INTEGRATION
OR ARROW_BUILD_TESTS
OR (ARROW_FLIGHT AND (ARROW_TESTING OR ARROW_BUILD_BENCHMARKS))
OR ARROW_FLIGHT_SQL_ODBC
OR (ARROW_S3 AND ARROW_BUILD_BENCHMARKS)
OR (ARROW_TESTING AND ARROW_BUILD_SHARED))
set(ARROW_USE_BOOST TRUE)
Expand All @@ -1287,6 +1288,9 @@ if(ARROW_USE_BOOST)
endif()
if(ARROW_BOOST_REQUIRE_LIBRARY)
set(ARROW_BOOST_COMPONENTS filesystem system)
if(ARROW_FLIGHT_SQL_ODBC AND MSVC)
list(APPEND ARROW_BOOST_COMPONENTS locale)
endif()
set(ARROW_BOOST_OPTIONAL_COMPONENTS process)
else()
set(ARROW_BOOST_COMPONENTS)
Expand Down Expand Up @@ -5561,4 +5565,11 @@ if(ARROW_WITH_AZURE_SDK)
Azure::azure-storage-blobs Azure::azure-identity)
endif()

# ----------------------------------------------------------------------
# Apache Flight SQL ODBC

if(ARROW_FLIGHT_SQL_ODBC)
find_package(ODBC REQUIRED)
endif()

message(STATUS "All bundled static libraries: ${ARROW_BUNDLED_STATIC_LIBS}")
4 changes: 4 additions & 0 deletions cpp/src/arrow/flight/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
endforeach()
endif()
endif()

if(ARROW_FLIGHT_SQL_ODBC)
add_subdirectory(odbc)
endif()
21 changes: 21 additions & 0 deletions cpp/src/arrow/flight/sql/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

add_custom_target(arrow_flight_sql_odbc)

add_subdirectory(flight_sql)
add_subdirectory(odbcabstraction)
140 changes: 140 additions & 0 deletions cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# 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.

add_library(arrow_odbc_spi_impl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use our add_arrow_lib() instead?

function(ADD_ARROW_LIB LIB_NAME)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an upcoming PR#46099 that uses add_arrow_lib(arrow_flight_sql_odbc) to add an arrow library at the odbc directory. The flight_sql and odbcabstraction directories are subfolders to arrow_flight_sql_odbc, so I suggest we keep add_library for these 2 subfolders.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I may misunderstand your comment... What will be focused in #46099? Will #46099 focus on replacing add_library() with add_arrow_lib()?

The flight_sql and odbcabstraction directories are subfolders to arrow_flight_sql_odbc, so I suggest we keep add_library for these 2 subfolders.

Could you explain why add_library() is better for them? (I'm not sure why "subfolders" is important here.)

include/flight_sql/flight_sql_driver.h
accessors/binary_array_accessor.cc
accessors/binary_array_accessor.h
accessors/boolean_array_accessor.cc
accessors/boolean_array_accessor.h
accessors/common.h
accessors/date_array_accessor.cc
accessors/date_array_accessor.h
accessors/decimal_array_accessor.cc
accessors/decimal_array_accessor.h
accessors/main.h
accessors/primitive_array_accessor.cc
accessors/primitive_array_accessor.h
accessors/string_array_accessor.cc
accessors/string_array_accessor.h
accessors/time_array_accessor.cc
accessors/time_array_accessor.h
accessors/timestamp_array_accessor.cc
accessors/timestamp_array_accessor.h
address_info.cc
address_info.h
flight_sql_auth_method.cc
flight_sql_auth_method.h
flight_sql_connection.cc
flight_sql_connection.h
flight_sql_driver.cc
flight_sql_get_tables_reader.cc
flight_sql_get_tables_reader.h
flight_sql_get_type_info_reader.cc
flight_sql_get_type_info_reader.h
flight_sql_result_set.cc
flight_sql_result_set.h
flight_sql_result_set_accessors.cc
flight_sql_result_set_accessors.h
flight_sql_result_set_column.cc
flight_sql_result_set_column.h
flight_sql_result_set_metadata.cc
flight_sql_result_set_metadata.h
flight_sql_ssl_config.cc
flight_sql_ssl_config.h
flight_sql_statement.cc
flight_sql_statement.h
flight_sql_statement_get_columns.cc
flight_sql_statement_get_columns.h
flight_sql_statement_get_tables.cc
flight_sql_statement_get_tables.h
flight_sql_statement_get_type_info.cc
flight_sql_statement_get_type_info.h
flight_sql_stream_chunk_buffer.cc
flight_sql_stream_chunk_buffer.h
get_info_cache.cc
get_info_cache.h
json_converter.cc
json_converter.h
record_batch_transformer.cc
record_batch_transformer.h
scalar_function_reporter.cc
scalar_function_reporter.h
system_trust_store.cc
system_trust_store.h
utils.cc)
target_include_directories(arrow_odbc_spi_impl
PUBLIC include include/flight_sql
${CMAKE_SOURCE_DIR}/odbcabstraction/include)
target_include_directories(arrow_odbc_spi_impl PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if(WIN32)
target_sources(arrow_odbc_spi_impl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_sources(arrow_odbc_spi_impl
target_sources(arrow_odbc_spi_impl PRIVATE

According to cmake docs, target_sources need a INTERFACE, PUBLIC or PRIVATE keyword to be able to build. I feel PRIVATE might be suitable here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the keyword resolved some build issues from my local environment

PRIVATE include/flight_sql/config/configuration.h
include/flight_sql/config/connection_string_parser.h
include/flight_sql/ui/add_property_window.h
include/flight_sql/ui/custom_window.h
include/flight_sql/ui/dsn_configuration_window.h
include/flight_sql/ui/window.h
config/configuration.cc
config/connection_string_parser.cc
ui/custom_window.cc
ui/window.cc
ui/dsn_configuration_window.cc
ui/add_property_window.cc
system_dsn.cc)
endif()

target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction arrow_flight_sql_shared)

if(MSVC)
target_link_libraries(arrow_odbc_spi_impl PUBLIC Boost::locale)
endif()

set_target_properties(arrow_odbc_spi_impl
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/lib
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/lib
RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/lib)
Comment on lines +108 to +114
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may be able to remove this by add_arrow_lib().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# CLI
add_executable(arrow_odbc_spi_impl_cli main.cc)
set_target_properties(arrow_odbc_spi_impl_cli
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/bin)
target_link_libraries(arrow_odbc_spi_impl_cli arrow_odbc_spi_impl)

# Unit tests
add_arrow_test(arrow_odbc_spi_impl_test
SOURCES
accessors/boolean_array_accessor_test.cc
accessors/binary_array_accessor_test.cc
accessors/date_array_accessor_test.cc
accessors/decimal_array_accessor_test.cc
accessors/primitive_array_accessor_test.cc
accessors/string_array_accessor_test.cc
accessors/time_array_accessor_test.cc
accessors/timestamp_array_accessor_test.cc
flight_sql_connection_test.cc
parse_table_types_test.cc
json_converter_test.cc
record_batch_transformer_test.cc
utils_test.cc
EXTRA_LINK_LIBS
arrow_odbc_spi_impl)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// 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 "arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.h"

#include <algorithm>
#include <cstdint>
#include "arrow/array.h"

namespace driver {
namespace flight_sql {

using arrow::BinaryArray;
using odbcabstraction::RowStatus;

namespace {

inline RowStatus MoveSingleCellToBinaryBuffer(ColumnBinding* binding, BinaryArray* array,
int64_t arrow_row, int64_t i,
int64_t& value_offset,
bool update_value_offset,
odbcabstraction::Diagnostics& diagnostics) {
RowStatus result = odbcabstraction::RowStatus_SUCCESS;

const char* value = array->Value(arrow_row).data();
size_t size_in_bytes = array->value_length(arrow_row);

size_t remaining_length = static_cast<size_t>(size_in_bytes - value_offset);
size_t value_length = std::min(remaining_length, binding->buffer_length);

auto* byte_buffer =
static_cast<unsigned char*>(binding->buffer) + i * binding->buffer_length;
memcpy(byte_buffer, ((char*)value) + value_offset, value_length);

if (remaining_length > binding->buffer_length) {
result = odbcabstraction::RowStatus_SUCCESS_WITH_INFO;
diagnostics.AddTruncationWarning();
if (update_value_offset) {
value_offset += value_length;
}
} else if (update_value_offset) {
value_offset = -1;
}

if (binding->strlen_buffer) {
binding->strlen_buffer[i] = static_cast<ssize_t>(remaining_length);
}

return result;
}

} // namespace

template <CDataType TARGET_TYPE>
BinaryArrayFlightSqlAccessor<TARGET_TYPE>::BinaryArrayFlightSqlAccessor(Array* array)
: FlightSqlAccessor<BinaryArray, TARGET_TYPE,
BinaryArrayFlightSqlAccessor<TARGET_TYPE>>(array) {}

template <>
RowStatus
BinaryArrayFlightSqlAccessor<odbcabstraction::CDataType_BINARY>::MoveSingleCell_impl(
ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset,
bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) {
return MoveSingleCellToBinaryBuffer(binding, this->GetArray(), arrow_row, i,
value_offset, update_value_offset, diagnostics);
}

template <CDataType TARGET_TYPE>
size_t BinaryArrayFlightSqlAccessor<TARGET_TYPE>::GetCellLength_impl(
ColumnBinding* binding) const {
return binding->buffer_length;
}

template class BinaryArrayFlightSqlAccessor<odbcabstraction::CDataType_BINARY>;

} // namespace flight_sql
} // namespace driver
Loading
Loading