Skip to content

Commit 65ed2a0

Browse files
committed
merge conflict changes
1 parent 9270878 commit 65ed2a0

File tree

6 files changed

+37
-6
lines changed

6 files changed

+37
-6
lines changed

athena-snowflake/athena-snowflake.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Resources:
125125
Statement:
126126
- Action:
127127
- secretsmanager:GetSecretValue
128+
- secretsmanager:PutSecretValue
128129
Effect: Allow
129130
Resource: !Sub 'arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${SecretNamePrefix}*'
130131
- Action:

athena-snowflake/src/main/java/com/amazonaws/athena/connectors/snowflake/SnowflakeConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public final class SnowflakeConstants
4545
public static final String SNOWFLAKE_SPLIT_QUERY_ID = "query_id";
4646
public static final String SNOWFLAKE_SPLIT_EXPORT_BUCKET = "exportBucket";
4747
public static final String SNOWFLAKE_SPLIT_OBJECT_KEY = "s3ObjectKey";
48+
public static final String AUTH_CODE = "auth_code";
49+
public static final String CLIENT_ID = "client_id";
50+
public static final String TOKEN_URL = "token_url";
51+
public static final String REDIRECT_URI = "redirect_uri";
52+
public static final String CLIENT_SECRET = "client_secret";
4853

4954
private SnowflakeConstants() {}
5055
}

athena-snowflake/src/main/java/com/amazonaws/athena/connectors/snowflake/SnowflakeMetadataHandler.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.amazonaws.athena.connectors.snowflake;
2222

23+
import com.amazonaws.athena.connector.credentials.CredentialsProvider;
2324
import com.amazonaws.athena.connector.lambda.QueryStatusChecker;
2425
import com.amazonaws.athena.connector.lambda.data.Block;
2526
import com.amazonaws.athena.connector.lambda.data.BlockAllocator;
@@ -765,4 +766,15 @@ public String getRoleArn(Context context)
765766
throw new RuntimeException("Error fetching IAM role ARN: " + e.getMessage());
766767
}
767768
}
769+
770+
@Override
771+
protected CredentialsProvider getCredentialProvider()
772+
{
773+
final String secretName = getDatabaseConnectionConfig().getSecret();
774+
if (StringUtils.isNotBlank(secretName)) {
775+
return new SnowflakeCredentialsProvider(secretName);
776+
}
777+
778+
return null;
779+
}
768780
}

athena-snowflake/src/main/java/com/amazonaws/athena/connectors/snowflake/SnowflakeRecordHandler.java

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

22+
import com.amazonaws.athena.connector.credentials.CredentialsProvider;
2223
import com.amazonaws.athena.connector.lambda.QueryStatusChecker;
2324
import com.amazonaws.athena.connector.lambda.data.Block;
2425
import com.amazonaws.athena.connector.lambda.data.BlockSpiller;
@@ -80,6 +81,7 @@
8081
import software.amazon.awssdk.services.glue.model.FederationSourceErrorCode;
8182
import software.amazon.awssdk.services.s3.S3Client;
8283
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
84+
import software.amazon.awssdk.utils.StringUtils;
8385
import software.amazon.awssdk.utils.Validate;
8486

8587
import java.math.BigDecimal;
@@ -445,4 +447,15 @@ public PreparedStatement buildSplitSql(Connection jdbcConnection, String catalog
445447
}
446448
return preparedStatement;
447449
}
450+
451+
@Override
452+
protected CredentialsProvider getCredentialProvider()
453+
{
454+
final String secretName = getDatabaseConnectionConfig().getSecret();
455+
if (StringUtils.isNotBlank(secretName)) {
456+
return new SnowflakeCredentialsProvider(secretName);
457+
}
458+
459+
return null;
460+
}
448461
}

athena-snowflake/src/test/java/com/amazonaws/athena/connectors/snowflake/SnowflakeMetadataHandlerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public void getPartitions() throws Exception {
290290

291291
GetTableLayoutRequest req = new GetTableLayoutRequest(this.federatedIdentity, "queryId", "default",
292292
new TableName("schema1", "table1"),
293-
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT),
293+
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT, Map.of(), null),
294294
tableSchema,
295295
partitionCols);
296296

@@ -390,7 +390,7 @@ public void doGetSplits() throws Exception {
390390
new TableName("schema", "table_name"),
391391
partitions,
392392
partitionCols,
393-
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT),
393+
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT, Collections.emptyMap(), null),
394394
null);
395395
GetSplitsRequest req = new GetSplitsRequest(originalReq, null);
396396

@@ -549,7 +549,7 @@ public void testGetPartitionsForView() throws Exception {
549549

550550
GetTableLayoutRequest req = new GetTableLayoutRequest(this.federatedIdentity, "queryId", "default",
551551
new TableName("testSchema", "testView"),
552-
new Constraints(new HashMap<>(), Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT),
552+
new Constraints(new HashMap<>(), Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT, Collections.emptyMap(), null),
553553
tableSchema,
554554
partitionCols);
555555

athena-snowflake/src/test/java/com/amazonaws/athena/connectors/snowflake/SnowflakeRecordHandlerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class SnowflakeRecordHandlerTest
111111
{
112112
private static final Logger logger = LoggerFactory.getLogger(SnowflakeRecordHandlerTest.class);
113113
private SnowflakeRecordHandler handler;
114-
private FederatedIdentity identity = new FederatedIdentity("arn", "account", Collections.emptyMap(), Collections.emptyList());
114+
private FederatedIdentity identity = new FederatedIdentity("arn", "account", Collections.emptyMap(), Collections.emptyList(), Collections.emptyMap());
115115
private EncryptionKeyFactory keyFactory = new LocalKeyFactory();
116116
private Connection connection;
117117
private static final BufferAllocator bufferAllocator = new RootAllocator();
@@ -202,7 +202,7 @@ public void doReadRecordsNoSpill()
202202
TABLE_NAME,
203203
schemaRoot.getSchema(),
204204
splitBuilder.build(),
205-
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT),
205+
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT, Collections.emptyMap(), null),
206206
100_000_000_000L,
207207
100_000_000_000L//100GB don't expect this to spill
208208
);
@@ -263,7 +263,7 @@ public void doReadRecordsSpill()
263263
TABLE_NAME,
264264
schemaRoot.getSchema(),
265265
splitBuilder.build(),
266-
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT),
266+
new Constraints(constraintsMap, Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT, Collections.emptyMap(), null),
267267
1_500_000L, //~1.5MB so we should see some spill
268268
0L
269269
);

0 commit comments

Comments
 (0)