From 4c28228c08aa971956f3b955d5b1e858ff775223 Mon Sep 17 00:00:00 2001 From: sfc-gh-dszmolka Date: Wed, 11 Sep 2024 18:13:26 +0200 Subject: [PATCH] SNOW-1660331 export SnowflakeFileTransferOptions.GetFileToStream --- azure_storage_client.go | 2 +- connection_util.go | 2 +- doc.go | 2 +- file_transfer_agent.go | 2 +- gcs_storage_client.go | 2 +- put_get_test.go | 6 +++--- s3_storage_client.go | 2 +- storage_client.go | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/azure_storage_client.go b/azure_storage_client.go index 307c7b264..b0626ebcb 100644 --- a/azure_storage_client.go +++ b/azure_storage_client.go @@ -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 diff --git a/connection_util.go b/connection_util.go index 78ea9d1c8..52e48176f 100644 --- a/connection_util.go +++ b/connection_util.go @@ -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 } diff --git a/doc.go b/doc.go index ec1865151..f1214f217 100644 --- a/doc.go +++ b/doc.go @@ -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" diff --git a/file_transfer_agent.go b/file_transfer_agent.go index c22d7489b..fe341cd81 100644 --- a/file_transfer_agent.go +++ b/file_transfer_agent.go @@ -92,7 +92,7 @@ type SnowflakeFileTransferOptions struct { compressSourceFromStream bool /* streaming GET */ - getFileToStream bool + GetFileToStream bool /* PUT */ putCallback *snowflakeProgressPercentage diff --git a/gcs_storage_client.go b/gcs_storage_client.go index b59708cc2..c39376de5 100644 --- a/gcs_storage_client.go +++ b/gcs_storage_client.go @@ -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 } diff --git a/put_get_test.go b/put_get_test.go index 8a4322a1b..f0722ee81 100644 --- a/put_get_test.go +++ b/put_get_test.go @@ -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, "\\", "\\\\") @@ -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) @@ -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, "\\", "\\\\") diff --git a/s3_storage_client.go b/s3_storage_client.go index 342d0c9f2..7cd1e3301 100644 --- a/s3_storage_client.go +++ b/s3_storage_client.go @@ -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, diff --git a/storage_client.go b/storage_client.go index 550be0d57..2079fa823 100644 --- a/storage_client.go +++ b/storage_client.go @@ -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 { @@ -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() }