You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "hermanschaaf (via GitHub)" <gi...@apache.org> on 2023/03/31 14:27:00 UTC

[GitHub] [arrow] hermanschaaf opened a new issue, #34828: [Go] Date32 and Date64 String() methods return numbers instead of dates

hermanschaaf opened a new issue, #34828:
URL: https://github.com/apache/arrow/issues/34828

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   The String methods on the Go `array.Date32` and `array.Date64` types return strings formatted as the underlying integers, rather than strings formatted as dates as in other implementations.
   
   For example, this code in Go:
   
   ```
   package main
   
   import (
   	"fmt"
   
   	"github.com/apache/arrow/go/v12/arrow"
   	"github.com/apache/arrow/go/v12/arrow/array"
   	"github.com/apache/arrow/go/v12/arrow/memory"
   )
   
   func main() {
   	db := array.NewDate32Builder(memory.DefaultAllocator)
   	defer db.Release()
   	db.AppendValues([]arrow.Date32{1, 2, 3}, nil)
   	arr := db.NewArray()
   	defer arr.Release()
   	fmt.Println(arr)
   }
   ```
   
   produces the following output:
   
   ```
   [1 2 3]
   ```
   
   More or less equivalent code in Python:
   
   ```
   import pyarrow as pa
   
   date_array = pa.array([1, 2, 3], type=pa.date32())
   print(date_array)
   ```
   
   produces:
   
   ```
   [
     1970-01-02,
     1970-01-03,
     1970-01-04
   ]
   ```
   
   I think the Go implementation's dates should also return formatted dates?
   
   ### Component(s)
   
   Go


-- 
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: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on issue #34828: [Go] Date32 and Date64 String() methods return numbers instead of dates

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on issue #34828:
URL: https://github.com/apache/arrow/issues/34828#issuecomment-1494631080

   So, the `arrow.Date32` and `arrow.Date64` types have `FormattedString` methods which return the actual date instead of the numeric value. I'm not opposed to just renaming them as `String()` so that it becomes the default string representation for those types and it should be pretty easy to do.
   
   Alternately, the `String()` method of those arrays could be modified to call `FormattedString` instead of just writing the numbers to the buffer.
   
   Honestly, I'd probably label this as an enhancement rather than a bug, because the current behavior *is* the intended behavior.


-- 
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


[GitHub] [arrow] hermanschaaf commented on issue #34828: [Go] Date32 and Date64 String() methods return numbers instead of dates

Posted by "hermanschaaf (via GitHub)" <gi...@apache.org>.
hermanschaaf commented on issue #34828:
URL: https://github.com/apache/arrow/issues/34828#issuecomment-1492038098

   I can submit a patch for this: just want to check that you agree this is a bug first.


-- 
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


[GitHub] [arrow] zeroshade commented on issue #34828: [Go] Date32 and Date64 String() methods return numbers instead of dates

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on issue #34828:
URL: https://github.com/apache/arrow/issues/34828#issuecomment-1496154619

   @hermanschaaf I think that bringing them into alignment is a perfectly reasonable thing to do, and if you want to file a PR to implement one of the suggestions I made, I'd happily review and support such a thing. (or if you have a better idea than my off the cuff suggestions). Let's mark this as an enhancement request for now and just ping me if you decide to file the PR.


-- 
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


[GitHub] [arrow] hermanschaaf commented on issue #34828: [Go] Date32 and Date64 String() methods return numbers instead of dates

Posted by "hermanschaaf (via GitHub)" <gi...@apache.org>.
hermanschaaf commented on issue #34828:
URL: https://github.com/apache/arrow/issues/34828#issuecomment-1495581700

   @zeroshade Great, thanks for the context! Yeah, I think the Go implementation here should probably match the C++/Python ones, and print the formatted string, so that when you print the array you get the actual dates. But if it was intended to work the way it is now then maybe it's fine. It's good to know there is at least a `FormattedString` function that could be used. 


-- 
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