Skip to content

Commit 9e8b151

Browse files
VenkatasivareddyTRTrianz-Akshay
authored andcommitted
Addressed review comments for neptune qpt.
1 parent 3793b24 commit 9e8b151

File tree

4 files changed

+350
-45
lines changed

4 files changed

+350
-45
lines changed

athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/NeptuneMetadataHandler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ public GetDataSourceCapabilitiesResponse doGetDataSourceCapabilities(BlockAlloca
136136

137137
return new GetDataSourceCapabilitiesResponse(request.getCatalogName(), capabilities.build());
138138
}
139-
139+
140140
/**
141141
* Since the entire Neptune cluster is considered as a single graph database,
142142
* just return the glue database name provided as a single database (schema)
143143
* name.
144-
*
144+
*
145145
* @param allocator Tool for creating and managing Apache Arrow Blocks.
146146
* @param request Provides details on who made the request and which Athena
147147
* catalog they are querying.
@@ -163,7 +163,7 @@ public ListSchemasResponse doListSchemaNames(BlockAllocator allocator, ListSchem
163163
/**
164164
* Used to get the list of tables that this data source contains. In this case,
165165
* fetch list of tables in the Glue database provided.
166-
*
166+
*
167167
* @param allocator Tool for creating and managing Apache Arrow Blocks.
168168
* @param request Provides details on who made the request and which Athena
169169
* catalog and database they are querying.
@@ -214,10 +214,10 @@ public GetTableResponse doGetTable(BlockAllocator blockAllocator, GetTableReques
214214
Schema tableSchema = null;
215215
try {
216216
if (glue != null) {
217-
tableSchema = super.doGetTable(blockAllocator, request).getSchema();
217+
tableSchema = super.doGetTable(blockAllocator, request).getSchema();
218218
logger.info("doGetTable: Retrieved schema for table[{}] from AWS Glue.", request.getTableName());
219219
}
220-
}
220+
}
221221
catch (RuntimeException ex) {
222222
logger.warn("doGetTable: Unable to retrieve table[{}:{}] from AWS Glue.",
223223
request.getTableName().getSchemaName(), request.getTableName().getTableName(), ex);
@@ -231,7 +231,7 @@ public GetTableResponse doGetTable(BlockAllocator blockAllocator, GetTableReques
231231
*/
232232
@Override
233233
public void getPartitions(BlockWriter blockWriter, GetTableLayoutRequest request,
234-
QueryStatusChecker queryStatusChecker) throws Exception
234+
QueryStatusChecker queryStatusChecker) throws Exception
235235
{
236236
// No implemenation as connector doesn't support partitioning
237237
}
@@ -260,7 +260,7 @@ public void getPartitions(BlockWriter blockWriter, GetTableLayoutRequest request
260260
* the RecordHandler has easy access to it.
261261
*/
262262
@Override
263-
public GetSplitsResponse doGetSplits(BlockAllocator blockAllocator, GetSplitsRequest request)
263+
public GetSplitsResponse doGetSplits(BlockAllocator blockAllocator, GetSplitsRequest request)
264264
{
265265
// Every split must have a unique location if we wish to spill to avoid failures
266266
SpillLocation spillLocation = makeSpillLocation(request);
@@ -271,7 +271,7 @@ public GetSplitsResponse doGetSplits(BlockAllocator blockAllocator, GetSplitsReq
271271
}
272272

273273
@Override
274-
protected Field convertField(String name, String glueType)
274+
protected Field convertField(String name, String glueType)
275275
{
276276
return GlueFieldLexer.lex(name, glueType);
277277
}
@@ -313,7 +313,7 @@ public GetTableResponse doGetQueryPassthroughSchema(BlockAllocator allocator, Ge
313313
GraphTraversal graphTraversalForSchema = (GraphTraversal) object;
314314
if (graphTraversalForSchema.hasNext()) {
315315
Object responseObj = graphTraversalForSchema.next();
316-
if (responseObj instanceof Map && gremlinQuery.contains(Constants.GREMLIN_QUERY_SUPPORT_TYPE)) {
316+
if (responseObj instanceof Map) {
317317
logger.info("NeptuneMetadataHandler doGetQueryPassthroughSchema gremlinQuery with valueMap");
318318
Map graphTraversalObj = (Map) responseObj;
319319
schema = NeptuneSchemaUtils.getSchemaFromResults(graphTraversalObj, componentTypeValue, tableName);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package com.amazonaws.athena.connectors.neptune.qpt;
2121

2222
import com.amazonaws.athena.connector.lambda.metadata.optimizations.querypassthrough.QueryPassthroughSignature;
23+
import com.amazonaws.athena.connectors.neptune.Constants;
2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
2526

@@ -81,5 +82,10 @@ public void customConnectorVerifications(Map<String, String> engineQptArguments)
8182
if (engineQptArguments.containsKey(QUERY)) {
8283
throw new IllegalArgumentException("Mixed operations not supported: Cannot use both SPARQL query and Gremlin traverse in the same request");
8384
}
85+
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. " +
87+
"Please make sure you are using valueMap gremlin query. " +
88+
"Example for valueMap query is g.V().hasLabel(\\\"airport\\\").valueMap().limit(5)");
89+
}
8490
}
8591
}

0 commit comments

Comments
 (0)