-
Notifications
You must be signed in to change notification settings - Fork 330
Changes to support Arrow 2.0 and Spark 3.0 #711
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
Changes from 20 commits
895b2dc
15e6288
f5ceed4
77c37c5
6d23a66
a8e478e
aeaaf0f
317e136
e7a6293
13ae385
329c2d7
9013fe9
cae8f01
28ea3f0
e2dcd03
bc451fa
b3be37a
5021df4
f5da9cf
8a67ece
4e46ff4
016d6d0
e2cc263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -422,8 +422,7 @@ private CommandExecutorStat ExecuteArrowSqlCommand( | |||||||
|
|
||||||||
| var recordBatch = new RecordBatch(resultSchema, results, numEntries); | ||||||||
|
|
||||||||
| // TODO: Remove sync-over-async once WriteRecordBatch exists. | ||||||||
| writer.WriteRecordBatchAsync(recordBatch).GetAwaiter().GetResult(); | ||||||||
| writer.WriteRecordBatch(recordBatch); | ||||||||
| } | ||||||||
|
|
||||||||
| WriteEnd(outputStream, ipcOptions); | ||||||||
|
|
@@ -468,8 +467,7 @@ private CommandExecutorStat ExecuteDataFrameSqlCommand( | |||||||
| new ArrowStreamWriter(outputStream, result.Schema, leaveOpen: true, ipcOptions); | ||||||||
| } | ||||||||
|
|
||||||||
| // TODO: Remove sync-over-async once WriteRecordBatch exists. | ||||||||
| writer.WriteRecordBatchAsync(result).GetAwaiter().GetResult(); | ||||||||
| writer.WriteRecordBatch(result); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -737,6 +735,27 @@ protected internal override CommandExecutorStat ExecuteCore( | |||||||
| return ExecuteArrowGroupedMapCommand(inputStream, outputStream, commands); | ||||||||
| } | ||||||||
|
|
||||||||
| private RecordBatch WrapArrowRecordBatchColumnsInAStruct(RecordBatch batch) | ||||||||
| { | ||||||||
| if (_version >= new Version(Versions.V3_0_0)) | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this instead ?
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, that's actually what I had first, until I saw this:
Are you worried about the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a very minor micro optimization. We can keep, I don't mind either. 👍 |
||||||||
| { | ||||||||
| var fields = new Field[batch.Schema.Fields.Count]; | ||||||||
| for (int i = 0; i < batch.Schema.Fields.Count; i++) | ||||||||
|
imback82 marked this conversation as resolved.
Outdated
|
||||||||
| { | ||||||||
| fields[i] = batch.Schema.GetFieldByIndex(i); | ||||||||
| } | ||||||||
| var structType = new StructType(fields); | ||||||||
|
pgovind marked this conversation as resolved.
|
||||||||
| var structArray = new StructArray( | ||||||||
| structType, | ||||||||
| batch.Length, | ||||||||
| batch.Arrays.Cast<Apache.Arrow.Array>(), | ||||||||
| ArrowBuffer.Empty); | ||||||||
| Schema schema = new Schema.Builder().Field(new Field("Struct", structType, false)).Build(); | ||||||||
| return new RecordBatch(schema, new[] { structArray }, batch.Length); | ||||||||
| } | ||||||||
| return batch; | ||||||||
|
pgovind marked this conversation as resolved.
|
||||||||
| } | ||||||||
|
pgovind marked this conversation as resolved.
|
||||||||
|
|
||||||||
| private CommandExecutorStat ExecuteArrowGroupedMapCommand( | ||||||||
| Stream inputStream, | ||||||||
| Stream outputStream, | ||||||||
|
|
@@ -754,8 +773,9 @@ private CommandExecutorStat ExecuteArrowGroupedMapCommand( | |||||||
| ArrowStreamWriter writer = null; | ||||||||
| foreach (RecordBatch input in GetInputIterator(inputStream)) | ||||||||
| { | ||||||||
| RecordBatch result = worker.Func(input); | ||||||||
| RecordBatch batch = worker.Func(input); | ||||||||
|
|
||||||||
| RecordBatch result = WrapArrowRecordBatchColumnsInAStruct(batch); | ||||||||
| int numEntries = result.Length; | ||||||||
| stat.NumEntriesProcessed += numEntries; | ||||||||
|
|
||||||||
|
|
@@ -765,8 +785,7 @@ private CommandExecutorStat ExecuteArrowGroupedMapCommand( | |||||||
| new ArrowStreamWriter(outputStream, result.Schema, leaveOpen: true, ipcOptions); | ||||||||
| } | ||||||||
|
|
||||||||
| // TODO: Remove sync-over-async once WriteRecordBatch exists. | ||||||||
| writer.WriteRecordBatchAsync(result).GetAwaiter().GetResult(); | ||||||||
| writer.WriteRecordBatch(result); | ||||||||
| } | ||||||||
|
|
||||||||
| WriteEnd(outputStream, ipcOptions); | ||||||||
|
|
@@ -794,20 +813,21 @@ private CommandExecutorStat ExecuteDataFrameGroupedMapCommand( | |||||||
| { | ||||||||
| FxDataFrame dataFrame = FxDataFrame.FromArrowRecordBatch(input); | ||||||||
| FxDataFrame resultDataFrame = worker.Func(dataFrame); | ||||||||
|
|
||||||||
| IEnumerable<RecordBatch> recordBatches = resultDataFrame.ToArrowRecordBatches(); | ||||||||
|
|
||||||||
| foreach (RecordBatch result in recordBatches) | ||||||||
| foreach (RecordBatch batch in recordBatches) | ||||||||
| { | ||||||||
| stat.NumEntriesProcessed += result.Length; | ||||||||
| RecordBatch final = WrapArrowRecordBatchColumnsInAStruct(batch); | ||||||||
|
pgovind marked this conversation as resolved.
Outdated
|
||||||||
| stat.NumEntriesProcessed += final.Length; | ||||||||
|
|
||||||||
| if (writer == null) | ||||||||
| { | ||||||||
| writer = | ||||||||
| new ArrowStreamWriter(outputStream, result.Schema, leaveOpen: true, ipcOptions); | ||||||||
| new ArrowStreamWriter(outputStream, final.Schema, leaveOpen: true, ipcOptions); | ||||||||
| } | ||||||||
|
|
||||||||
| // TODO: Remove sync-over-async once WriteRecordBatch exists. | ||||||||
| writer.WriteRecordBatchAsync(result).GetAwaiter().GetResult(); | ||||||||
| writer.WriteRecordBatch(final); | ||||||||
|
pgovind marked this conversation as resolved.
|
||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.