19
19
import static com .amazon .opendistroforelasticsearch .sql .ast .dsl .AstDSL .aggregate ;
20
20
import static com .amazon .opendistroforelasticsearch .sql .ast .dsl .AstDSL .qualifiedName ;
21
21
import static com .amazon .opendistroforelasticsearch .sql .sql .antlr .parser .OpenDistroSQLParser .IdentContext ;
22
- import static com .amazon .opendistroforelasticsearch .sql .sql .antlr .parser .OpenDistroSQLParser .KeywordsAsQualifiedNameContext ;
22
+ import static com .amazon .opendistroforelasticsearch .sql .sql .antlr .parser .OpenDistroSQLParser .QualifiedNameContext ;
23
23
import static org .junit .jupiter .api .Assertions .assertEquals ;
24
24
import static org .mockito .ArgumentMatchers .any ;
25
25
import static org .mockito .Mockito .mock ;
26
26
import static org .mockito .Mockito .when ;
27
27
28
28
import com .amazon .opendistroforelasticsearch .sql .ast .expression .UnresolvedExpression ;
29
- import com .amazon .opendistroforelasticsearch .sql .sql .antlr .parser .OpenDistroSQLParser .IdentsAsQualifiedNameContext ;
30
- import com .amazon .opendistroforelasticsearch .sql .sql .antlr .parser .OpenDistroSQLParser .KeywordsCanBeIdContext ;
31
29
import com .amazon .opendistroforelasticsearch .sql .sql .parser .context .QuerySpecification ;
32
30
import com .google .common .collect .ImmutableList ;
33
31
import org .junit .jupiter .api .BeforeEach ;
@@ -54,28 +52,14 @@ void setup() {
54
52
55
53
@ Test
56
54
void should_replace_alias_with_select_expression () {
57
- IdentsAsQualifiedNameContext qualifiedName = mock (IdentsAsQualifiedNameContext .class );
55
+ QualifiedNameContext qualifiedName = mock (QualifiedNameContext .class );
58
56
IdentContext identifier = mock (IdentContext .class );
59
57
UnresolvedExpression expression = aggregate ("AVG" , qualifiedName ("age" ));
60
58
61
59
when (identifier .getText ()).thenReturn ("a" );
62
60
when (qualifiedName .ident ()).thenReturn (ImmutableList .of (identifier ));
63
61
when (querySpec .isSelectAlias (any ())).thenReturn (true );
64
62
when (querySpec .getSelectItemByAlias (any ())).thenReturn (expression );
65
- assertEquals (expression , builder .visitIdentsAsQualifiedName (qualifiedName ));
63
+ assertEquals (expression , builder .visitQualifiedName (qualifiedName ));
66
64
}
67
-
68
- @ Test
69
- void should_replace_keyword_alias_with_select_expression () {
70
- KeywordsAsQualifiedNameContext qualifiedName = mock (KeywordsAsQualifiedNameContext .class );
71
- KeywordsCanBeIdContext keyword = mock (KeywordsCanBeIdContext .class );
72
- UnresolvedExpression expression = aggregate ("AVG" , qualifiedName ("age" ));
73
-
74
- when (keyword .getText ()).thenReturn ("a" );
75
- when (qualifiedName .keywordsCanBeId ()).thenReturn (keyword );
76
- when (querySpec .isSelectAlias (any ())).thenReturn (true );
77
- when (querySpec .getSelectItemByAlias (any ())).thenReturn (expression );
78
- assertEquals (expression , builder .visitKeywordsAsQualifiedName (qualifiedName ));
79
- }
80
-
81
65
}
0 commit comments