| 1129 | } // namespace |
| 1130 | |
| 1131 | Result<std::unique_ptr<substrait::Expression::Literal>> ToProto( |
| 1132 | const Datum& datum, ExtensionSet* ext_set, |
| 1133 | const ConversionOptions& conversion_options) { |
| 1134 | if (!datum.is_scalar()) { |
| 1135 | return Status::NotImplemented("representing ", datum.ToString(), |
| 1136 | " as a substrait::Expression::Literal"); |
| 1137 | } |
| 1138 | |
| 1139 | auto out = std::make_unique<substrait::Expression::Literal>(); |
| 1140 | |
| 1141 | if (datum.scalar()->is_valid) { |
| 1142 | RETURN_NOT_OK( |
| 1143 | (ScalarToProtoImpl{out.get(), ext_set, conversion_options})(*datum.scalar())); |
| 1144 | } else { |
| 1145 | ARROW_ASSIGN_OR_RAISE(auto type, ToProto(*datum.type(), /*nullable=*/true, ext_set, |
| 1146 | conversion_options)); |
| 1147 | out->set_allocated_null(type.release()); |
| 1148 | } |
| 1149 | |
| 1150 | return out; |
| 1151 | } |
| 1152 | |
| 1153 | namespace { |
| 1154 |
no test coverage detected