Skip to content

Commit de2d6d3

Browse files
committed
fix build issue
1 parent 9e8b151 commit de2d6d3

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/qpt/NeptuneGremlinQueryPassthrough.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
*/
2020
package com.amazonaws.athena.connectors.neptune.qpt;
2121

22+
import com.amazonaws.athena.connector.lambda.exceptions.AthenaConnectorException;
2223
import com.amazonaws.athena.connector.lambda.metadata.optimizations.querypassthrough.QueryPassthroughSignature;
2324
import com.amazonaws.athena.connectors.neptune.Constants;
2425
import org.slf4j.Logger;
2526
import org.slf4j.LoggerFactory;
27+
import software.amazon.awssdk.services.glue.model.ErrorDetails;
28+
import software.amazon.awssdk.services.glue.model.FederationSourceErrorCode;
2629

2730
import java.util.Arrays;
2831
import java.util.List;
@@ -80,12 +83,12 @@ public void customConnectorVerifications(Map<String, String> engineQptArguments)
8083
{
8184
// Verify no mixed operations (SPARQL and Gremlin in same request)
8285
if (engineQptArguments.containsKey(QUERY)) {
83-
throw new IllegalArgumentException("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request");
86+
throw new AthenaConnectorException("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request", ErrorDetails.builder().errorCode(FederationSourceErrorCode.INVALID_INPUT_EXCEPTION.toString()).build());
8487
}
8588
else if (!engineQptArguments.get(TRAVERSE).contains(Constants.GREMLIN_QUERY_SUPPORT_TYPE)) {
86-
throw new IllegalArgumentException("Unsupported gremlin query format: We are currently supporting only valueMap gremlin queries. " +
89+
throw new AthenaConnectorException("Unsupported gremlin query format: We are currently supporting only valueMap gremlin queries. " +
8790
"Please make sure you are using valueMap gremlin query. " +
88-
"Example for valueMap query is g.V().hasLabel(\\\"airport\\\").valueMap().limit(5)");
91+
"Example for valueMap query is g.V().hasLabel(\\\"airport\\\").valueMap().limit(5)", ErrorDetails.builder().errorCode(FederationSourceErrorCode.INVALID_INPUT_EXCEPTION.toString()).build());
8992
}
9093
}
9194
}

athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/qpt/NeptuneSparqlQueryPassthrough.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
*/
2020
package com.amazonaws.athena.connectors.neptune.qpt;
2121

22+
import com.amazonaws.athena.connector.lambda.exceptions.AthenaConnectorException;
2223
import com.amazonaws.athena.connector.lambda.metadata.optimizations.querypassthrough.QueryPassthroughSignature;
2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
26+
import software.amazon.awssdk.services.glue.model.ErrorDetails;
27+
import software.amazon.awssdk.services.glue.model.FederationSourceErrorCode;
2528

2629
import java.util.Arrays;
2730
import java.util.List;
@@ -78,7 +81,7 @@ public void customConnectorVerifications(Map<String, String> engineQptArguments)
7881
{
7982
// Verify no mixed operations (SPARQL and Gremlin in same request)
8083
if (engineQptArguments.containsKey(TRAVERSE)) {
81-
throw new IllegalArgumentException("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request");
84+
throw new AthenaConnectorException("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request", ErrorDetails.builder().errorCode(FederationSourceErrorCode.INVALID_INPUT_EXCEPTION.toString()).build());
8285
}
8386
}
8487
}

athena-neptune/src/test/java/com/amazonaws/athena/connectors/neptune/qpt/NeptuneGremlinQueryPassthroughTest.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package com.amazonaws.athena.connectors.neptune.qpt;
2121

