[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16221614#comment-16221614
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm closed pull request #1256: ARROW-1730, ARROW-1738: [Python] Fix wrong 
datetime conversion
URL: https://github.com/apache/arrow/pull/1256
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cpp/src/arrow/python/builtin_convert.cc 
b/cpp/src/arrow/python/builtin_convert.cc
index f7862d151..d52627ebf 100644
--- a/cpp/src/arrow/python/builtin_convert.cc
+++ b/cpp/src/arrow/python/builtin_convert.cc
@@ -522,18 +522,51 @@ class UInt64Converter : public 
TypedConverterVisitor {
  public:
   inline Status AppendItem(const OwnedRef& item) {
-auto pydate = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDate_to_ms(pydate));
+int64_t t;
+if (PyDate_Check(item.obj())) {
+  auto pydate = reinterpret_cast(item.obj());
+  t = PyDate_to_ms(pydate);
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
+  RETURN_IF_PYERROR();
+}
+return typed_builder_->Append(t);
   }
 };
 
 class TimestampConverter
 : public TypedConverterVisitor {
  public:
+  explicit TimestampConverter(TimeUnit::type unit) : unit_(unit) {}
+
   inline Status AppendItem(const OwnedRef& item) {
-auto pydatetime = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDateTime_to_us(pydatetime));
+int64_t t;
+if (PyDateTime_Check(item.obj())) {
+  auto pydatetime = reinterpret_cast(item.obj());
+
+  switch (unit_) {
+case TimeUnit::SECOND:
+  t = PyDateTime_to_s(pydatetime);
+  break;
+case TimeUnit::MILLI:
+  t = PyDateTime_to_ms(pydatetime);
+  break;
+case TimeUnit::MICRO:
+  t = PyDateTime_to_us(pydatetime);
+  break;
+case TimeUnit::NANO:
+  t = PyDateTime_to_ns(pydatetime);
+  break;
+  }
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
+  RETURN_IF_PYERROR();
+}
+return typed_builder_->Append(t);
   }
