|
28 | 28 |
|
29 | 29 | namespace parquet::encryption { |
30 | 30 |
|
| 31 | +/// Extracting functionality common to both GetFileEncryptionProperties and |
| 32 | +/// GetExternalFileEncryptionProperties here for reuse. |
31 | 33 | namespace { |
32 | 34 |
|
| 35 | +// Struct to simplify the returned objects in GetFileKeyUtils. |
33 | 36 | struct FileKeyUtils { |
34 | 37 | std::shared_ptr<FileKeyMaterialStore> key_material_store; |
35 | 38 | FileKeyWrapper key_wrapper; |
@@ -63,7 +66,7 @@ int ValidateAndGetKeyLength(int32_t dek_length_bits) { |
63 | 66 | if (!internal::ValidateKeyLength(dek_length_bits)) { |
64 | 67 | std::ostringstream ss; |
65 | 68 | ss << "Wrong data key length : " << dek_length_bits; |
66 | | - throw ParquetException (ss.str()); |
| 69 | + throw ParquetException(ss.str()); |
67 | 70 | } |
68 | 71 | return dek_length_bits / 8; |
69 | 72 | } |
@@ -126,6 +129,9 @@ CryptoFactory::GetExternalFileEncryptionProperties( |
126 | 129 | const ExternalEncryptionConfiguration& external_encryption_config, |
127 | 130 | const std::string& file_path, const std::shared_ptr<::arrow::fs::FileSystem>& file_system) { |
128 | 131 | // Validate the same rules as FileEncryptionProperties but considering per_column_encryption too. |
| 132 | + // If uniform_encryption is not set then either column_keys or per_column_encryption must have |
| 133 | + // values. |
| 134 | + // If uniform_encryption is set, then both column_keys and per_column_encryption must be empty. |
129 | 135 | bool no_columns_encrypted = external_encryption_config.column_keys.empty() && |
130 | 136 | external_encryption_config.per_column_encryption.empty(); |
131 | 137 | if (!external_encryption_config.uniform_encryption && no_columns_encrypted) { |
@@ -167,10 +173,11 @@ CryptoFactory::GetExternalFileEncryptionProperties( |
167 | 173 | const std::string& column_name = pair.first; |
168 | 174 | const ColumnEncryptionAttributes& attributes = pair.second; |
169 | 175 |
|
170 | | - // Validate column names are not in both collumn_keys and per_column_encryption maps. |
| 176 | + // Validate column names are not in both column_keys and per_column_encryption maps. |
171 | 177 | if (encrypted_columns.find(column_name) != encrypted_columns.end()) { |
172 | 178 | std::stringstream string_stream; |
173 | | - string_stream << "Multiple keys defined for column [" << column_name << "] \n"; |
| 179 | + string_stream << "Multiple keys defined for column [" << column_name << "]. "; |
| 180 | + string_stream << "Keys found in column_keys and in per_column_encryption."; |
174 | 181 | throw ParquetException(string_stream.str()); |
175 | 182 | } |
176 | 183 |
|
|
0 commit comments