MCPcopy Create free account
hub / github.com/apache/arrow / LoadInfoFromServer

Method LoadInfoFromServer

cpp/src/arrow/flight/sql/odbc/odbc_impl/get_info_cache.cc:286–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286bool GetInfoCache::LoadInfoFromServer() {
287 if (sql_client_ && !has_server_info_.exchange(true)) {
288 std::unique_lock<std::mutex> lock(mutex_);
289 arrow::Result<std::shared_ptr<FlightInfo>> result =
290 sql_client_->GetSqlInfo(call_options_, {});
291 util::ThrowIfNotOK(result.status());
292 FlightStreamChunkBuffer chunk_iter(*sql_client_, client_options_, call_options_,
293 result.ValueOrDie());
294
295 FlightStreamChunk chunk;
296 bool supports_correlation_name = false;
297 bool requires_different_correlation_name = false;
298 bool transactions_supported = false;
299 bool transaction_ddl_commit = false;
300 bool transaction_ddl_ignore = false;
301 while (chunk_iter.GetNext(&chunk)) {
302 auto name_array = chunk.data->GetColumnByName("info_name");
303 auto value_array = chunk.data->GetColumnByName("value");
304
305 UInt32Array* info_type_array = static_cast<UInt32Array*>(name_array.get());
306 UnionArray* value_union_array = static_cast<UnionArray*>(value_array.get());
307 for (int64_t i = 0; i < chunk.data->num_rows(); ++i) {
308 if (!value_array->IsNull(i)) {
309 auto info_type =
310 static_cast<SqlInfoOptions::SqlInfo>(info_type_array->Value(i));
311 auto result_scalar = value_union_array->GetScalar(i);
312 util::ThrowIfNotOK(result_scalar.status());
313 std::shared_ptr<Scalar> scalar_ptr = result_scalar.ValueOrDie();
314 UnionScalar* scalar = reinterpret_cast<UnionScalar*>(scalar_ptr.get());
315 switch (info_type) {
316 // String properties
317 case SqlInfoOptions::FLIGHT_SQL_SERVER_NAME: {
318 std::string server_name(
319 reinterpret_cast<StringScalar*>(scalar->child_value().get())->view());
320
321 // GH-47855 TODO: Consider creating different properties in GetSqlInfo.
322 // GH-47856 TODO: Investigate if SQL_SERVER_NAME should just be the host
323 // address as well. In JDBC, FLIGHT_SQL_SERVER_NAME is only used for
324 // the DatabaseProductName.
325 info_[SQL_SERVER_NAME] = server_name;
326 info_[SQL_DBMS_NAME] = server_name;
327 info_[SQL_DATABASE_NAME] =
328 server_name; // This is usually the current catalog. May need to
329 // throw HYC00 instead.
330 break;
331 }
332 case SqlInfoOptions::FLIGHT_SQL_SERVER_VERSION: {
333 info_[SQL_DBMS_VER] = util::ConvertToDBMSVer(std::string(
334 reinterpret_cast<StringScalar*>(scalar->child_value().get())->view()));
335 break;
336 }
337 case SqlInfoOptions::FLIGHT_SQL_SERVER_ARROW_VERSION: {
338 // Unused.
339 break;
340 }
341 case SqlInfoOptions::SQL_SEARCH_STRING_ESCAPE: {
342 info_[SQL_SEARCH_PATTERN_ESCAPE] = std::string(
343 reinterpret_cast<StringScalar*>(scalar->child_value().get())->view());

Callers

nothing calls this directly

Calls 15

ThrowIfNotOKFunction · 0.85
ConvertToDBMSVerFunction · 0.85
ScalarToBoolStringFunction · 0.85
ScalarToInt64Function · 0.85
ScalarToInt32Function · 0.85
ReportNumericFunctionFunction · 0.85
ReportStringFunctionFunction · 0.85
ReportSystemFunctionFunction · 0.85
ReportDatetimeFunctionFunction · 0.85
GetSqlInfoMethod · 0.80

Tested by

no test coverage detected