-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-893835 Arrow - support for multi-chunk results (#771)
### Description Arrow - support for multi-chunk results. ### Checklist - [x] Code compiles correctly - [x] Code is formatted according to [Coding Conventions](../CodingConventions.md) - [x] Created tests which fail without the change (if possible) - [x] All tests passing (`dotnet test`) - [x] Extended the README / documentation, if necessary - [x] Provide JIRA issue id (if possible) or GitHub issue id in PR name
- Loading branch information
1 parent
4609451
commit 78ddc27
Showing
29 changed files
with
844 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2023 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
using System.Linq; | ||
using Apache.Arrow; | ||
using Apache.Arrow.Ipc; | ||
|
||
namespace Snowflake.Data.Tests.UnitTests | ||
{ | ||
using NUnit.Framework; | ||
using Snowflake.Data.Client; | ||
using Snowflake.Data.Configuration; | ||
using Snowflake.Data.Core; | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
[TestFixture, NonParallelizable] | ||
class ArrowChunkParserTest | ||
{ | ||
[Test] | ||
[Ignore("ArrowChunkParserTest")] | ||
public void ArrowChunkParserTestDone() | ||
{ | ||
// Do nothing - test progress marker | ||
} | ||
|
||
[Test] | ||
public void TestParseChunkReadsRecordBatches([Values(1, 2, 4)] int numberOfRecordBatch) | ||
{ | ||
// Arrange | ||
MemoryStream stream = new MemoryStream(); | ||
|
||
for (var i = 0; i < numberOfRecordBatch; i++) | ||
{ | ||
var numberOfRecordsInBatch = 10 * i; | ||
var recordBatch = new RecordBatch.Builder() | ||
.Append("Col_Int32", false, col => col.Int32(array => array.AppendRange(Enumerable.Range(1, numberOfRecordsInBatch)))) | ||
.Build(); | ||
|
||
ArrowStreamWriter writer = new ArrowStreamWriter(stream, recordBatch.Schema, true); | ||
writer.WriteRecordBatch(recordBatch); | ||
} | ||
stream.Position = 0; | ||
|
||
var parser = new ArrowChunkParser(stream); | ||
|
||
// Act | ||
var chunk = new ArrowResultChunk(1); | ||
var task = parser.ParseChunk(chunk); | ||
task.Wait(); | ||
|
||
// Assert | ||
Assert.AreEqual(numberOfRecordBatch, chunk.RecordBatch.Count); | ||
for (var i = 0; i < numberOfRecordBatch; i++) | ||
{ | ||
var numberOfRecordsInBatch = 10 * i; | ||
Assert.AreEqual(numberOfRecordsInBatch, chunk.RecordBatch[i].Length); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.