Skip to content

Commit e2aad46

Browse files
alinaliBQvic-tsang
andauthored
GH-48576: [C++][FlightRPC] ODBC: add Mac setup script (#48578)
### Rationale for this change #48576 ### What changes are included in this PR? - Added Mac Setup ODBC ini Script ### Are these changes tested? Script is tested in CI. Tested locally on macOS. ### Are there any user-facing changes? N/A * GitHub Issue: #48576 Lead-authored-by: Alina (Xi) Li <alinal@bitquilltech.com> Co-authored-by: Victor Tsang <victor.tsang@improving.com> Co-authored-by: Alina (Xi) Li <alina.li@improving.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 134638d commit e2aad46

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

.github/workflows/cpp_extra.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ jobs:
395395
export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR"
396396
export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR"
397397
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
398+
- name: Register Flight SQL ODBC Driver
399+
run: |
400+
sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh $(pwd)/build/cpp/debug/libarrow_flight_sql_odbc.dylib
398401
- name: Test
399402
shell: bash
400403
run: |

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ repos:
353353
?^cpp/build-support/update-thrift\.sh$|
354354
?^cpp/examples/minimal_build/run\.sh$|
355355
?^cpp/examples/tutorial_examples/run\.sh$|
356+
?^cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc\.sh$|
356357
?^dev/release/05-binary-upload\.sh$|
357358
?^dev/release/08-binary-verify\.sh$|
358359
?^dev/release/binary-recover\.sh$|
@@ -379,6 +380,7 @@ repos:
379380
files: >-
380381
(
381382
?^ci/scripts/python_test_type_annotations\.sh$|
383+
?^cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc\.sh$|
382384
?^dev/release/05-binary-upload\.sh$|
383385
?^dev/release/binary-recover\.sh$|
384386
?^dev/release/post-03-binary\.sh$|
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
# Used by macOS ODBC installer script `install_odbc_ini.sh` and macOS ODBC testing
21+
22+
set -euo pipefail
23+
24+
# Admin privilege is needed to add ODBC driver registration
25+
if [ $EUID -ne 0 ]; then
26+
echo "Please run this script with sudo"
27+
exit 1
28+
fi
29+
30+
ODBC_64BIT="$1"
31+
32+
if [[ -z "$ODBC_64BIT" ]]; then
33+
echo "error: 64-bit driver is not specified. Call format: install_odbc abs_path_to_64_bit_driver"
34+
exit 1
35+
fi
36+
37+
if [ ! -f "$ODBC_64BIT" ]; then
38+
echo "64-bit driver can not be found: $ODBC_64BIT"
39+
echo "Call format: install_odbc abs_path_to_64_bit_driver"
40+
exit 1
41+
fi
42+
43+
USER_ODBCINST_FILE="$HOME/Library/ODBC/odbcinst.ini"
44+
DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver"
45+
46+
mkdir -p "$HOME"/Library/ODBC
47+
48+
touch "$USER_ODBCINST_FILE"
49+
50+
if grep -q "^\[$DRIVER_NAME\]" "$USER_ODBCINST_FILE"; then
51+
echo "Driver [$DRIVER_NAME] already exists in odbcinst.ini"
52+
else
53+
echo "Adding [$DRIVER_NAME] to odbcinst.ini..."
54+
echo "
55+
[$DRIVER_NAME]
56+
Description=An ODBC Driver for Apache Arrow Flight SQL
57+
Driver=$ODBC_64BIT
58+
" >>"$USER_ODBCINST_FILE"
59+
fi
60+
61+
# Check if [ODBC Drivers] section exists
62+
if grep -q '^\[ODBC Drivers\]' "$USER_ODBCINST_FILE"; then
63+
# Section exists: check if driver entry exists
64+
if ! grep -q "^${DRIVER_NAME}=" "$USER_ODBCINST_FILE"; then
65+
# Driver entry does not exist, add under [ODBC Drivers]
66+
sed -i '' "/^\[ODBC Drivers\]/a\\
67+
${DRIVER_NAME}=Installed
68+
" "$USER_ODBCINST_FILE"
69+
fi
70+
else
71+
# Section doesn't exist, append both section and driver entry at end
72+
{
73+
echo ""
74+
echo "[ODBC Drivers]"
75+
echo "${DRIVER_NAME}=Installed"
76+
} >>"$USER_ODBCINST_FILE"
77+
fi

0 commit comments

Comments
 (0)