huaxingao commented on a change in pull request #3757:
URL: https://github.com/apache/iceberg/pull/3757#discussion_r769967500
##########
File path:
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/procedures/RewriteDataFilesProcedure.java
##########
@@ -109,19 +110,23 @@ public StructType outputType() {
}
String where = args.isNullAt(4) ? null : args.getString(4);
- action = checkAndApplyFilter(action, where);
+ action = checkAndApplyFilter(action, where, table.name());
RewriteDataFiles.Result result = action.execute();
return toOutputRows(result);
});
}
- private RewriteDataFiles checkAndApplyFilter(RewriteDataFiles action, String
where) {
+ private RewriteDataFiles checkAndApplyFilter(RewriteDataFiles action, String
where, String tableName) {
if (where != null) {
+ // Add a dummy prefix linking to the table to collect the resolved spark
expression from analyzed plan.
+ String prefix = String.format("SELECT count(*) from %s where ",
tableName);
ParserInterface sqlParser = spark().sessionState().sqlParser();
try {
- Expression expression = sqlParser.parseExpression(where);
+ LogicalPlan logicalPlan = sqlParser.parsePlan(prefix + where);
+ Expression expression =
SparkExpressionConverter.collectSparkExpression(
+ Dataset.ofRows(spark(), logicalPlan).queryExecution().analyzed());
Review comment:
Instead of calling
```
Dataset.ofRows(spark(), logicalPlan).queryExecution().analyzed()
```
we might want to directly call
```
spark().sessionState().executePlan(logicalPlan,
CommandExecutionMode.ALL()).analyzed()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]