| 778 | } |
| 779 | |
| 780 | Status FlightSqlServerBase::DoPut(const ServerCallContext& context, |
| 781 | std::unique_ptr<FlightMessageReader> reader, |
| 782 | std::unique_ptr<FlightMetadataWriter> writer) { |
| 783 | const FlightDescriptor& request = reader->descriptor(); |
| 784 | |
| 785 | google::protobuf::Any any; |
| 786 | if (!any.ParseFromArray(request.cmd.data(), static_cast<int>(request.cmd.size()))) { |
| 787 | return Status::Invalid("Unable to parse command"); |
| 788 | } |
| 789 | |
| 790 | if (any.Is<pb::sql::CommandStatementUpdate>()) { |
| 791 | ARROW_ASSIGN_OR_RAISE(StatementUpdate internal_command, |
| 792 | ParseCommandStatementUpdate(any)); |
| 793 | ARROW_ASSIGN_OR_RAISE(auto record_count, |
| 794 | DoPutCommandStatementUpdate(context, internal_command)) |
| 795 | |
| 796 | pb::sql::DoPutUpdateResult result; |
| 797 | result.set_record_count(record_count); |
| 798 | |
| 799 | const auto buffer = Buffer::FromString(result.SerializeAsString()); |
| 800 | ARROW_RETURN_NOT_OK(writer->WriteMetadata(*buffer)); |
| 801 | |
| 802 | return Status::OK(); |
| 803 | } else if (any.Is<pb::sql::CommandStatementSubstraitPlan>()) { |
| 804 | ARROW_ASSIGN_OR_RAISE(StatementSubstraitPlan internal_command, |
| 805 | ParseCommandStatementSubstraitPlan(any)); |
| 806 | ARROW_ASSIGN_OR_RAISE(auto record_count, |
| 807 | DoPutCommandSubstraitPlan(context, internal_command)); |
| 808 | |
| 809 | pb::sql::DoPutUpdateResult result; |
| 810 | result.set_record_count(record_count); |
| 811 | |
| 812 | const auto buffer = Buffer::FromString(result.SerializeAsString()); |
| 813 | ARROW_RETURN_NOT_OK(writer->WriteMetadata(*buffer)); |
| 814 | return Status::OK(); |
| 815 | } else if (any.Is<pb::sql::CommandPreparedStatementQuery>()) { |
| 816 | ARROW_ASSIGN_OR_RAISE(PreparedStatementQuery internal_command, |
| 817 | ParseCommandPreparedStatementQuery(any)); |
| 818 | return DoPutPreparedStatementQuery(context, internal_command, reader.get(), |
| 819 | writer.get()); |
| 820 | } else if (any.Is<pb::sql::CommandPreparedStatementUpdate>()) { |
| 821 | ARROW_ASSIGN_OR_RAISE(PreparedStatementUpdate internal_command, |
| 822 | ParseCommandPreparedStatementUpdate(any)); |
| 823 | ARROW_ASSIGN_OR_RAISE( |
| 824 | auto record_count, |
| 825 | DoPutPreparedStatementUpdate(context, internal_command, reader.get())); |
| 826 | |
| 827 | pb::sql::DoPutUpdateResult result; |
| 828 | result.set_record_count(record_count); |
| 829 | |
| 830 | const auto buffer = Buffer::FromString(result.SerializeAsString()); |
| 831 | ARROW_RETURN_NOT_OK(writer->WriteMetadata(*buffer)); |
| 832 | return Status::OK(); |
| 833 | } else if (any.Is<pb::sql::CommandStatementIngest>()) { |
| 834 | ARROW_ASSIGN_OR_RAISE(StatementIngest internal_command, |
| 835 | ParseCommandStatementIngest(any)); |
| 836 | ARROW_ASSIGN_OR_RAISE( |
| 837 | auto record_count, |
no test coverage detected