public class SnowflakeFileTransferAgent extends SFBaseFileTransferAgent
Modifier and Type | Class and Description |
---|---|
class |
SnowflakeFileTransferAgent.DownloadCommandEncryptionFacade |
class |
SnowflakeFileTransferAgent.DownloadCommandFacade
A class for encapsulating the columns to return for the download command
|
static class |
SnowflakeFileTransferAgent.ResultStatus
Result status enum
|
static class |
SnowflakeFileTransferAgent.UploadColumns
A class for encapsulating the columns to return for the upload command
|
class |
SnowflakeFileTransferAgent.UploadCommandEncryptionFacade |
class |
SnowflakeFileTransferAgent.UploadCommandFacade |
SFBaseFileTransferAgent.CommandType
Modifier and Type | Field and Description |
---|---|
static String |
SRC_FILE_NAME_FOR_STREAM |
commandType, compressSourceFromStream, destFileNameForStreamSource, destStagePath, showEncryptionParameter, sourceFromStream, sourceStream, statusRows
Constructor and Description |
---|
SnowflakeFileTransferAgent(String command,
SFSession session,
SFStatement statement) |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
InputStream |
downloadStream(String fileName)
Download a file from remote, and return an input stream
|
boolean |
execute()
Run the PUT/GET command, if a command has been set.
|
static net.snowflake.client.jdbc.SnowflakeFileTransferAgent.remoteLocation |
extractLocationAndPath(String stageLocationPath)
A small helper for extracting location name and path from full location path
|
SFBaseFileTransferAgent.CommandType |
getCommandType() |
static Callable<Void> |
getDownloadFileCallable(StageInfo stage,
String srcFilePath,
String localLocation,
Map<String,net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata> fileMetadataMap,
SnowflakeStorageClient client,
SFSession session,
String command,
int parallel,
net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat,
String presignedUrl)
A callable that can be executed in a separate thread using executor service.
|
List<net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> |
getEncryptionMaterial() |
List<SnowflakeFileTransferMetadata> |
getFileTransferMetadatas()
This is API function to retrieve the File Transfer Metadatas.
|
static List<SnowflakeFileTransferMetadata> |
getFileTransferMetadatas(com.fasterxml.jackson.databind.JsonNode jsonNode)
This is API function to parse the File Transfer Metadatas from a supplied PUT call response.
|
Object |
getResultSet() |
Map<String,net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> |
getSrcToMaterialsMap() |
Map<String,String> |
getSrcToPresignedUrlMap() |
Map<?,?> |
getStageCredentials() |
StageInfo |
getStageInfo() |
String |
getStageLocation() |
static Callable<Void> |
getUploadFileCallable(StageInfo stage,
String srcFilePath,
net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata metadata,
SnowflakeStorageClient client,
SFSession session,
String command,
InputStream inputStream,
boolean sourceFromStream,
int parallel,
File srcFile,
net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)
A callable that can be executed in a separate thread using exeuctor service.
|
static void |
renewExpiredToken(SFSession session,
String command,
SnowflakeStorageClient client)
This static method is called when we are handling an expired token exception It retrieves a
fresh token from GS and then calls .renew() on the storage client to refresh itself with the
new token
|
static void |
throwJCEMissingError(String operation,
Exception ex) |
static void |
uploadWithoutConnection(SnowflakeFileTransferConfig config)
Static API function to upload data without JDBC session.
|
describeColumns, getNextRow, getTotalRows, setCompressSourceFromStream, setDestFileNameForStreamSource, setDestStagePath, setSourceStream
public static final String SRC_FILE_NAME_FOR_STREAM
public SnowflakeFileTransferAgent(String command, SFSession session, SFStatement statement) throws SnowflakeSQLException
SnowflakeSQLException
public StageInfo getStageInfo()
public Map<?,?> getStageCredentials()
public List<net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> getEncryptionMaterial()
public Map<String,net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> getSrcToMaterialsMap()
public String getStageLocation()
public static Callable<Void> getUploadFileCallable(StageInfo stage, String srcFilePath, net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata metadata, SnowflakeStorageClient client, SFSession session, String command, InputStream inputStream, boolean sourceFromStream, int parallel, File srcFile, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)
The callable does compression if needed and upload the result to the table's staging area.
stage
- information about the stagesrcFilePath
- source file pathmetadata
- file metadataclient
- client object used to communicate with c3session
- session objectcommand
- command stringinputStream
- null if upload source is filesourceFromStream
- whether upload source is file or streamparallel
- number of threads for parallel uploadingsrcFile
- source file nameencMat
- not null if encryption is requiredpublic static Callable<Void> getDownloadFileCallable(StageInfo stage, String srcFilePath, String localLocation, Map<String,net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata> fileMetadataMap, SnowflakeStorageClient client, SFSession session, String command, int parallel, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat, String presignedUrl)
The callable download files from a stage location to a local location
stage
- stage informationsrcFilePath
- path that stores the downloaded filelocalLocation
- local locationfileMetadataMap
- file metadata mapclient
- remote store clientsession
- session objectcommand
- command stringencMat
- remote store encryption materialparallel
- number of parallel threads for downloadingpresignedUrl
- Presigned URL for file downloadpublic List<SnowflakeFileTransferMetadata> getFileTransferMetadatas() throws SnowflakeSQLException
NOTE: It only supports PUT on S3/AZURE/GCS
SnowflakeSQLException
- if any error occurspublic static List<SnowflakeFileTransferMetadata> getFileTransferMetadatas(com.fasterxml.jackson.databind.JsonNode jsonNode) throws SnowflakeSQLException
NOTE: It only supports PUT on S3/AZURE/GCS (i.e. NOT LOCAL_FS)
jsonNode
- JSON doc returned by GS from PUT callSnowflakeSQLException
- if any error occurspublic boolean execute() throws SQLException
SFBaseFileTransferAgent
execute
in class SFBaseFileTransferAgent
SQLException
- for SQL or upload errorspublic InputStream downloadStream(String fileName) throws SnowflakeSQLException
downloadStream
in class SFBaseFileTransferAgent
fileName
- A file on a stage to download.SnowflakeSQLException
- If the file does not exist, or if an error occurred during
transport.public void cancel()
public static void uploadWithoutConnection(SnowflakeFileTransferConfig config) throws Exception
NOTE: This function is developed based on getUploadFileCallable().
config
- Configuration to upload a file to cloud storageException
- if error occurs while data upload.public static void renewExpiredToken(SFSession session, String command, SnowflakeStorageClient client) throws SnowflakeSQLException
session
- a session objectcommand
- a command to be retriedclient
- a Snowflake Storage client objectSnowflakeSQLException
- if any error occurspublic static net.snowflake.client.jdbc.SnowflakeFileTransferAgent.remoteLocation extractLocationAndPath(String stageLocationPath)
stageLocationPath
- stage locationpublic Object getResultSet() throws SnowflakeSQLException
SnowflakeSQLException
public SFBaseFileTransferAgent.CommandType getCommandType()
public static void throwJCEMissingError(String operation, Exception ex) throws SnowflakeSQLException
SnowflakeSQLException
Copyright © 2022. All rights reserved.