Skip to content

Commit dcdb5ba

Browse files
authored
Fix SemanticCheckException not thrown (#5239)
Signed-off-by: Sunil Ramchandra Pawar <pawar_sr@apple.com>
1 parent b10d541 commit dcdb5ba

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

core/src/main/java/org/opensearch/sql/analysis/AnalysisContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ public TypeEnvironment pop() {
7171
environment = curEnv.getParent();
7272
return curEnv;
7373
}
74+
75+
/** Push a new isolated environment without parent access. */
76+
public void pushIsolated() {
77+
environment = new TypeEnvironment(null);
78+
}
7479
}

core/src/main/java/org/opensearch/sql/analysis/Analyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public LogicalPlan visitProject(Project node, AnalysisContext context) {
423423

424424
child = processNestedAnalysis(node.getProjectList(), namedExpressions, child, context);
425425

426-
context.push();
426+
context.pushIsolated();
427427
TypeEnvironment newEnv = context.peek();
428428
namedExpressions.forEach(
429429
expr ->

core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
import java.util.Optional;
7373
import org.apache.commons.lang3.tuple.ImmutablePair;
7474
import org.apache.commons.lang3.tuple.Pair;
75-
import org.junit.jupiter.api.Disabled;
7675
import org.junit.jupiter.api.Test;
7776
import org.opensearch.sql.ast.dsl.AstDSL;
7877
import org.opensearch.sql.ast.expression.Argument;
@@ -898,9 +897,6 @@ public void remove_source() {
898897
AstDSL.field("double_value")));
899898
}
900899

901-
@Disabled(
902-
"the project/remove command should shrink the type env. Should be enabled once "
903-
+ "https://github.com/opensearch-project/sql/issues/917 is resolved")
904900
@Test
905901
public void project_source_change_type_env() {
906902
SemanticCheckException exception =

0 commit comments

Comments
 (0)