gtomitsuka opened a new pull request, #40272:
URL: https://github.com/apache/arrow/pull/40272

   ### Rationale for this change
   Exporting functions with unexposed return types is a bad practice in Go, as 
it makes typings more complex and makes it considerably more difficult for 
developers to pass the return values in their own functions, since you have to 
actively look through the types and figure out which interface the return type 
conforms to (if any), leading to significant wasted time and cryptic, useless 
return types in godocs and IDE suggestions.
   
   For example, at a glance, it's extremely difficult to tell whether these two 
return types (`*simpleTable` and `arrow.Table`) represent the same interface or 
something entirely different:
   
   <img width="1161" alt="image" 
src="https://github.com/apache/arrow/assets/10295671/463cd8a7-47f3-44ce-9871-2885025e5a5c";>
   <img width="1151" alt="image" 
src="https://github.com/apache/arrow/assets/10295671/4ffc049c-fb88-43fb-bd57-fc1ad5d4dc68";>
   
   Most table-related methods (e.g., `AddColumn()` or `TableFromJSON()`) return 
tables via the `arrow.Table` interface, while `NewTable`, `NewTableFromSlice`, 
and `NewTableFromColumns` return a `*simpleTable`.
   
   Similarly, most record-related methods (e.g., `RecordFromJSON()`) return 
   
   You can't use `*simpleTable` or similar types in function signatures or 
variables with explicit types, so this is a backwards-compatible change that 
will lead to better docs and IDE support for Arrow.
   
   ### What changes are included in this PR?
   * Change return signature of functions using the following unexposed return 
types:
       * `*simpleTable` --> `arrow.Table`
       * `*simpleRecord` --> `arrow.Record`
       * `*simpleRecords` --> `array.RecordReader`
   * Add the function `String()` to the `arrow.Table` interface. `*simpleTable` 
is the only implementation of `arrow.Table`, so this requires no further 
changes. 
   
   ### Are these changes tested?
   Yes. The relevant code is already covered by tests in 
`arrow/array/table_test.go` and `arrow/array/record_test.go`.
   
   All tests pass (subpackages without tests omitted):
   ```bash
   ok      github.com/apache/arrow/go/v16/arrow    0.398s
   ok      github.com/apache/arrow/go/v16/arrow/array      0.600s
   ok      github.com/apache/arrow/go/v16/arrow/arrio      1.544s
   ok      github.com/apache/arrow/go/v16/arrow/avro       0.629s
   ok      github.com/apache/arrow/go/v16/arrow/bitutil    1.001s
   ok      github.com/apache/arrow/go/v16/arrow/compute    2.147s
   ok      github.com/apache/arrow/go/v16/arrow/compute/exec       0.813s
   ok      github.com/apache/arrow/go/v16/arrow/compute/exprs      1.900s
   ok      github.com/apache/arrow/go/v16/arrow/csv        0.288s
   ok      github.com/apache/arrow/go/v16/arrow/decimal128 1.356s
   ok      github.com/apache/arrow/go/v16/arrow/decimal256 1.718s
   ok      github.com/apache/arrow/go/v16/arrow/encoded    0.493s
   ok      github.com/apache/arrow/go/v16/arrow/flight     2.845s
   ok      github.com/apache/arrow/go/v16/arrow/flight/flightsql   0.512s
   ok      github.com/apache/arrow/go/v16/arrow/flight/flightsql/driver    
7.386s
   ok      github.com/apache/arrow/go/v16/arrow/float16    0.570s
   ok      github.com/apache/arrow/go/v16/arrow/internal/arrjson   0.419s
   ok      github.com/apache/arrow/go/v16/arrow/internal/dictutils 0.407s
   ok      github.com/apache/arrow/go/v16/arrow/internal/testing/tools     
0.247s
   ok      github.com/apache/arrow/go/v16/arrow/ipc        1.984s
   ok      github.com/apache/arrow/go/v16/arrow/ipc/cmd/arrow-cat  0.530s
   ok      github.com/apache/arrow/go/v16/arrow/ipc/cmd/arrow-file-to-stream    
   1.267s
   ok      
github.com/apache/arrow/go/v16/arrow/ipc/cmd/arrow-json-integration-test        
1.074s
   ok      github.com/apache/arrow/go/v16/arrow/ipc/cmd/arrow-ls   1.263s
   ok      github.com/apache/arrow/go/v16/arrow/ipc/cmd/arrow-stream-to-file    
   0.935s
   ok      github.com/apache/arrow/go/v16/arrow/math       0.616s
   ok      github.com/apache/arrow/go/v16/arrow/memory     1.275s
   ok      github.com/apache/arrow/go/v16/arrow/memory/mallocator  0.348s
   ok      github.com/apache/arrow/go/v16/arrow/scalar     0.484s
   ok      github.com/apache/arrow/go/v16/arrow/tensor     0.418s
   ok      github.com/apache/arrow/go/v16/arrow/util       0.621s
   ```
   
   ### Are there any user-facing changes?
   No. The interfaces were unexported, and accordingly not possible to 
reference from user code.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to