Som*_*hal 1 java encryption hadoop apache-spark spark3
我将 Spark 数据集保存为本地计算机中的 parquet 文件。我想知道是否有任何方法可以使用某种加密算法来加密数据。我用来将数据保存为镶木地板文件的代码看起来像这样。
dataset.write().mode("overwrite").parquet(parquetFile);
我看到了类似的问题,但当我写入本地磁盘时,我的查询有所不同。
从 Spark 3.2 开始,Parquet 表支持列式加密。
例如:
hadoopConfiguration.set("parquet.encryption.kms.client.class" ,
"org.apache.parquet.crypto.keytools.mocks.InMemoryKMS");
// Explicit master keys (base64 encoded) - required only for mock InMemoryKMS
hadoopConfiguration.set("parquet.encryption.key.list" ,
"keyA:AAECAwQFBgcICQoLDA0ODw== , keyB:AAECAAECAAECAAECAAECAA==");
// Activate Parquet encryption, driven by Hadoop properties
hadoopConfiguration.set("parquet.crypto.factory.class" ,
"org.apache.parquet.crypto.keytools.PropertiesDrivenCryptoFactory");
// Write encrypted dataframe files.
// Column "square" will be protected with master key "keyA".
// Parquet file footers will be protected with master key "keyB"
squaresDF.write().
option("parquet.encryption.column.keys" , "keyA:square").
option("parquet.encryption.footer.key" , "keyB").
parquet("/path/to/table.parquet.encrypted");
// Read encrypted dataframe files
Dataset<Row> df2 = spark.read().parquet("/path/to/table.parquet.encrypted");
Run Code Online (Sandbox Code Playgroud)
这基于以下使用示例: https: //spark.apache.org/docs/3.2.0/sql-data-sources-parquet.html#columnar-encryption
归档时间: |
|
查看次数: |
2006 次 |
最近记录: |