-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into encode-catalog-name-in-flint-index-name
Signed-off-by: Chen Dai <[email protected]>
- Loading branch information
Showing
105 changed files
with
10,334 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
integ-test/src/test/scala/org/opensearch/flint/spark/LogicalPlanTestUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.spark | ||
|
||
import org.apache.spark.sql.catalyst.expressions.{Alias, ExprId} | ||
import org.apache.spark.sql.catalyst.plans.logical.{Aggregate, LogicalPlan, Project} | ||
|
||
/** | ||
* general utility functions for ppl to spark transformation test | ||
*/ | ||
trait LogicalPlanTestUtils { | ||
|
||
/** | ||
* utility function to compare two logical plans while ignoring the auto-generated expressionId | ||
* associated with the alias which is used for projection or aggregation | ||
* @param plan | ||
* @return | ||
*/ | ||
def compareByString(plan: LogicalPlan): String = { | ||
// Create a rule to replace Alias's ExprId with a dummy id | ||
val rule: PartialFunction[LogicalPlan, LogicalPlan] = { | ||
case p: Project => | ||
val newProjections = p.projectList.map { | ||
case alias: Alias => | ||
Alias(alias.child, alias.name)(exprId = ExprId(0), qualifier = alias.qualifier) | ||
case other => other | ||
} | ||
p.copy(projectList = newProjections) | ||
|
||
case agg: Aggregate => | ||
val newGrouping = agg.groupingExpressions.map { | ||
case alias: Alias => | ||
Alias(alias.child, alias.name)(exprId = ExprId(0), qualifier = alias.qualifier) | ||
case other => other | ||
} | ||
val newAggregations = agg.aggregateExpressions.map { | ||
case alias: Alias => | ||
Alias(alias.child, alias.name)(exprId = ExprId(0), qualifier = alias.qualifier) | ||
case other => other | ||
} | ||
agg.copy(groupingExpressions = newGrouping, aggregateExpressions = newAggregations) | ||
|
||
case other => other | ||
} | ||
|
||
// Apply the rule using transform | ||
val transformedPlan = plan.transform(rule) | ||
|
||
// Return the string representation of the transformed plan | ||
transformedPlan.toString | ||
} | ||
|
||
} |
Oops, something went wrong.