-
Notifications
You must be signed in to change notification settings - Fork 3k
Spark 4.1: Simplify description and toString in scans #15281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -153,6 +153,10 @@ protected List<Expression> filterExpressions() { | |||||||||
| return filterExpressions; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| protected String filtersDesc() { | ||||||||||
| return Spark3Util.describe(filterExpressions); | ||||||||||
|
||||||||||
| return Spark3Util.describe(filterExpressions); | |
| return filterExpressions.stream() | |
| .map(Expression::toString) | |
| .collect(Collectors.joining(" AND ")); |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,6 +67,7 @@ | |||||||||
| import org.apache.spark.sql.connector.expressions.filter.Or; | ||||||||||
| import org.apache.spark.sql.connector.expressions.filter.Predicate; | ||||||||||
| import org.apache.spark.sql.connector.read.Batch; | ||||||||||
| import org.apache.spark.sql.connector.read.Scan; | ||||||||||
| import org.apache.spark.sql.connector.read.ScanBuilder; | ||||||||||
| import org.apache.spark.sql.connector.read.Statistics; | ||||||||||
| import org.apache.spark.sql.connector.read.SupportsPushDownV2Filters; | ||||||||||
|
|
@@ -1022,6 +1023,50 @@ public void testPartitionedOr() throws Exception { | |||||||||
| assertThat(scan.planInputPartitions()).hasSize(4); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @TestTemplate | ||||||||||
| public void testBatchQueryScanDescription() throws Exception { | ||||||||||
| createPartitionedTable(spark, tableName, "data"); | ||||||||||
| SparkScanBuilder builder = scanBuilder(); | ||||||||||
|
|
||||||||||
| withSQLConf( | ||||||||||
| ImmutableMap.of(SparkSQLProperties.PRESERVE_DATA_GROUPING, "true"), | ||||||||||
| () -> { | ||||||||||
| Predicate predicate1 = new Predicate("=", expressions(fieldRef("id"), intLit(1))); | ||||||||||
| Predicate predicate2 = new Predicate(">", expressions(fieldRef("id"), intLit(0))); | ||||||||||
| pushFilters(builder, predicate1, predicate2); | ||||||||||
|
|
||||||||||
| Scan scan = builder.build(); | ||||||||||
| String description = scan.description(); | ||||||||||
|
|
||||||||||
| assertThat(description).contains("IcebergScan"); | ||||||||||
| assertThat(description).contains(tableName); | ||||||||||
| assertThat(description).contains("filters=id = 1, id > 0"); | ||||||||||
| assertThat(description).contains("groupedBy=data"); | ||||||||||
|
Comment on lines
+1041
to
+1044
|
||||||||||
| }); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @TestTemplate | ||||||||||
| public void testCopyOnWriteScanDescription() throws Exception { | ||||||||||
| createPartitionedTable(spark, tableName, "data"); | ||||||||||
| SparkScanBuilder builder = scanBuilder(); | ||||||||||
|
|
||||||||||
| withSQLConf( | ||||||||||
| ImmutableMap.of(SparkSQLProperties.PRESERVE_DATA_GROUPING, "true"), | ||||||||||
| () -> { | ||||||||||
| Predicate predicate1 = new Predicate("=", expressions(fieldRef("id"), intLit(2))); | ||||||||||
| Predicate predicate2 = new Predicate("<", expressions(fieldRef("id"), intLit(10))); | ||||||||||
| pushFilters(builder, predicate1, predicate2); | ||||||||||
|
|
||||||||||
| Scan scan = builder.buildCopyOnWriteScan(); | ||||||||||
| String description = scan.description(); | ||||||||||
|
|
||||||||||
| assertThat(description).contains("IcebergCopyOnWriteScan"); | ||||||||||
| assertThat(description).contains(tableName); | ||||||||||
| assertThat(description).contains("filters=id = 2, id < 10"); | ||||||||||
|
||||||||||
| assertThat(description).contains("filters=id = 2, id < 10"); | |
| assertThat(description).contains("filters="); | |
| assertThat(description).contains("id = 2"); | |
| assertThat(description).contains("id < 10"); |
Uh oh!
There was an error while loading. Please reload this page.