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-1660331 export SnowflakeFileTransferOptions.GetFileToStream #1208

Merged
Merged
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
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
Loading