Skip to content

Commit 11721e7

Browse files
authored
GH-46914: [C++][FlightSQL] Remove boost/algorithm/string.h dependency (#50241)
### Rationale for this change Issue #46914 requests removing the remaining boost/algorithm/string.hpp dependency from FlightSQL. ### What changes are included in this PR? * Replace boost::iequals() with arrow::internal::AsciiEqualsCaseInsensitive() * Replace boost::istarts_with() with a local case-insensitive prefix helper * Remove boost/algorithm/string.hpp includes from sqlite_server.cc and test_app_cli.cc ### Are these changes tested? The modified files compile successfully in the local build configuration. CI will validate FlightSQL configurations. ### Are there any user-facing changes? No. * GitHub Issue: #46914 Authored-by: Aaditya Srinivasan <aadityasri03@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
1 parent f486053 commit 11721e7

2 files changed

Lines changed: 33 additions & 17 deletions

File tree

cpp/src/arrow/flight/sql/example/sqlite_server.cc

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
#include "arrow/flight/sql/example/sqlite_server.h"
1919

20-
#define BOOST_NO_CXX98_FUNCTION_BASE // ARROW-17805
21-
#include <boost/algorithm/string.hpp>
2220
#include <mutex>
2321
#include <random>
2422
#include <sstream>
@@ -37,6 +35,7 @@
3735
#include "arrow/scalar.h"
3836
#include "arrow/util/checked_cast.h"
3937
#include "arrow/util/logging.h"
38+
#include "arrow/util/string.h"
4039

4140
namespace arrow {
4241
namespace flight {
@@ -47,6 +46,11 @@ using arrow::internal::checked_cast;
4746

4847
namespace {
4948

49+
bool AsciiStartsWithCaseInsensitive(std::string_view value, std::string_view prefix) {
50+
return value.size() >= prefix.size() && arrow::internal::AsciiEqualsCaseInsensitive(
51+
value.substr(0, prefix.size()), prefix);
52+
}
53+
5054
std::string PrepareQueryForGetTables(const GetTables& command) {
5155
std::stringstream table_query;
5256

@@ -174,15 +178,17 @@ arrow::Result<std::shared_ptr<DataType>> GetArrowType(const char* sqlite_type) {
174178
return null();
175179
}
176180

177-
if (boost::iequals(sqlite_type, "int") || boost::iequals(sqlite_type, "integer")) {
181+
if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "int") ||
182+
arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "integer")) {
178183
return int64();
179-
} else if (boost::iequals(sqlite_type, "REAL")) {
184+
} else if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "REAL")) {
180185
return float64();
181-
} else if (boost::iequals(sqlite_type, "BLOB")) {
186+
} else if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "BLOB")) {
182187
return binary();
183-
} else if (boost::iequals(sqlite_type, "TEXT") || boost::iequals(sqlite_type, "DATE") ||
184-
boost::istarts_with(sqlite_type, "char") ||
185-
boost::istarts_with(sqlite_type, "varchar")) {
188+
} else if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "TEXT") ||
189+
arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "DATE") ||
190+
AsciiStartsWithCaseInsensitive(sqlite_type, "char") ||
191+
AsciiStartsWithCaseInsensitive(sqlite_type, "varchar")) {
186192
return utf8();
187193
}
188194
return Status::Invalid("Invalid SQLite type: ", sqlite_type);
@@ -194,15 +200,17 @@ int32_t GetSqlTypeFromTypeName(const char* sqlite_type) {
194200
return SQLITE_NULL;
195201
}
196202

197-
if (boost::iequals(sqlite_type, "int") || boost::iequals(sqlite_type, "integer")) {
203+
if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "int") ||
204+
arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "integer")) {
198205
return SQLITE_INTEGER;
199-
} else if (boost::iequals(sqlite_type, "REAL")) {
206+
} else if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "REAL")) {
200207
return SQLITE_FLOAT;
201-
} else if (boost::iequals(sqlite_type, "BLOB")) {
208+
} else if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "BLOB")) {
202209
return SQLITE_BLOB;
203-
} else if (boost::iequals(sqlite_type, "TEXT") || boost::iequals(sqlite_type, "DATE") ||
204-
boost::istarts_with(sqlite_type, "char") ||
205-
boost::istarts_with(sqlite_type, "varchar")) {
210+
} else if (arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "TEXT") ||
211+
arrow::internal::AsciiEqualsCaseInsensitive(sqlite_type, "DATE") ||
212+
AsciiStartsWithCaseInsensitive(sqlite_type, "char") ||
213+
AsciiStartsWithCaseInsensitive(sqlite_type, "varchar")) {
206214
return SQLITE_TEXT;
207215
} else {
208216
return SQLITE_NULL;

cpp/src/arrow/flight/sql/test_app_cli.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include "arrow/util/config.h"
1919

2020
#include <gflags/gflags.h>
21-
#define BOOST_NO_CXX98_FUNCTION_BASE // ARROW-17805
22-
#include <boost/algorithm/string.hpp>
2321
#include <iostream>
2422
#include <memory>
2523
#include <optional>
@@ -33,6 +31,7 @@
3331
#include "arrow/pretty_print.h"
3432
#include "arrow/status.h"
3533
#include "arrow/table.h"
34+
#include "arrow/util/string.h"
3635

3736
#ifdef ARROW_WITH_OPENTELEMETRY
3837
# include "arrow/flight/otel_logging.h"
@@ -75,6 +74,15 @@ DEFINE_string(catalog, "", "Catalog");
7574
DEFINE_string(schema, "", "Schema");
7675
DEFINE_string(table, "", "Table");
7776

77+
namespace {
78+
79+
bool AsciiStartsWithCaseInsensitive(std::string_view value, std::string_view prefix) {
80+
return value.size() >= prefix.size() && arrow::internal::AsciiEqualsCaseInsensitive(
81+
value.substr(0, prefix.size()), prefix);
82+
}
83+
84+
} // namespace
85+
7886
#ifdef ARROW_WITH_OPENTELEMETRY
7987
class OtelScope {
8088
public:
@@ -234,7 +242,7 @@ Status RunMain() {
234242
}
235243

236244
if (info != NULLPTR &&
237-
!boost::istarts_with(FLAGS_command, "PreparedStatementExecute")) {
245+
!AsciiStartsWithCaseInsensitive(FLAGS_command, "PreparedStatementExecute")) {
238246
return PrintResults(sql_client, call_options, info);
239247
}
240248

0 commit comments

Comments
 (0)