You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "miguelpragier (via GitHub)" <gi...@apache.org> on 2023/10/05 07:54:53 UTC
[PR] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
miguelpragier opened a new pull request, #38028:
URL: https://github.com/apache/arrow/pull/38028
### Rationale for this change
This PR targets flightsql.Driver, that complies with sql.Driver interface, from the stdlib. <br>
The driver has a resultset iterator: the type [Rows](https://github.com/apache/arrow/blob/7d834d65c37c17d1c19bfb497eadb983893c9ea0/go/arrow/flight/flightsql/driver/driver.go#L39). <br>
The method [Rows.Next()](https://github.com/apache/arrow/blob/7d834d65c37c17d1c19bfb497eadb983893c9ea0/go/arrow/flight/flightsql/driver/driver.go#L81), which populates the next row of data, lacks handling/treatment of some common types, as described in the [issue](https://github.com/apache/arrow/issues/38017). <br>
### What changes are included in this PR?
This PR includes the missing common basic data types for Rows.Next() method. <br>
### Are these changes tested?
The driver is already tested, but I also included unitary tests that cover not only the new types, but all the implemented types. <br>
### Are there any user-facing changes?
All the contracts and signatures, and the current types were preserved. <br>
--
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] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #38028:
URL: https://github.com/apache/arrow/pull/38028#discussion_r1347530471
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.Float16:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx).Float32()), nil
Review Comment:
should a float16 return a `float64`? or should it return `float16.Num`? I would lean towards the latter
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.Float16:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx).Float32()), nil
case *array.Float32:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx)), nil
Review Comment:
why convert to float64 rather than just return the `float32`?
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
Review Comment:
because `IsNull` is in the `arrow.Array` interface, you can probably factor this out and just do `if arr.IsNull(idx) { return nil, nil }` before the typeswitch both to simplify the code and to create a fast path for nulls to avoid the type switch entirely in that case.
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.Float16:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx).Float32()), nil
case *array.Float32:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx)), nil
case *array.Float64:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
+ case *array.Decimal128:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
+ dt, ok := arr.DataType().(*arrow.Decimal128Type)
+ if !ok {
+ return nil, fmt.Errorf("datatype %T not matching decimal128", arr.DataType())
+ }
+
+ return c.Value(idx).ToFloat64(dt.Scale), nil
+ case *array.Decimal256:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
+ dt, ok := arr.DataType().(*arrow.Decimal256Type)
+ if !ok {
+ return nil, fmt.Errorf("datatype %T not matching decimal256", arr.DataType())
+ }
+
+ return c.Value(idx).ToFloat64(dt.Scale), nil
case *array.Int8:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return int64(c.Value(idx)), nil
Review Comment:
i know that this is the existing code, but since we're in this discussion, does it make sense to upcast to int64 rather than letting it stay int8?
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.Float16:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx).Float32()), nil
case *array.Float32:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx)), nil
case *array.Float64:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
+ case *array.Decimal128:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
+ dt, ok := arr.DataType().(*arrow.Decimal128Type)
+ if !ok {
+ return nil, fmt.Errorf("datatype %T not matching decimal128", arr.DataType())
+ }
+
+ return c.Value(idx).ToFloat64(dt.Scale), nil
+ case *array.Decimal256:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
+ dt, ok := arr.DataType().(*arrow.Decimal256Type)
+ if !ok {
+ return nil, fmt.Errorf("datatype %T not matching decimal256", arr.DataType())
+ }
+
+ return c.Value(idx).ToFloat64(dt.Scale), nil
case *array.Int8:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return int64(c.Value(idx)), nil
case *array.Int16:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return int64(c.Value(idx)), nil
case *array.Int32:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return int64(c.Value(idx)), nil
case *array.Int64:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
+ return c.Value(idx), nil
+ case *array.Binary:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.String:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.Time32:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
dt, ok := arr.DataType().(*arrow.Time32Type)
if !ok {
return nil, fmt.Errorf("datatype %T not matching time32", arr.DataType())
}
Review Comment:
same statement as above, there's no need to confirm the time32type here, it can be safely assumed
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
case *array.Float16:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx).Float32()), nil
case *array.Float32:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return float64(c.Value(idx)), nil
case *array.Float64:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
return c.Value(idx), nil
+ case *array.Decimal128:
+ if c.IsNull(idx) {
+ return nil, nil
+ }
+
+ dt, ok := arr.DataType().(*arrow.Decimal128Type)
+ if !ok {
+ return nil, fmt.Errorf("datatype %T not matching decimal128", arr.DataType())
+ }
Review Comment:
this check is unnecessary, there should never be a case where the datatype for a `Decimal128` is not a `Decimal128Type`
--
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] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #38028:
URL: https://github.com/apache/arrow/pull/38028#issuecomment-1751642777
After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 10843823ea7e8856c0ae1eb19143b7d786d334e7.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/17488175674) has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
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] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38028:
URL: https://github.com/apache/arrow/pull/38028#issuecomment-1748314660
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Thanks for opening a pull request!
If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
See also:
* [Other pull requests](https://github.com/apache/arrow/pulls/)
* [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
--
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] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #38028:
URL: https://github.com/apache/arrow/pull/38028
--
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] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38028:
URL: https://github.com/apache/arrow/pull/38028#issuecomment-1749605349
:warning: GitHub issue #38017 **has been automatically assigned in GitHub** to PR creator.
--
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] GH-38017: [Go][FlightSQL] Increment types handled by internal converter [arrow]
Posted by "miguelpragier (via GitHub)" <gi...@apache.org>.
miguelpragier commented on code in PR #38028:
URL: https://github.com/apache/arrow/pull/38028#discussion_r1347713397
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
Review Comment:
Great catch, thanks! ✅
##########
go/arrow/flight/flightsql/driver/utils.go:
##########
@@ -60,44 +60,135 @@ func (g grpcCredentials) RequireTransportSecurity() bool {
func fromArrowType(arr arrow.Array, idx int) (interface{}, error) {
switch c := arr.(type) {
case *array.Boolean:
+ if c.IsNull(idx) {
Review Comment:
Great catch, thanks! ✅
--
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