+
+ private:
+  TimeUnit::type unit_;
 };
 
 class DoubleConverter : public TypedConverterVisitor {
@@ -687,7 +720,8 @@ std::shared_ptr GetConverter(const 
std::shared_ptr& type
 case Type::DATE64:
   return std::make_shared();
 case Type::TIMESTAMP:
-  return std::make_shared();
+  return std::make_shared(
+  static_cast(*type).unit());
 case Type::DOUBLE:
   return std::make_shared();
 case Type::BINARY:
diff --git a/cpp/src/arrow/python/util/datetime.h 
b/cpp/src/arrow/python/util/datetime.h
index 782960f62..c110bc64a 100644
--- a/cpp/src/arrow/python/util/datetime.h
+++ b/cpp/src/arrow/python/util/datetime.h
@@ -247,12 +247,26 @@ static inline int64_t PyDate_to_ms(PyDateTime_Date* 
pydate) {
   return total_seconds * 1000;
 }
 
+static inline int64_t PyDateTime_to_s(PyDateTime_DateTime* pydatetime) {
+  return PyDate_to_ms(reinterpret_cast(pydatetime)) / 1000LL;
+}
+
+static inline int64_t PyDateTime_to_ms(PyDateTime_DateTime* pydatetime) {
+  int64_t date_ms = 
PyDate_to_ms(reinterpret_cast(pydatetime));
+  int ms = PyDateTime_DATE_GET_MICROSECOND(pydatetime) / 1000;
+  return date_ms + ms;
+}
+
 static inline int64_t PyDateTime_to_us(PyDateTime_DateTime* pydatetime) {
   int64_t ms = PyDate_to_ms(reinterpret_cast(pydatetime));
   int us = PyDateTime_DATE_GET_MICROSECOND(pydatetime);
   return ms * 1000 + us;
 }
 
+static inline int64_t PyDateTime_to_ns(PyDateTime_DateTime* pydatetime) {
+  return PyDateTime_to_us(pydatetime) * 1000;
+}
+
 static inline int32_t PyDate_to_days(PyDateTime_Date* pydate) {
   return static_cast(PyDate_to_ms(pydate) / 8640LL);
 }
diff --git a/python/pyarrow/tests/test_convert_builtin.py 
b/python/pyarrow/tests/test_convert_builtin.py
index d18ed9506..414266ddb 100644
--- a/python/pyarrow/tests/test_convert_builtin.py
+++ b/python/pyarrow/tests/test_convert_builtin.py
@@ -197,6 +197,75 @@ def test_timestamp(self):
 assert arr[3].as_py() == datetime.datetime(2010, 8, 13, 5,
46, 57, 437699)
 
+def test_timestamp_with_unit(self):
+data = [
+datetime.datetime(2007, 7, 13, 1, 23, 34, 123456),
+]
+
+s = pa.timestamp('s')
+ms = pa.timestamp('ms')
+us = 

[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220994#comment-16220994
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on issue #1256: ARROW-1730, ARROW-1738: [Python] Fix wrong 
datetime conversion
URL: https://github.com/apache/arrow/pull/1256#issuecomment-339761168
 
 
   +1. I will await the build to run


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220988#comment-16220988
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on a change in pull request #1256: ARROW-1730, ARROW-1738: 
[Python] Fix wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256#discussion_r147231585
 
 

 ##
 File path: cpp/src/arrow/python/builtin_convert.cc
 ##
 @@ -522,18 +522,49 @@ class UInt64Converter : public 
TypedConverterVisitor {
  public:
   inline Status AppendItem(const OwnedRef& item) {
-auto pydate = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDate_to_ms(pydate));
+int64_t t;
+if (PyDate_Check(item.obj())) {
+  auto pydate = reinterpret_cast(item.obj());
+  t = PyDate_to_ms(pydate);
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
 
 Review comment:
   fixed


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220987#comment-16220987
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on a change in pull request #1256: ARROW-1730, ARROW-1738: 
[Python] Fix wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256#discussion_r147231578
 
 

 ##
 File path: cpp/src/arrow/python/builtin_convert.cc
 ##
 @@ -522,18 +522,49 @@ class UInt64Converter : public 
TypedConverterVisitor {
  public:
   inline Status AppendItem(const OwnedRef& item) {
-auto pydate = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDate_to_ms(pydate));
+int64_t t;
+if (PyDate_Check(item.obj())) {
+  auto pydate = reinterpret_cast(item.obj());
+  t = PyDate_to_ms(pydate);
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
+}
+return typed_builder_->Append(t);
   }
 };
 
 class TimestampConverter
 : public TypedConverterVisitor {
  public:
+  TimestampConverter(TimeUnit::type unit) : unit_(unit) {}
+
   inline Status AppendItem(const OwnedRef& item) {
-auto pydatetime = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDateTime_to_us(pydatetime));
+int64_t t;
+if (PyDateTime_Check(item.obj())) {
+  auto pydatetime = reinterpret_cast(item.obj());
+
+  switch (unit_) {
+case TimeUnit::SECOND:
+  t = PyDateTime_to_s(pydatetime);
+  break;
+case TimeUnit::MILLI:
+  t = PyDateTime_to_ms(pydatetime);
+  break;
+case TimeUnit::MICRO:
+  t = PyDateTime_to_us(pydatetime);
+  break;
+case TimeUnit::NANO:
+  t = PyDateTime_to_ns(pydatetime);
+  break;
+  }
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
 
 Review comment:
   fixed


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220912#comment-16220912
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on a change in pull request #1256: ARROW-1730, ARROW-1738: 
[Python] Fix wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256#discussion_r147221502
 
 

 ##
 File path: cpp/src/arrow/python/builtin_convert.cc
 ##
 @@ -522,18 +522,49 @@ class UInt64Converter : public 
TypedConverterVisitor {
  public:
   inline Status AppendItem(const OwnedRef& item) {
-auto pydate = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDate_to_ms(pydate));
+int64_t t;
+if (PyDate_Check(item.obj())) {
+  auto pydate = reinterpret_cast(item.obj());
+  t = PyDate_to_ms(pydate);
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
 
 Review comment:
   adding `RETURN_IF_PYERROR();` after this line is probably adequate error 
checking, then no further type checking is needed in the else


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220909#comment-16220909
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on a change in pull request #1256: ARROW-1730, ARROW-1738: 
[Python] Fix wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256#discussion_r147220475
 
 

 ##
 File path: cpp/src/arrow/python/builtin_convert.cc
 ##
 @@ -522,18 +522,49 @@ class UInt64Converter : public 
TypedConverterVisitor {
  public:
   inline Status AppendItem(const OwnedRef& item) {
-auto pydate = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDate_to_ms(pydate));
+int64_t t;
+if (PyDate_Check(item.obj())) {
+  auto pydate = reinterpret_cast(item.obj());
+  t = PyDate_to_ms(pydate);
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
 
 Review comment:
   Seems this can fail: 
https://docs.python.org/2/c-api/long.html#c.PyLong_AsLongLong. Is there a way 
for some other kind of object than a PyLong to end up in this code branch? 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220908#comment-16220908
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on a change in pull request #1256: ARROW-1730, ARROW-1738: 
[Python] Fix wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256#discussion_r147220854
 
 

 ##
 File path: cpp/src/arrow/python/builtin_convert.cc
 ##
 @@ -687,7 +718,8 @@ std::shared_ptr GetConverter(const 
std::shared_ptr& type
 case Type::DATE64:
   return std::make_shared();
 case Type::TIMESTAMP:
-  return std::make_shared();
+  return std::make_shared(
+  static_cast(&*type)->unit());
 
 Review comment:
   More consistent with other parts of the code to use `static_cast(*type).unit()`


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220910#comment-16220910
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on a change in pull request #1256: ARROW-1730, ARROW-1738: 
[Python] Fix wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256#discussion_r147220627
 
 

 ##
 File path: cpp/src/arrow/python/builtin_convert.cc
 ##
 @@ -522,18 +522,49 @@ class UInt64Converter : public 
TypedConverterVisitor {
  public:
   inline Status AppendItem(const OwnedRef& item) {
-auto pydate = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDate_to_ms(pydate));
+int64_t t;
+if (PyDate_Check(item.obj())) {
+  auto pydate = reinterpret_cast(item.obj());
+  t = PyDate_to_ms(pydate);
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
+}
+return typed_builder_->Append(t);
   }
 };
 
 class TimestampConverter
 : public TypedConverterVisitor {
  public:
+  TimestampConverter(TimeUnit::type unit) : unit_(unit) {}
+
   inline Status AppendItem(const OwnedRef& item) {
-auto pydatetime = reinterpret_cast(item.obj());
-return typed_builder_->Append(PyDateTime_to_us(pydatetime));
+int64_t t;
+if (PyDateTime_Check(item.obj())) {
+  auto pydatetime = reinterpret_cast(item.obj());
+
+  switch (unit_) {
+case TimeUnit::SECOND:
+  t = PyDateTime_to_s(pydatetime);
+  break;
+case TimeUnit::MILLI:
+  t = PyDateTime_to_ms(pydatetime);
+  break;
+case TimeUnit::MICRO:
+  t = PyDateTime_to_us(pydatetime);
+  break;
+case TimeUnit::NANO:
+  t = PyDateTime_to_ns(pydatetime);
+  break;
+  }
+} else {
+  t = static_cast(PyLong_AsLongLong(item.obj()));
 
 Review comment:
   see above


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220904#comment-16220904
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

wesm commented on issue #1256: ARROW-1730, ARROW-1738: [Python] Fix wrong 
datetime conversion
URL: https://github.com/apache/arrow/pull/1256#issuecomment-339748151
 
 
   rebased


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220648#comment-16220648
 ] 

ASF GitHub Bot commented on ARROW-1730:
---

Licht-T opened a new pull request #1256: ARROW-1730, ARROW-1738: [Python] Fix 
wrong datetime conversion
URL: https://github.com/apache/arrow/pull/1256
 
 
   This closes [ARROW-1730](https://issues.apache.org/jira/browse/ARROW-1730) 
and [ARROW-1738](https://issues.apache.org/jira/browse/ARROW-1738).


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-26 Thread Licht Takeuchi (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16220405#comment-16220405
 ] 

Licht Takeuchi commented on ARROW-1730:
---

I'm working on this.
It seems that PyLong is casted to PyDateTime.

> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
>Assignee: Licht Takeuchi
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1730) [Python] Incorrect result from pyarrow.array when passing timestamp type

2017-10-25 Thread Wes McKinney (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16219186#comment-16219186
 ] 

Wes McKinney commented on ARROW-1730:
-

But

{code}
In [15]: pa.array(np.array([0], dtype='int64'), type=pa.timestamp('ns'))
Out[15]: 

[
  Timestamp('1970-01-01 00:00:00')
]
{code}

> [Python] Incorrect result from pyarrow.array when passing timestamp type
> 
>
> Key: ARROW-1730
> URL: https://issues.apache.org/jira/browse/ARROW-1730
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: Python
>Reporter: Wes McKinney
> Fix For: 0.8.0
>
>
> Even with the ARROW-1484 patch, we have:
> {code: language=python}
> In [10]: pa.array([0], type=pa.timestamp('ns'))
> Out[10]: 
> 
> [
>   Timestamp('1968-01-12 11:18:14.409378304')
> ]
> In [11]: pa.array([0], type='int64').cast(pa.timestamp('ns'))
> Out[11]: 
> 
> [
>   Timestamp('1970-01-01 00:00:00')
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)