You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "birschick-bq (via GitHub)" <gi...@apache.org> on 2024/11/01 00:13:26 UTC
[PR] feat(csharp/src/Drivers/Apache): convert Double to Float for Apache Spark on scalar conversion [arrow-adbc]
birschick-bq opened a new pull request, #2296:
URL: https://github.com/apache/arrow-adbc/pull/2296
If Apache Spark server indicates the host data type is FLOAT, and the `scalar` data type conversion is selected, convert Double array to Float array.
* Performs conversion as prescribed
* Updates tests
* Corrects SQL statement for older versions of Spark server.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(csharp/src/Drivers/Apache): convert Double to Float for Apache Spark on scalar conversion [arrow-adbc]
Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on code in PR #2296:
URL: https://github.com/apache/arrow-adbc/pull/2296#discussion_r1826123907
##########
csharp/src/Drivers/Apache/Hive2/HiveServer2Reader.cs:
##########
@@ -178,6 +189,18 @@ internal static Date32Array ConvertToDate32(StringArray array, IArrowType _)
return resultArray.Build();
}
+ internal static FloatArray ConvertToFloat(DoubleArray array, IArrowType _)
+ {
+ var resultArray = new FloatArray.Builder();
+ int length = array.Length;
Review Comment:
Added call to .Reserve() for all array builders.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(csharp/src/Drivers/Apache): convert Double to Float for Apache Spark on scalar conversion [arrow-adbc]
Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher merged PR #2296:
URL: https://github.com/apache/arrow-adbc/pull/2296
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(csharp/src/Drivers/Apache): convert Double to Float for Apache Spark on scalar conversion [arrow-adbc]
Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on code in PR #2296:
URL: https://github.com/apache/arrow-adbc/pull/2296#discussion_r1825896102
##########
csharp/src/Drivers/Apache/Hive2/HiveServer2Reader.cs:
##########
@@ -178,6 +189,18 @@ internal static Date32Array ConvertToDate32(StringArray array, IArrowType _)
return resultArray.Build();
}
+ internal static FloatArray ConvertToFloat(DoubleArray array, IArrowType _)
+ {
+ var resultArray = new FloatArray.Builder();
+ int length = array.Length;
Review Comment:
Awesome suggestion!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(csharp/src/Drivers/Apache): convert Double to Float for Apache Spark on scalar conversion [arrow-adbc]
Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on code in PR #2296:
URL: https://github.com/apache/arrow-adbc/pull/2296#discussion_r1825879537
##########
csharp/src/Drivers/Apache/Hive2/HiveServer2Reader.cs:
##########
@@ -178,6 +189,18 @@ internal static Date32Array ConvertToDate32(StringArray array, IArrowType _)
return resultArray.Build();
}
+ internal static FloatArray ConvertToFloat(DoubleArray array, IArrowType _)
+ {
+ var resultArray = new FloatArray.Builder();
+ int length = array.Length;
Review Comment:
Generally -- and this applies to `ConvertToDate32` as well -- it's much better to first call `resultArray.Reserve(length)` before starting to append values. This avoids the need to resize the buffers as the array grows. An array of length 100 would need to be resized four times (8 -> 16, 16 -> 32, 32 -> 64 and 64 -> 128), and each resizing involves allocating a new buffer and copying the values over from the old buffer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org