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

Method LoadInfoFromServer

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

ThrowIfNotOKFunction · 0.85
ConvertToDBMSVerFunction · 0.85
ScalarToBoolStringFunction · 0.85
SetDefaultIfMissingFunction · 0.85
ScalarToInt64Function · 0.85
ScalarToInt32Function · 0.85
ReportNumericFunctionFunction · 0.85
ReportStringFunctionFunction · 0.85
ReportSystemFunctionFunction · 0.85
ReportDatetimeFunctionFunction · 0.85

Tested by

no test coverage detected