| 711 | } |
| 712 | |
| 713 | Result<std::shared_ptr<FileWriter>> ParquetFileFormat::MakeWriter( |
| 714 | std::shared_ptr<io::OutputStream> destination, std::shared_ptr<Schema> schema, |
| 715 | std::shared_ptr<FileWriteOptions> options, |
| 716 | fs::FileLocator destination_locator) const { |
| 717 | if (!Equals(*options->format())) { |
| 718 | return Status::TypeError("Mismatching format/write options"); |
| 719 | } |
| 720 | |
| 721 | auto parquet_options = checked_pointer_cast<ParquetFileWriteOptions>(options); |
| 722 | |
| 723 | std::unique_ptr<parquet::arrow::FileWriter> parquet_writer; |
| 724 | |
| 725 | #ifdef PARQUET_REQUIRE_ENCRYPTION |
| 726 | auto parquet_encrypt_config = parquet_options->parquet_encryption_config; |
| 727 | |
| 728 | if (parquet_encrypt_config != nullptr) { |
| 729 | auto file_encryption_prop = |
| 730 | parquet_encrypt_config->crypto_factory->GetFileEncryptionProperties( |
| 731 | *parquet_encrypt_config->kms_connection_config, |
| 732 | *parquet_encrypt_config->encryption_config, destination_locator.path, |
| 733 | destination_locator.filesystem); |
| 734 | |
| 735 | auto writer_properties = |
| 736 | parquet::WriterProperties::Builder(*parquet_options->writer_properties) |
| 737 | .encryption(std::move(file_encryption_prop)) |
| 738 | ->build(); |
| 739 | |
| 740 | ARROW_ASSIGN_OR_RAISE( |
| 741 | parquet_writer, parquet::arrow::FileWriter::Open( |
| 742 | *schema, writer_properties->memory_pool(), destination, |
| 743 | writer_properties, parquet_options->arrow_writer_properties)); |
| 744 | } |
| 745 | #else |
| 746 | if (parquet_options->parquet_encryption_config != nullptr) { |
| 747 | return Status::NotImplemented("Encryption is not supported in this build."); |
| 748 | } |
| 749 | #endif |
| 750 | |
| 751 | if (parquet_writer == nullptr) { |
| 752 | ARROW_ASSIGN_OR_RAISE(parquet_writer, |
| 753 | parquet::arrow::FileWriter::Open( |
| 754 | *schema, parquet_options->writer_properties->memory_pool(), |
| 755 | destination, parquet_options->writer_properties, |
| 756 | parquet_options->arrow_writer_properties)); |
| 757 | } |
| 758 | |
| 759 | return std::shared_ptr<FileWriter>( |
| 760 | new ParquetFileWriter(std::move(destination), std::move(parquet_writer), |
| 761 | std::move(parquet_options), std::move(destination_locator))); |
| 762 | } |
| 763 | |
| 764 | ParquetFileWriter::ParquetFileWriter(std::shared_ptr<io::OutputStream> destination, |
| 765 | std::shared_ptr<parquet::arrow::FileWriter> writer, |
nothing calls this directly
no test coverage detected