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

SNOW-0000: [APPS-53008] SnowflakeFileTransferAgent avoid query history clutter and enable test mocks #2100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/main/java/net/snowflake/client/core/StmtInternal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved.
*/

package net.snowflake.client.core;

import java.util.Map;
import net.snowflake.client.jdbc.SnowflakeSQLException;

// Consumed by Snowsight
@SnowflakeJdbcInternalApi
class StmtInternal extends SFStatement {

public StmtInternal(SFSession session) {
super(session);
}

@Override
public Object executeHelper(
String sql,
String mediaType,
Map<String, ParameterBindingDTO> bindValues,
boolean describeOnly,
boolean internal,
boolean asyncExec,
ExecTimeTelemetryData execTimeData)
throws SnowflakeSQLException, SFException {
return super.executeHelper(
sql, mediaType, bindValues, describeOnly, true, asyncExec, execTimeData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public class SnowflakeFileTransferAgent extends SFBaseFileTransferAgent {
private static final SFLogger logger =
SFLoggerFactory.getLogger(SnowflakeFileTransferAgent.class);

static final StorageClientFactory storageFactory = StorageClientFactory.getFactory();

private static final ObjectMapper mapper = ObjectMapperFactory.getObjectMapper();

// We will allow buffering of upto 128M data before spilling to disk during
Expand Down Expand Up @@ -898,7 +896,8 @@ public SnowflakeFileTransferAgent(String command, SFSession session, SFStatement
parseCommand();

if (stageInfo.getStageType() != StageInfo.StageType.LOCAL_FS) {
storageClient = storageFactory.createClient(stageInfo, parallel, null, session);
storageClient =
StorageClientFactory.getFactory().createClient(stageInfo, parallel, null, session);
}
}

Expand Down Expand Up @@ -1633,7 +1632,8 @@ private void uploadStream() throws SnowflakeSQLException {
fileMetadata,
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
? null
: storageFactory.createClient(stageInfo, parallel, encMat, session),
: StorageClientFactory.getFactory()
.createClient(stageInfo, parallel, encMat, session),
session,
command,
sourceStream,
Expand Down Expand Up @@ -1734,7 +1734,7 @@ public InputStream downloadStream(String fileName) throws SnowflakeSQLException
RemoteStoreFileEncryptionMaterial encMat = srcFileToEncMat.get(sourceLocation);
String presignedUrl = srcFileToPresignedUrl.get(sourceLocation);

return storageFactory
return StorageClientFactory.getFactory()
.createClient(stageInfo, parallel, encMat, session)
.downloadToStream(
session,
Expand Down Expand Up @@ -1778,7 +1778,8 @@ private void downloadFiles() throws SnowflakeSQLException {
fileMetadataMap,
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
? null
: storageFactory.createClient(stageInfo, parallel, encMat, session),
: StorageClientFactory.getFactory()
.createClient(stageInfo, parallel, encMat, session),
session,
command,
parallel,
Expand Down Expand Up @@ -1884,8 +1885,8 @@ private void uploadFiles(Set<String> fileList, int parallel) throws SnowflakeSQL
fileMetadata,
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
? null
: storageFactory.createClient(
stageInfo, parallel, encryptionMaterial.get(0), session),
: StorageClientFactory.getFactory()
.createClient(stageInfo, parallel, encryptionMaterial.get(0), session),
session,
command,
null,
Expand Down Expand Up @@ -2180,7 +2181,8 @@ private static void pushFileToRemoteStore(
(ArgSupplier)
() -> (encMat == null ? "NULL" : encMat.getSmkId() + "|" + encMat.getQueryId()));

StorageObjectMetadata meta = storageFactory.createStorageMetadataObj(stage.getStageType());
StorageObjectMetadata meta =
StorageClientFactory.getFactory().createStorageMetadataObj(stage.getStageType());
meta.setContentLength(uploadSize);
if (digest != null) {
initialClient.addDigestMetadata(meta, digest);
Expand Down Expand Up @@ -2318,7 +2320,7 @@ public static void uploadWithoutConnection(SnowflakeFileTransferConfig config) t
uploadSize);

SnowflakeStorageClient initialClient =
storageFactory.createClient(stageInfo, 1, encMat, /* session= */ null);
StorageClientFactory.getFactory().createClient(stageInfo, 1, encMat, /* session= */ null);

// Normal flow will never hit here. This is only for testing purposes
if (isInjectedFileTransferExceptionEnabled()) {
Expand Down Expand Up @@ -2434,7 +2436,8 @@ private static void pushFileToRemoteStoreWithPresignedUrl(
(ArgSupplier)
() -> (encMat == null ? "NULL" : encMat.getSmkId() + "|" + encMat.getQueryId()));

StorageObjectMetadata meta = storageFactory.createStorageMetadataObj(stage.getStageType());
StorageObjectMetadata meta =
StorageClientFactory.getFactory().createStorageMetadataObj(stage.getStageType());
meta.setContentLength(uploadSize);
if (digest != null) {
initialClient.addDigestMetadata(meta, digest);
Expand Down
Loading