Skip to content

Commit

Permalink
Address minor review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Jan 30, 2025
1 parent af69781 commit f01355a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions core/src/main/java/org/opensearch/sql/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ public class Analyzer extends AbstractNodeVisitor<LogicalPlan, AnalysisContext>

private final BuiltinFunctionRepository repository;

private static final String PATH_SEPARATOR = ".";

/** Constructor. */
public Analyzer(
ExpressionAnalyzer expressionAnalyzer,
Expand Down Expand Up @@ -459,7 +457,6 @@ public LogicalPlan visitEval(Eval node, AnalysisContext context) {
* Builds and returns a {@link org.opensearch.sql.planner.logical.LogicalFlatten} corresponding to
* the given flatten node.
*/
@SuppressWarnings("NonConstantStringShouldBeStringBuffer")
@Override
public LogicalPlan visitFlatten(Flatten node, AnalysisContext context) {
LogicalPlan child = node.getChild().getFirst().accept(this, context);
Expand Down Expand Up @@ -522,10 +519,11 @@ public LogicalPlan visitFlatten(Flatten node, AnalysisContext context) {
TypeEnvironment env = context.peek();
Map<String, ExprType> fieldsMap = env.lookupAllTupleFields(Namespace.FIELD_NAME);

final String fieldDescendantPath = fieldName + PATH_SEPARATOR;
final String pathSeparator = ".";
final String fieldDescendantPath = fieldName + pathSeparator;
final Optional<String> fieldParentPath =
fieldName.contains(PATH_SEPARATOR)
? Optional.of(fieldName.substring(0, fieldName.lastIndexOf(PATH_SEPARATOR)))
fieldName.contains(pathSeparator)
? Optional.of(fieldName.substring(0, fieldName.lastIndexOf(pathSeparator)))
: Optional.empty();

for (String path : fieldsMap.keySet()) {
Expand All @@ -538,7 +536,7 @@ public LogicalPlan visitFlatten(Flatten node, AnalysisContext context) {
// Build the new path.
String newPath = path.substring(fieldDescendantPath.length());
if (fieldParentPath.isPresent()) {
newPath = fieldParentPath.get() + PATH_SEPARATOR + newPath;
newPath = fieldParentPath.get() + pathSeparator + newPath;
}

ExprType type = fieldsMap.get(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void visitTrendline_should_build_TrendlineOperator() {
}

@Test
void visitFlatten_should_build_FlattenOperator() {
public void visitFlatten_should_build_FlattenOperator() {

// Mock physical and logical plan children.
var logicalChild = mock(LogicalPlan.class);
Expand Down

0 comments on commit f01355a

Please sign in to comment.