-
Notifications
You must be signed in to change notification settings - Fork 181
Add option to use LakeFormation in S3Glue data source. #2624
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,52 @@ void testDispatchSelectQuery() { | |
| verifyNoInteractions(flintIndexMetadataService); | ||
| } | ||
|
|
||
| @Test | ||
| void testDispatchSelectQueryWithLakeFormation() { | ||
| HashMap<String, String> tags = new HashMap<>(); | ||
| tags.put(DATASOURCE_TAG_KEY, "my_glue"); | ||
| tags.put(CLUSTER_NAME_TAG_KEY, TEST_CLUSTER_NAME); | ||
| tags.put(JOB_TYPE_TAG_KEY, JobType.BATCH.getText()); | ||
| String query = "select * from my_glue.default.http_logs"; | ||
| String sparkSubmitParameters = | ||
| constructExpectedSparkSubmitParameterString( | ||
| "sigv4", | ||
| new HashMap<>() { | ||
| { | ||
| put(FLINT_INDEX_STORE_AWSREGION_KEY, "eu-west-1"); | ||
| } | ||
| }, | ||
| query, | ||
| true); | ||
| StartJobRequest expected = | ||
| new StartJobRequest( | ||
| "TEST_CLUSTER:batch", | ||
| EMRS_APPLICATION_ID, | ||
| EMRS_EXECUTION_ROLE, | ||
| sparkSubmitParameters, | ||
| tags, | ||
| false, | ||
| "query_execution_result_my_glue"); | ||
| when(emrServerlessClient.startJobRun(expected)).thenReturn(EMR_JOB_ID); | ||
| DataSourceMetadata dataSourceMetadata = constructMyGlueDataSourceMetadataWithLakeFormation(); | ||
| when(dataSourceService.verifyDataSourceAccessAndGetRawMetadata("my_glue")) | ||
| .thenReturn(dataSourceMetadata); | ||
|
|
||
| DispatchQueryResponse dispatchQueryResponse = | ||
| sparkQueryDispatcher.dispatch( | ||
| new DispatchQueryRequest( | ||
| EMRS_APPLICATION_ID, | ||
| query, | ||
| "my_glue", | ||
| LangType.SQL, | ||
| EMRS_EXECUTION_ROLE, | ||
| TEST_CLUSTER_NAME)); | ||
| verify(emrServerlessClient, times(1)).startJobRun(startJobRequestArgumentCaptor.capture()); | ||
| Assertions.assertEquals(expected, startJobRequestArgumentCaptor.getValue()); | ||
| Assertions.assertEquals(EMR_JOB_ID, dispatchQueryResponse.getJobId()); | ||
| verifyNoInteractions(flintIndexMetadataService); | ||
| } | ||
|
|
||
| @Test | ||
| void testDispatchSelectQueryWithBasicAuthIndexStoreDatasource() { | ||
| HashMap<String, String> tags = new HashMap<>(); | ||
|
|
@@ -936,13 +982,17 @@ void testDispatchQueryWithExtraSparkSubmitParameters() { | |
|
|
||
| private String constructExpectedSparkSubmitParameterString( | ||
| String auth, Map<String, String> authParams, String query) { | ||
| return constructExpectedSparkSubmitParameterString(auth, authParams, query, false); | ||
| } | ||
|
|
||
| private String constructExpectedSparkSubmitParameterString( | ||
| String auth, Map<String, String> authParams, String query, boolean lakeFormationEnabled) { | ||
| StringBuilder authParamConfigBuilder = new StringBuilder(); | ||
| for (String key : authParams.keySet()) { | ||
| authParamConfigBuilder.append(" --conf "); | ||
| authParamConfigBuilder.append(" --conf "); | ||
| authParamConfigBuilder.append(key); | ||
| authParamConfigBuilder.append("="); | ||
| authParamConfigBuilder.append(authParams.get(key)); | ||
| authParamConfigBuilder.append(" "); | ||
| } | ||
| query = "\"" + query + "\""; | ||
| return " --class org.apache.spark.sql.FlintJob --conf" | ||
|
|
@@ -978,9 +1028,13 @@ private String constructExpectedSparkSubmitParameterString( | |
| + " --conf" | ||
| + " spark.hive.metastore.glue.role.arn=arn:aws:iam::924196221507:role/FlintOpensearchServiceRole" | ||
| + " --conf spark.sql.catalog.my_glue=org.opensearch.sql.FlintDelegatingSessionCatalog " | ||
| + " --conf spark.flint.datasource.name=my_glue " | ||
| + " --conf spark.flint.datasource.name=my_glue --conf" | ||
| + " spark.emr-serverless.lakeformation.enabled=" | ||
| + Boolean.toString(lakeFormationEnabled) | ||
| + " --conf spark.flint.optimizer.covering.enabled=" | ||
| + Boolean.toString(!lakeFormationEnabled) | ||
| + authParamConfigBuilder | ||
| + " --conf spark.flint.job.query=" | ||
| + " --conf spark.flint.job.query=" | ||
| + query | ||
| + " "; | ||
| } | ||
|
|
@@ -1056,6 +1110,25 @@ private DataSourceMetadata constructMyGlueDataSourceMetadataWithBadURISyntax() { | |
| .build(); | ||
| } | ||
|
|
||
| private DataSourceMetadata constructMyGlueDataSourceMetadataWithLakeFormation() { | ||
|
|
||
| Map<String, String> properties = new HashMap<>(); | ||
| properties.put("glue.auth.type", "iam_role"); | ||
| properties.put( | ||
| "glue.auth.role_arn", "arn:aws:iam::924196221507:role/FlintOpensearchServiceRole"); | ||
| properties.put( | ||
| "glue.indexstore.opensearch.uri", | ||
| "https://search-flint-dp-benchmark-cf5crj5mj2kfzvgwdeynkxnefy.eu-west-1.es.amazonaws.com"); | ||
|
Comment on lines
+1117
to
+1121
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume these account and domain info are internal? Can we replace with fake one for test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like these values are used for all tests. I can update as part of a follow-up PR. |
||
| properties.put("glue.indexstore.opensearch.auth", "awssigv4"); | ||
| properties.put("glue.indexstore.opensearch.region", "eu-west-1"); | ||
| properties.put("glue.lakeformation.enabled", "true"); | ||
| return new DataSourceMetadata.Builder() | ||
| .setName("my_glue") | ||
| .setConnector(DataSourceType.S3GLUE) | ||
| .setProperties(properties) | ||
| .build(); | ||
| } | ||
|
|
||
| private DataSourceMetadata constructPrometheusDataSourceType() { | ||
| return new DataSourceMetadata.Builder() | ||
| .setName("my_prometheus") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.