forked from fixer-m/snowflake-db-net-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnowflakeChunksDownloaderTest.cs
54 lines (46 loc) · 1.96 KB
/
SnowflakeChunksDownloaderTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using NUnit.Framework;
using Snowflake.Client.Model;
using System.Linq;
using System.Threading.Tasks;
namespace Snowflake.Client.Tests.IntegrationTests
{
[TestFixture]
public class SnowflakeChunksDownloaderTest : IntegrationTestBase
{
[Test]
public async Task DownloadAndParseChunks()
{
var result = await _snowflakeClient.QueryRawResponseAsync("select top 10000 * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF1000.SUPPLIER;");
var chunksDownloadInfo = new ChunksDownloadInfo() { ChunkHeaders = result.ChunkHeaders, Chunks = result.Chunks, Qrmk = result.Qrmk };
var parsed = await ChunksDownloader.DownloadAndParseChunksAsync(chunksDownloadInfo);
var totalRowCountInChunks = result.Chunks.Sum(c => c.RowCount);
Assert.AreEqual(totalRowCountInChunks, parsed.Count);
}
[Test]
public async Task QueryAndMap_ResponseWithChunks()
{
var selectCount = 10000;
var result = await _snowflakeClient.QueryAsync<Supplier>($"select top {selectCount} * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF1000.SUPPLIER;");
var records = result.ToList();
Assert.AreEqual(selectCount, records.Count);
}
[Test]
public async Task QueryAndMap_ResponseWithChunks_AndRowset()
{
var selectCount = 1300;
var result = await _snowflakeClient.QueryAsync<Supplier>($"select top {selectCount} * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF1000.SUPPLIER;");
var records = result.ToList();
Assert.AreEqual(selectCount, records.Count);
}
}
internal class Supplier
{
public long? S_Suppkey { get; set; }
public string S_Name { get; set; }
public string S_Address { get; set; }
public int? S_Nationkey { get; set; }
public string S_Phone { get; set; }
public float? S_Acctbal { get; set; }
public string S_Comment { get; set; }
}
}