Skip to content

Commit

Permalink
SNOW-1660331 export SnowflakeFileTransferOptions.GetFileToStream (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dszmolka authored Sep 25, 2024
1 parent 099708d commit 3428b00
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion azure_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (util *snowflakeAzureClient) nativeDownloadFile(
if meta.mockAzureClient != nil {
blobClient = meta.mockAzureClient
}
if meta.options.getFileToStream {
if meta.options.GetFileToStream {
blobDownloadResponse, err := blobClient.DownloadStream(context.Background(), &azblob.DownloadStreamOptions{})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion connection_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (sc *snowflakeConn) processFileTransfer(
if err != nil {
return nil, err
}
if sfa.options.getFileToStream {
if sfa.options.GetFileToStream {
if err := writeFileStream(ctx, sfa.streamBuffer); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ an absolute path rather than a relative path. For example:
To download a file into an in-memory stream (rather than a file) use code similar to the code below.
var streamBuf bytes.Buffer
ctx := WithFileTransferOptions(context.Background(), &SnowflakeFileTransferOptions{getFileToStream: true})
ctx := WithFileTransferOptions(context.Background(), &SnowflakeFileTransferOptions{GetFileToStream: true})
ctx = WithFileGetStream(ctx, &streamBuf)
sql := "get @~/data1.txt.gz file:///tmp/testData"
Expand Down
2 changes: 1 addition & 1 deletion file_transfer_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type SnowflakeFileTransferOptions struct {
compressSourceFromStream bool

/* streaming GET */
getFileToStream bool
GetFileToStream bool

/* PUT */
putCallback *snowflakeProgressPercentage
Expand Down
2 changes: 1 addition & 1 deletion gcs_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (util *snowflakeGcsClient) nativeDownloadFile(
return meta.lastError
}

if meta.options.getFileToStream {
if meta.options.GetFileToStream {
if _, err := io.Copy(meta.dstStream, resp.Body); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions put_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestPutGetWithAutoCompressFalse(t *testing.T) {

// GET test
var streamBuf bytes.Buffer
ctx := WithFileTransferOptions(context.Background(), &SnowflakeFileTransferOptions{getFileToStream: true})
ctx := WithFileTransferOptions(context.Background(), &SnowflakeFileTransferOptions{GetFileToStream: true})
ctx = WithFileGetStream(ctx, &streamBuf)
sql := fmt.Sprintf("get @~/test_put_uncompress_file/data.txt 'file://%v'", tmpDir)
sqlText = strings.ReplaceAll(sql, "\\", "\\\\")
Expand Down Expand Up @@ -468,7 +468,7 @@ func testPutGet(t *testing.T, isStream bool) {

var streamBuf bytes.Buffer
if isStream {
ctx = WithFileTransferOptions(ctx, &SnowflakeFileTransferOptions{getFileToStream: true})
ctx = WithFileTransferOptions(ctx, &SnowflakeFileTransferOptions{GetFileToStream: true})
ctx = WithFileGetStream(ctx, &streamBuf)
}
sql = fmt.Sprintf("get @%%%v 'file://%v'", tableName, tmpDir)
Expand Down Expand Up @@ -686,7 +686,7 @@ func TestPutGetLargeFile(t *testing.T) {

// GET test with stream
var streamBuf bytes.Buffer
ctx := WithFileTransferOptions(context.Background(), &SnowflakeFileTransferOptions{getFileToStream: true})
ctx := WithFileTransferOptions(context.Background(), &SnowflakeFileTransferOptions{GetFileToStream: true})
ctx = WithFileGetStream(ctx, &streamBuf)
sql := fmt.Sprintf("get @%v 'file://%v'", "~/test_put_largefile/largefile.txt.gz", t.TempDir())
sqlText = strings.ReplaceAll(sql, "\\", "\\\\")
Expand Down
2 changes: 1 addition & 1 deletion s3_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (util *snowflakeS3Client) nativeDownloadFile(
downloader = meta.mockDownloader
}

if meta.options.getFileToStream {
if meta.options.GetFileToStream {
buf := manager.NewWriteAtBuffer([]byte{})
_, err = downloader.Download(context.Background(), buf, &s3.GetObjectInput{
Bucket: s3Obj.Bucket,
Expand Down
4 changes: 2 additions & 2 deletions storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (rsu *remoteStorageUtil) downloadOneFile(meta *fileMetadata) error {
return err
}
}
if meta.options.getFileToStream {
if meta.options.GetFileToStream {
totalFileSize, err := decryptStream(header.encryptionMetadata,
meta.encryptionMaterial, 0, meta.dstStream, meta.sfa.streamBuffer)
if err != nil {
Expand All @@ -238,7 +238,7 @@ func (rsu *remoteStorageUtil) downloadOneFile(meta *fileMetadata) error {
}

}
if !meta.options.getFileToStream {
if !meta.options.GetFileToStream {
if fi, err := os.Stat(fullDstFileName); err == nil {
meta.dstFileSize = fi.Size()
}
Expand Down

0 comments on commit 3428b00

Please sign in to comment.