22+
import com.amazonaws.athena.connector.lambda.exceptions.AthenaConnectorException;
2223
import org.junit.Before;
2324
import org.junit.Test;
2425
import org.junit.runner.RunWith;
@@ -75,8 +76,8 @@ public void testVerifyWithValidArguments() {
7576
public void testVerifyWithEmptyArguments() {
7677
try {
7778
queryPassthrough.verify(new HashMap<>());
78-
fail("Expected IllegalArgumentException");
79-
} catch (IllegalArgumentException e) {
79+
fail("Expected AthenaConnectorException");
80+
} catch (AthenaConnectorException e) {
8081
assertEquals("Function Signature doesn't match implementation's", e.getMessage());
8182
}
8283
}
@@ -87,8 +88,8 @@ public void testVerifyWithMissingDatabase() {
8788

8889
try {
8990
queryPassthrough.verify(baseArguments);
90-
fail("Expected IllegalArgumentException");
91-
} catch (IllegalArgumentException e) {
91+
fail("Expected AthenaConnectorException");
92+
} catch (AthenaConnectorException e) {
9293
assertEquals("Missing Query Passthrough Argument: " + DATABASE, e.getMessage());
9394
}
9495
}
@@ -99,8 +100,8 @@ public void testVerifyWithMissingCollection() {
99100

100101
try {
101102
queryPassthrough.verify(baseArguments);
102-
fail("Expected IllegalArgumentException");
103-
} catch (IllegalArgumentException e) {
103+
fail("Expected AthenaConnectorException");
104+
} catch (AthenaConnectorException e) {
104105
assertEquals("Missing Query Passthrough Argument: " + COLLECTION, e.getMessage());
105106
}
106107
}
@@ -111,8 +112,8 @@ public void testVerifyWithMissingComponentType() {
111112

112113
try {
113114
queryPassthrough.verify(baseArguments);
114-
fail("Expected IllegalArgumentException");
115-
} catch (IllegalArgumentException e) {
115+
fail("Expected AthenaConnectorException");
116+
} catch (AthenaConnectorException e) {
116117
assertEquals("Missing Query Passthrough Argument: " + COMPONENT_TYPE, e.getMessage());
117118
}
118119
}
@@ -123,8 +124,8 @@ public void testVerifyWithMissingTraverse() {
123124

124125
try {
125126
queryPassthrough.verify(baseArguments);
126-
fail("Expected IllegalArgumentException");
127-
} catch (IllegalArgumentException e) {
127+
fail("Expected AthenaConnectorException");
128+
} catch (AthenaConnectorException e) {
128129
assertEquals("Missing Query Passthrough Argument: " + TRAVERSE, e.getMessage());
129130
}
130131
}
@@ -135,8 +136,8 @@ public void testVerifyWithTraverseAndQueryArguments_ShouldThrowException() {
135136

136137
try {
137138
queryPassthrough.verify(baseArguments);
138-
fail("Expected IllegalArgumentException");
139-
} catch (IllegalArgumentException e) {
139+
fail("Expected AthenaConnectorException");
140+
} catch (AthenaConnectorException e) {
140141
assertEquals("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request", e.getMessage());
141142
}
142143
}
@@ -147,8 +148,8 @@ public void testVerifyWithInvalidTraverseSyntax_ShouldThrowException() {
147148

148149
try {
149150
queryPassthrough.verify(baseArguments);
150-
fail("Expected IllegalArgumentException");
151-
} catch (IllegalArgumentException e) {
151+
fail("Expected AthenaConnectorException");
152+
} catch (AthenaConnectorException e) {
152153
assertEquals("Unsupported gremlin query format: We are currently supporting only valueMap gremlin queries. " +
153154
"Please make sure you are using valueMap gremlin query. " +
154155
"Example for valueMap query is g.V().hasLabel(\\\"airport\\\").valueMap().limit(5)", e.getMessage());

athena-neptune/src/test/java/com/amazonaws/athena/connectors/neptune/qpt/NeptuneSparqlQueryPassthroughTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package com.amazonaws.athena.connectors.neptune.qpt;
2121

22+
import com.amazonaws.athena.connector.lambda.exceptions.AthenaConnectorException;
2223
import org.junit.Before;
2324
import org.junit.Test;
2425
import org.junit.runner.RunWith;
@@ -72,8 +73,8 @@ public void testVerifyWithValidArguments() {
7273
public void testVerifyWithEmptyArguments() {
7374
try {
7475
queryPassthrough.verify(new HashMap<>());
75-
fail("Expected IllegalArgumentException");
76-
} catch (IllegalArgumentException e) {
76+
fail("Expected AthenaConnectorException");
77+
} catch (AthenaConnectorException e) {
7778
assertEquals("Function Signature doesn't match implementation's", e.getMessage());
7879
}
7980
}
@@ -84,8 +85,8 @@ public void testVerifyWithMissingDatabase() {
8485

8586
try {
8687
queryPassthrough.verify(baseArguments);
87-
fail("Expected IllegalArgumentException");
88-
} catch (IllegalArgumentException e) {
88+
fail("Expected AthenaConnectorException");
89+
} catch (AthenaConnectorException e) {
8990
assertEquals("Missing Query Passthrough Argument: " + DATABASE, e.getMessage());
9091
}
9192
}
@@ -96,8 +97,8 @@ public void testVerifyWithMissingCollection() {
9697

9798
try {
9899
queryPassthrough.verify(baseArguments);
99-
fail("Expected IllegalArgumentException");
100-
} catch (IllegalArgumentException e) {
100+
fail("Expected AthenaConnectorException");
101+
} catch (AthenaConnectorException e) {
101102
assertEquals("Missing Query Passthrough Argument: " + COLLECTION, e.getMessage());
102103
}
103104
}
@@ -108,8 +109,8 @@ public void testVerifyWithMissingQuery() {
108109

109110
try {
110111
queryPassthrough.verify(baseArguments);
111-
fail("Expected IllegalArgumentException");
112-
} catch (IllegalArgumentException e) {
112+
fail("Expected AthenaConnectorException");
113+
} catch (AthenaConnectorException e) {
113114
assertEquals("Missing Query Passthrough Argument: " + QUERY, e.getMessage());
114115
}
115116
}
@@ -120,8 +121,8 @@ public void testVerifyWithTraverseAndQueryArguments_ShouldThrowException() {
120121

121122
try {
122123
queryPassthrough.verify(baseArguments);
123-
fail("Expected IllegalArgumentException");
124-
} catch (IllegalArgumentException e) {
124+
fail("Expected AthenaConnectorException");
125+
} catch (AthenaConnectorException e) {
125126
assertEquals("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request", e.getMessage());
126127
}
127128
}

0 commit comments

Comments
 (0)