Skip to content

Commit

Permalink
Closes #33 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
prmoore77 authored Apr 2, 2024
1 parent 5326758 commit 666b728
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pandas==2.1.*
duckdb==0.10.1
click==8.1.*
pyarrow==15.0.2
adbc-driver-flightsql==0.10.*
adbc-driver-manager==0.10.*
adbc-driver-flightsql==0.11.*
adbc-driver-manager==0.11.*
10 changes: 7 additions & 3 deletions src/library/flight_sql_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <csignal>
#include <iostream>
#include <filesystem>
#include <regex>
#include <vector>
#include <arrow/flight/client.h>
#include <arrow/flight/sql/server.h>
Expand All @@ -26,12 +27,15 @@ const int port = 31337;
#define RUN_INIT_COMMANDS(serverType, init_sql_commands) \
do { \
if (init_sql_commands != "") { \
std::vector<std::string> tokens; \
boost::split(tokens, init_sql_commands, boost::is_any_of(";")); \
for (const std::string &init_sql_command: tokens) { \
std::regex regex_pattern(";(?=(?:[^']*'[^']*')*[^']*$)"); \
std::sregex_token_iterator iter(init_sql_commands.begin(), init_sql_commands.end(), regex_pattern, -1); \
std::sregex_token_iterator end; \
while (iter != end) { \
std::string init_sql_command = *iter; \
if (init_sql_command.empty()) continue; \
std::cout << "Running Init SQL command: " << std::endl << init_sql_command << ";" << std::endl; \
ARROW_RETURN_NOT_OK(serverType->ExecuteSql(init_sql_command)); \
++iter; \
} \
} \
} while (false)
Expand Down

0 comments on commit 666b728

Please sign in to comment.