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

Method DoGetSqlInfo

cpp/src/arrow/flight/sql/server.cc:1064–1101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062}
1063
1064arrow::Result<std::unique_ptr<FlightDataStream>> FlightSqlServerBase::DoGetSqlInfo(
1065 const ServerCallContext& context, const GetSqlInfo& command) {
1066 MemoryPool* memory_pool = default_memory_pool();
1067 UInt32Builder name_field_builder(memory_pool);
1068 std::unique_ptr<ArrayBuilder> value_field_builder;
1069 const auto& value_field_type = checked_pointer_cast<DenseUnionType>(
1070 SqlSchema::GetSqlInfoSchema()->fields()[1]->type());
1071 ARROW_RETURN_NOT_OK(MakeBuilder(memory_pool, value_field_type, &value_field_builder));
1072
1073 internal::SqlInfoResultAppender sql_info_result_appender(
1074 checked_cast<DenseUnionBuilder*>(value_field_builder.get()));
1075
1076 // Populate both name_field_builder and value_field_builder for each element
1077 // on command.info.
1078 // value_field_builder is populated differently depending on the data type (as it is
1079 // a DenseUnionBuilder). The population for each data type is implemented on
1080 // internal::SqlInfoResultAppender.
1081 for (const auto& info : command.info) {
1082 const auto it = sql_info_id_to_result_.find(info);
1083 if (it == sql_info_id_to_result_.end()) {
1084 return Status::KeyError("No information for SQL info number ", info);
1085 }
1086 ARROW_RETURN_NOT_OK(name_field_builder.Append(info));
1087 ARROW_RETURN_NOT_OK(std::visit(sql_info_result_appender, it->second));
1088 }
1089
1090 std::shared_ptr<Array> name;
1091 ARROW_RETURN_NOT_OK(name_field_builder.Finish(&name));
1092 std::shared_ptr<Array> value;
1093 ARROW_RETURN_NOT_OK(value_field_builder->Finish(&value));
1094
1095 auto row_count = static_cast<int64_t>(command.info.size());
1096 const std::shared_ptr<RecordBatch>& batch =
1097 RecordBatch::Make(SqlSchema::GetSqlInfoSchema(), row_count, {name, value});
1098 ARROW_ASSIGN_OR_RAISE(const auto reader, RecordBatchReader::Make({batch}));
1099
1100 return std::make_unique<RecordBatchStream>(reader);
1101}
1102
1103arrow::Result<std::unique_ptr<FlightInfo>> FlightSqlServerBase::GetFlightInfoSchemas(
1104 const ServerCallContext& context, const GetDbSchemas& command,

Callers

nothing calls this directly

Calls 12

default_memory_poolFunction · 0.85
KeyErrorFunction · 0.85
MakeBuilderFunction · 0.50
MakeFunction · 0.50
typeMethod · 0.45
fieldsMethod · 0.45
getMethod · 0.45
findMethod · 0.45
endMethod · 0.45
AppendMethod · 0.45
FinishMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected