Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
The filter used by Metadata-only queries should not have Unevaluable
  • Loading branch information
cxzl25 committed Apr 28, 2020
commit c34f030e634018d6c64171bfa9baa75de5ecabec
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ case class OptimizeMetadataOnlyQuery(catalog: SessionCatalog) extends Rule[Logic
}
}
Copy link
Member

@maropu maropu May 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you filter out this unsupported case outside replaceTableScanWithPartitionMetadata(I think this filtering is not related to normalization)? e.g., in https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/OptimizeMetadataOnlyQuery.scala#L53-L55


if (normalizedFilters.exists(_.find(_.isInstanceOf[Unevaluable]).isDefined)) {
return child
}

child transform {
case plan if plan eq relation =>
relation match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,30 @@ class OptimizeMetadataOnlyQuerySuite extends QueryTest with SharedSparkSession {
}
}
}

test("SPARK-31590 The filter used by Metadata-only queries should not have Unevaluable") {
withTable("test_tbl") {
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> "true") {
sql("CREATE TABLE test_tbl (a INT,d STRING,h STRING) USING PARQUET PARTITIONED BY (d ,h)")
sql("""
|INSERT OVERWRITE TABLE test_tbl PARTITION(d,h)
|SELECT 1,'2020-01-01','23'
|UNION ALL
|SELECT 2,'2020-01-02','01'
|UNION ALL
|SELECT 3,'2020-01-02','02'
""".stripMargin)
sql(
s"""
|SELECT d, MAX(h) AS h
|FROM test_tbl
|WHERE d= (
| SELECT MAX(d) AS d
| FROM test_tbl
|)
|GROUP BY d
""".stripMargin).collect()
}
}
}
}