Apache spark 读取时是否忽略Spark中已排序文件的拼花地板摘要文件(_元数据)?
我有一个具有不同列和id的已排序数据集。该数据集已排序(也使用拼花工具进行验证): 例如:Apache spark 读取时是否忽略Spark中已排序文件的拼花地板摘要文件(_元数据)?,apache-spark,hadoop,parquet,Apache Spark,Hadoop,Parquet,我有一个具有不同列和id的已排序数据集。该数据集已排序(也使用拼花工具进行验证): 例如: file 1: ID 1-10 file 2: ID 10-12 file 3: ID 12-33 .... 我还生成并编写了_元数据和_common_元数据文件。我尝试使用过滤器查询(非常大的)数据集 val mydata=spark.read.parquet("s3a://.../mylocation") val result = mydata.filter(mydata("id") === 11)
file 1: ID 1-10
file 2: ID 10-12
file 3: ID 12-33
....
我还生成并编写了_元数据和_common_元数据文件。我尝试使用过滤器查询(非常大的)数据集
val mydata=spark.read.parquet("s3a://.../mylocation")
val result = mydata.filter(mydata("id") === 11)
result.explain(true)
解释告诉我:
== Parsed Logical Plan ==
Filter (id#14L = 11)
+- Relation[fieldA#12, fieldB#13,id#14L] parquet
== Analyzed Logical Plan ==
fieldA: int, fieldB: string, id: bigint
Filter (id#14L = 11)
+- Relation[fieldA#12, fieldB#13,id#14L] parquet
== Optimized Logical Plan ==
Filter (isnotnull(id#14L) && (id#14L = 11))
+- Relation[fieldA#12, fieldB#13,id#14L] parquet
== Physical Plan ==
*(1) Project [fieldA#12, fieldB#13,id#14L]
+- *(1) Filter (isnotnull(id#14L) && (id#14L = 11))
+- *(1) FileScan parquet [fieldA#12,fieldB#13,id#14L] Batched: true, Format: Parquet, Location: InMemoryFileIndex[s3a://mybucket/path/to/data], PartitionFilters: [], PushedFilters: [IsNotNull(id), EqualTo(id,11)], ReadSchema: struct<fieldA:int,fieldB:string,id:bigint>
拼花地板摘要文件被认为实际上是无用的,对它们的写支持在年被禁用。JIRA中提到的推理表明,摘要文件仅用于读取模式,而不是用于过滤的其他元数据,如min/max stats。我无法确认这是否真的是这样,但这里有一段摘录自该推理: 拼花地板摘要文件现在不是特别有用,因为
如果ID查询是对您的频繁操作,您可以考虑通过ID对表进行分区,以避免不必要地读取文件。
谢谢您的答复,我将把问题标记为已解决。即使按ID划分也不是我的解决方案spark.conf.set("parquet.summary.metadata.level","ALL")
spark.conf.set("parquet.filter.statistics.enabled","true")
spark.conf.set("parquet.filter.dictionary.enabled","true")
spark.conf.set("spark.sql.parquet.filterPushdown","true")
spark.conf.set("spark.sql.hive.convertMetastoreParquet","true")
spark.conf.set("spark.sql.parquet.respectSummaryFiles","true")
spark.conf.set("spark.sql.parquet.mergeSchema","false")
spark.conf.set("spark.sql.hive.convertMetastoreParquet.mergeSchema","false")
spark.conf.set("spark.sql.optimizer.metadataOnly", "true")