From fcf0d3c592afa6a22dd25e272c5652c29fd735bb Mon Sep 17 00:00:00 2001 From: Victor Tsang Date: Mon, 1 Dec 2025 16:28:18 -0800 Subject: [PATCH 1/8] Mac Setup ODBC ini Script * added setup script for mac and platform folders Co-Authored-By: Alina (Xi) Li Co-Authored-By: vic-tsang Update install_odbc.sh --- .../sql/odbc/install/mac/install_odbc.sh | 76 +++++++++++++++++ .../sql/odbc/install/mac/install_odbc_ini.sh | 82 +++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh create mode 100755 cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh new file mode 100644 index 00000000000..0916bff0845 --- /dev/null +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# +# 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. + +# Used by macOS ODBC installer script and macOS ODBC testing + +ODBC_64BIT="$1" + +if [[ -z "$ODBC_64BIT" ]]; then + echo "error: 64-bit driver is not specified. Call format: install_odbc abs_path_to_64_bit_driver" + exit 1 +fi + +if [ ! -f $ODBC_64BIT ]; then + echo "64-bit driver can not be found: $ODBC_64BIT" + echo "Call format: install_odbc abs_path_to_64_bit_driver" + exit 1 +fi + +USER_ODBCINST_FILE="$HOME/Library/ODBC/odbcinst.ini" +DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver" +DSN_NAME="Apache Arrow Flight SQL ODBC DSN" + +mkdir -p $HOME/Library/ODBC + +touch "$USER_ODBCINST_FILE" + +# Admin privilege is needed to add ODBC driver registration +if [ $EUID -ne 0 ]; then + echo "Please run this script with sudo" + exit 1 +fi + +if grep -q "^\[$DRIVER_NAME\]" "$USER_ODBCINST_FILE"; then + echo "Driver [$DRIVER_NAME] already exists in odbcinst.ini" +else + echo "Adding [$DRIVER_NAME] to odbcinst.ini..." + echo " +[$DRIVER_NAME] +Description=An ODBC Driver for Apache Arrow Flight SQL +Driver=$ODBC_64BIT +" >> "$USER_ODBCINST_FILE" +fi + +# Check if [ODBC Drivers] section exists +if grep -q '^\[ODBC Drivers\]' "$USER_ODBCINST_FILE"; then + # Section exists: check if driver entry exists + if ! grep -q "^${DRIVER_NAME}=" "$USER_ODBCINST_FILE"; then + # Driver entry does not exist, add under [ODBC Drivers] + sed -i '' "/^\[ODBC Drivers\]/a\\ +${DRIVER_NAME}=Installed +" "$USER_ODBCINST_FILE" + fi +else + # Section doesn't exist, append both section and driver entry at end + { + echo "" + echo "[ODBC Drivers]" + echo "${DRIVER_NAME}=Installed" + } >> "$USER_ODBCINST_FILE" +fi diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh new file mode 100755 index 00000000000..cfc9729ed7e --- /dev/null +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# +# 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. + +# GH-47876 TODO: create macOS ODBC Installer. +# Script for installing macOS ODBC driver, to be used for macOS installer. + +source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +odbc_install_script="${source_dir}/install_odbc.sh" + +chmod +x "$odbc_install_script" +. "$odbc_install_script" /Library/Apache/ArrowFlightSQLODBC/lib/libarrow_flight_sql_odbc.dylib + +USER_ODBC_FILE="$HOME/Library/ODBC/odbc.ini" +DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver" +DSN_NAME="Apache Arrow Flight SQL ODBC DSN" + +touch "$USER_ODBC_FILE" + +if [ $EUID -ne 0 ]; then + echo "Please run this script with sudo" + exit 1 +fi + +if grep -q "^\[$DSN_NAME\]" "$USER_ODBC_FILE"; then + echo "DSN [$DSN_NAME] already exists in $USER_ODBC_FILE" +else + echo "Adding [$DSN_NAME] to $USER_ODBC_FILE..." + cat >> "$USER_ODBC_FILE" < "${USER_ODBC_FILE}.tmp" && mv "${USER_ODBC_FILE}.tmp" "$USER_ODBC_FILE" + fi +else + # Section doesn't exist, append section and DSN entry at end + { + echo "" + echo "[ODBC Data Sources]" + echo "${DSN_NAME}=${DRIVER_NAME}" + } >> "$USER_ODBC_FILE" +fi + From d23125476f65405daf4eed320085f405135104dd Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Tue, 6 Jan 2026 15:14:06 -0800 Subject: [PATCH 2/8] Apply suggestions from David - Moved admin check upwards - removed sourcing of script that isn't required --- .../flight/sql/odbc/install/mac/install_odbc.sh | 16 +++++++++------- .../sql/odbc/install/mac/install_odbc_ini.sh | 17 ++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) mode change 100644 => 100755 cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh old mode 100644 new mode 100755 index 0916bff0845..cf96255b715 --- a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh @@ -17,7 +17,15 @@ # specific language governing permissions and limitations # under the License. -# Used by macOS ODBC installer script and macOS ODBC testing +# Used by macOS ODBC installer script `install_odbc_ini.sh` and macOS ODBC testing + +set -euo pipefail + +# Admin privilege is needed to add ODBC driver registration +if [ $EUID -ne 0 ]; then + echo "Please run this script with sudo" + exit 1 +fi ODBC_64BIT="$1" @@ -40,12 +48,6 @@ mkdir -p $HOME/Library/ODBC touch "$USER_ODBCINST_FILE" -# Admin privilege is needed to add ODBC driver registration -if [ $EUID -ne 0 ]; then - echo "Please run this script with sudo" - exit 1 -fi - if grep -q "^\[$DRIVER_NAME\]" "$USER_ODBCINST_FILE"; then echo "Driver [$DRIVER_NAME] already exists in odbcinst.ini" else diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh index cfc9729ed7e..0385453a720 100755 --- a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh @@ -19,13 +19,21 @@ # GH-47876 TODO: create macOS ODBC Installer. # Script for installing macOS ODBC driver, to be used for macOS installer. +# This script assumes ODBC driver is at +# /Library/ODBC/arrow-odbc/libarrow_flight_sql_odbc.dylib + +set -euo pipefail + +if [ $EUID -ne 0 ]; then + echo "Please run this script with sudo" + exit 1 +fi source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" odbc_install_script="${source_dir}/install_odbc.sh" -chmod +x "$odbc_install_script" -. "$odbc_install_script" /Library/Apache/ArrowFlightSQLODBC/lib/libarrow_flight_sql_odbc.dylib +"$odbc_install_script" /Library/ODBC/arrow-odbc/libarrow_flight_sql_odbc.dylib USER_ODBC_FILE="$HOME/Library/ODBC/odbc.ini" DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver" @@ -33,11 +41,6 @@ DSN_NAME="Apache Arrow Flight SQL ODBC DSN" touch "$USER_ODBC_FILE" -if [ $EUID -ne 0 ]; then - echo "Please run this script with sudo" - exit 1 -fi - if grep -q "^\[$DSN_NAME\]" "$USER_ODBC_FILE"; then echo "DSN [$DSN_NAME] already exists in $USER_ODBC_FILE" else From b0812fd2bdce1b30518e85919da9513842ee2157 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Wed, 7 Jan 2026 14:12:36 -0800 Subject: [PATCH 3/8] Use `#!/bin/bash` for scripts The scripts assume bash shells on macOS are used. --- cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh | 2 +- cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh index cf96255b715..0e2e626b79f 100755 --- a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh index 0385453a720..652034f4946 100755 --- a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file From 0aaf41d0ec995d7853e0a611983462bf67450805 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Mon, 9 Feb 2026 16:01:41 -0800 Subject: [PATCH 4/8] Register ODBC on macOS --- .github/workflows/cpp_extra.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index b38ccaa2779..d565107f856 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -395,6 +395,10 @@ jobs: export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR" export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR" ci/scripts/cpp_build.sh $(pwd) $(pwd)/build + - name: Register Flight SQL ODBC Driver + run: | + chmod +x cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh + sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh $(pwd)/build/cpp/debug/libarrow_flight_sql_odbc.dylib - name: Test shell: bash run: | From 06619c81a576292ed51fab52d90f12ebc9af76fe Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Wed, 11 Feb 2026 10:46:21 -0800 Subject: [PATCH 5/8] Remove `chmod +x` command The scripts are already executable. `chmod +x` should not be needed --- .github/workflows/cpp_extra.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index d565107f856..50ea4ebe61a 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -397,7 +397,6 @@ jobs: ci/scripts/cpp_build.sh $(pwd) $(pwd)/build - name: Register Flight SQL ODBC Driver run: | - chmod +x cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh $(pwd)/build/cpp/debug/libarrow_flight_sql_odbc.dylib - name: Test shell: bash From 7a0e1647ed56f802ef16b15da03c862d40b7ab9b Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Wed, 11 Feb 2026 10:46:42 -0800 Subject: [PATCH 6/8] Delete install_odbc_ini.sh --- .../sql/odbc/install/mac/install_odbc_ini.sh | 85 ------------------- 1 file changed, 85 deletions(-) delete mode 100755 cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh deleted file mode 100755 index 652034f4946..00000000000 --- a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc_ini.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/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 -# 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. - -# GH-47876 TODO: create macOS ODBC Installer. -# Script for installing macOS ODBC driver, to be used for macOS installer. -# This script assumes ODBC driver is at -# /Library/ODBC/arrow-odbc/libarrow_flight_sql_odbc.dylib - -set -euo pipefail - -if [ $EUID -ne 0 ]; then - echo "Please run this script with sudo" - exit 1 -fi - -source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -odbc_install_script="${source_dir}/install_odbc.sh" - -"$odbc_install_script" /Library/ODBC/arrow-odbc/libarrow_flight_sql_odbc.dylib - -USER_ODBC_FILE="$HOME/Library/ODBC/odbc.ini" -DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver" -DSN_NAME="Apache Arrow Flight SQL ODBC DSN" - -touch "$USER_ODBC_FILE" - -if grep -q "^\[$DSN_NAME\]" "$USER_ODBC_FILE"; then - echo "DSN [$DSN_NAME] already exists in $USER_ODBC_FILE" -else - echo "Adding [$DSN_NAME] to $USER_ODBC_FILE..." - cat >> "$USER_ODBC_FILE" < "${USER_ODBC_FILE}.tmp" && mv "${USER_ODBC_FILE}.tmp" "$USER_ODBC_FILE" - fi -else - # Section doesn't exist, append section and DSN entry at end - { - echo "" - echo "[ODBC Data Sources]" - echo "${DSN_NAME}=${DRIVER_NAME}" - } >> "$USER_ODBC_FILE" -fi - From 35c51c58f4c0d983b5c016805a93c6879ff58413 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Thu, 12 Feb 2026 11:04:00 -0800 Subject: [PATCH 7/8] Add `install_odbc.sh` to `.pre-commit-config.yaml` --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 566ade91721..a33aa3acb47 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -353,6 +353,7 @@ repos: ?^cpp/build-support/update-thrift\.sh$| ?^cpp/examples/minimal_build/run\.sh$| ?^cpp/examples/tutorial_examples/run\.sh$| + ?^cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc\.sh$| ?^dev/release/05-binary-upload\.sh$| ?^dev/release/08-binary-verify\.sh$| ?^dev/release/binary-recover\.sh$| @@ -379,6 +380,7 @@ repos: files: >- ( ?^ci/scripts/python_test_type_annotations\.sh$| + ?^cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc\.sh$| ?^dev/release/05-binary-upload\.sh$| ?^dev/release/binary-recover\.sh$| ?^dev/release/post-03-binary\.sh$| From 9ce0a758a5de782830816dec971941b6a5c4ee72 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Thu, 12 Feb 2026 11:15:02 -0800 Subject: [PATCH 8/8] Fix Formatting --- .../sql/odbc/install/mac/install_odbc.sh | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh index 0e2e626b79f..069c534c297 100755 --- a/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh +++ b/cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh @@ -22,9 +22,9 @@ set -euo pipefail # Admin privilege is needed to add ODBC driver registration -if [ $EUID -ne 0 ]; then - echo "Please run this script with sudo" - exit 1 +if [ $EUID -ne 0 ]; then + echo "Please run this script with sudo" + exit 1 fi ODBC_64BIT="$1" @@ -34,17 +34,16 @@ if [[ -z "$ODBC_64BIT" ]]; then exit 1 fi -if [ ! -f $ODBC_64BIT ]; then - echo "64-bit driver can not be found: $ODBC_64BIT" - echo "Call format: install_odbc abs_path_to_64_bit_driver" - exit 1 +if [ ! -f "$ODBC_64BIT" ]; then + echo "64-bit driver can not be found: $ODBC_64BIT" + echo "Call format: install_odbc abs_path_to_64_bit_driver" + exit 1 fi USER_ODBCINST_FILE="$HOME/Library/ODBC/odbcinst.ini" DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver" -DSN_NAME="Apache Arrow Flight SQL ODBC DSN" -mkdir -p $HOME/Library/ODBC +mkdir -p "$HOME"/Library/ODBC touch "$USER_ODBCINST_FILE" @@ -56,7 +55,7 @@ else [$DRIVER_NAME] Description=An ODBC Driver for Apache Arrow Flight SQL Driver=$ODBC_64BIT -" >> "$USER_ODBCINST_FILE" +" >>"$USER_ODBCINST_FILE" fi # Check if [ODBC Drivers] section exists @@ -74,5 +73,5 @@ else echo "" echo "[ODBC Drivers]" echo "${DRIVER_NAME}=Installed" - } >> "$USER_ODBCINST_FILE" + } >>"$USER_ODBCINST_FILE" fi