Skip to content

Commit 8ef7474

Browse files
Jithendar12Trianz-Akshayburhan94
authored
Added unit tests for athena-cloudera-impala Connector (#2880)
Co-authored-by: akshay.kachore <[email protected]> Co-authored-by: burhan94 <[email protected]>
1 parent 6248677 commit 8ef7474

File tree

6 files changed

+1008
-138
lines changed

6 files changed

+1008
-138
lines changed

athena-cloudera-impala/src/test/java/com/amazonaws/athena/connectors/cloudera/ImpalaEnvironmentPropertiesTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,27 @@
3232
import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.SECRET_NAME;
3333
import static org.junit.Assert.assertEquals;
3434

35-
public class ImpalaEnvironmentPropertiesTest {
35+
public class ImpalaEnvironmentPropertiesTest
36+
{
3637
Map<String, String> connectionProperties;
3738
ImpalaEnvironmentProperties impalaEnvironmentProperties;
3839

3940
@Before
40-
public void setUp() {
41+
public void setUp()
42+
{
4143
connectionProperties = new HashMap<>();
42-
connectionProperties.put(HOST, "50.100.00.10");
44+
connectionProperties.put(HOST, "localhost");
4345
connectionProperties.put(DATABASE, "default");
4446
connectionProperties.put(SECRET_NAME, "testSecret");
4547
connectionProperties.put(PORT, "49172");
4648
impalaEnvironmentProperties = new ImpalaEnvironmentProperties();
4749
}
4850

4951
@Test
50-
public void impalaConnectionPropertiesTest() {
51-
52+
public void testImpalaConnectionProperties()
53+
{
5254
Map<String, String> impalaConnectionProperties = impalaEnvironmentProperties.connectionPropertiesToEnvironment(connectionProperties);
53-
54-
String expectedConnectionString = "impala://jdbc:impala://50.100.00.10:49172/default;${testSecret}";
55+
String expectedConnectionString = "impala://jdbc:impala://localhost:49172/default;${testSecret}";
5556
assertEquals(expectedConnectionString, impalaConnectionProperties.get(DEFAULT));
5657
}
57-
}
58+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*-
2+
* #%L
3+
* athena-cloudera-impala
4+
* %%
5+
* Copyright (C) 2019 - 2025 Amazon Web Services
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.amazonaws.athena.connectors.cloudera;
21+
22+
import org.apache.arrow.vector.types.pojo.ArrowType;
23+
import org.junit.Test;
24+
25+
import java.util.Arrays;
26+
import java.util.Collections;
27+
28+
import static org.junit.Assert.assertEquals;
29+
30+
public class ImpalaFederationExpressionParserTest
31+
{
32+
private static final String IMPALA_QUOTE_CHARACTER = "`";
33+
private final ImpalaFederationExpressionParser parser = new ImpalaFederationExpressionParser(IMPALA_QUOTE_CHARACTER);
34+
35+
@Test
36+
public void testWriteArrayConstructorClause_withMultipleElements()
37+
{
38+
String result = parser.writeArrayConstructorClause(
39+
new ArrowType.Int(32, true),
40+
Arrays.asList("1", "2", "3")
41+
);
42+
assertEquals("1, 2, 3", result);
43+
}
44+
45+
@Test
46+
public void testWriteArrayConstructorClause_withSingleElement()
47+
{
48+
String result = parser.writeArrayConstructorClause(
49+
new ArrowType.Utf8(),
50+
Collections.singletonList("'test'")
51+
);
52+
assertEquals("'test'", result);
53+
}
54+
55+
@Test
56+
public void testWriteArrayConstructorClause_withEmptyList()
57+
{
58+
String result = parser.writeArrayConstructorClause(
59+
new ArrowType.Bool(),
60+
Collections.emptyList()
61+
);
62+
assertEquals("", result);
63+
}
64+
}

athena-cloudera-impala/src/test/java/com/amazonaws/athena/connectors/cloudera/ImpalaJdbcConnectionFactoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

0 commit comments

Comments
 (0)