Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom query fix #1428

Merged
merged 60 commits into from
Nov 21, 2023
Merged

Custom query fix #1428

merged 60 commits into from
Nov 21, 2023

Conversation

mhavey
Copy link
Contributor

@mhavey mhavey commented Aug 22, 2023

Issue #, if available:

#1398

Description of changes:
Add RDF support to Neptune connector. This builds on recent changes for property graph views in Neptune connector.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

private static NeptuneConnection createConnection(java.util.Map<String, String> configOptions)
{
GraphType graphType = GraphType.PROPERTYGRAPH;
if (System.getenv("neptune_graphtype") != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use configOptions.getEnv here. We dump System.getEnv to configOptions when the RecordHandler is instantiated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

switch(graphType){
case PROPERTYGRAPH:
return new NeptuneGremlinConnection(configOptions.get("neptune_endpoint"),
configOptions.get("neptune_port"), Boolean.parseBoolean(configOptions.get("iam_enabled")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make static variables for these properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

break;

case VIEW:
String query = recordsRequest.getSchema().getCustomMetadata().get("query");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add static variable here pls. Maybe its worth creating a class for constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

this.connectionString = "https://" + neptuneEndpoint + ":" + neptunePort;
}

public void connect() throws NeptuneSigV4SignerException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need a separate connect() class? why not include this as a part of the constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connect now from constructor

@@ -29,7 +29,8 @@
</Appenders>
<Loggers>
<Logger name="com.amazonaws.athena.connector.lambda" level="${env:ATHENA_FEDERATION_SDK_LOG_LEVEL:-warn}" />
<Logger name="com.amazonaws.athena.connectors.neptune" level="${env:ATHENA_FEDERATION_SDK_LOG_LEVEL:-warn}" />
<Logger name="com.amazonaws.athena.connectors.neptune" level="warn" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert the changes and keep as: level="${env:ATHENA_FEDERATION_SDK_LOG_LEVEL:-warn}

This is used for customer debugging so that log levels can be configured via lambda env variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

String pfx = k.substring(PREFIX_LEN);
String val = recordsRequest.getSchema().getCustomMetadata().get(k);
prefixMap.put(pfx, val);
prefixBlock += "PREFIX " + pfx + ": <" + val + ">\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a stringbuilder for readability or string.format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now using string builder

{
ArrowType arrowType = field.getType();
Types.MinorType minorType = Types.getMinorTypeForArrowType(arrowType);
Boolean enableCaseinsensitivematch = (System.getenv("enable_caseinsensitivematch") == null) ? true : Boolean.parseBoolean(System.getenv("enable_caseinsensitivematch"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to use configOptions here. Using System.getEnv within the connectors isn't recommended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

}

// 2. Build the SPARQL query
String queryMode = recordsRequest.getSchema().getCustomMetadata().get("querymode");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls use constants for all of these. Its hard to determine where they're coming from without prior context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@mhavey
Copy link
Contributor Author

mhavey commented Oct 9, 2023

Made code changes to address review comments

@chngpe
Copy link
Contributor

chngpe commented Nov 15, 2023

build failure
Error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project athena-neptune: Compilation failure Error: /home/runner/work/aws-athena-query-federation/aws-athena-query-federation/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/PropertyGraphHandler.java:[30,67] package com.amazonaws.athena.connectors.neptune.propertygraph.Enums does not exist

@mhavey mhavey requested a review from burhan94 November 16, 2023 16:40

<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like some merge headers got added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed merge headers

@burhan94 burhan94 merged commit b765e3b into awslabs:master Nov 21, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants