From 028c183396e263634afee98600cb90cefcef9812 Mon Sep 17 00:00:00 2001 From: currantw Date: Thu, 30 Jan 2025 10:03:30 -0800 Subject: [PATCH] Minor cleanup. Signed-off-by: currantw --- core/src/main/java/org/opensearch/sql/analysis/Analyzer.java | 4 ++-- .../org/opensearch/sql/planner/physical/FlattenOperator.java | 4 +--- .../opensearch/sql/planner/logical/LogicalFlattenTest.java | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/opensearch/sql/analysis/Analyzer.java b/core/src/main/java/org/opensearch/sql/analysis/Analyzer.java index 355eb265eb..3719d95c30 100644 --- a/core/src/main/java/org/opensearch/sql/analysis/Analyzer.java +++ b/core/src/main/java/org/opensearch/sql/analysis/Analyzer.java @@ -482,8 +482,8 @@ public LogicalPlan visitFlatten(Flatten node, AnalysisContext context) { if (fieldType != STRUCT) { String msg = StringUtils.format( - "Invalid field type '%s' for flatten command. Supported field types: '%s'.", - fieldType, STRUCT.typeName()); + "Invalid field type for flatten command. Expected '%s' but got '%s'.", + STRUCT.typeName(), fieldType); throw new IllegalArgumentException(msg); } diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/FlattenOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/FlattenOperator.java index d3ff7c9739..c5bd7530ac 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/FlattenOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/FlattenOperator.java @@ -28,9 +28,7 @@ public class FlattenOperator extends PhysicalPlan { private final PhysicalPlan input; private final ReferenceExpression field; - private static final String PATH_SEPARATOR = "."; - private static final Pattern PATH_SEPARATOR_PATTERN = - Pattern.compile(PATH_SEPARATOR, Pattern.LITERAL); + private static final Pattern PATH_SEPARATOR_PATTERN = Pattern.compile(".", Pattern.LITERAL); @Override public R accept(PhysicalPlanNodeVisitor visitor, C context) { diff --git a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalFlattenTest.java b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalFlattenTest.java index 03e587e79d..068091388f 100644 --- a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalFlattenTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalFlattenTest.java @@ -124,8 +124,7 @@ void testInvalidType() { assertThrows(IllegalArgumentException.class, () -> analyze(actualUnresolvedPlan)) .getMessage(); assertEquals( - "Invalid field type 'INTEGER' for flatten command. Supported field types: 'STRUCT'.", - actualMsg); + "Invalid field type for flatten command. Expected 'STRUCT' but got 'INTEGER'.", actualMsg); } @Test