You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/28 20:47:54 UTC

[GitHub] [arrow] kshitij12345 opened a new pull request, #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

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

   Following snippet now works.
   ```python
   dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],
                           pa.map_(pa.string(), pa.int64()))
   ```


-- 
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] github-actions[bot] commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1295450515

   :warning: Ticket **has not been started in JIRA**, please click 'Start Progress'.


-- 
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] jorisvandenbossche merged pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche merged PR #14547:
URL: https://github.com/apache/arrow/pull/14547


-- 
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] kshitij12345 commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
kshitij12345 commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1295450804

   cc: @AlenkaF @jorisvandenbossche 


-- 
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] rok commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1411179137

   > When will this fix be in PyPi? Need the new version 12.0.0 to be installable using `pip` please pray
   
   Releases are roughly every three months and 11.0.0 was released ~week ago.


-- 
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] jorisvandenbossche commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1308512122

   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


[GitHub] [arrow] github-actions[bot] commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1295450490

   https://issues.apache.org/jira/browse/ARROW-17832


-- 
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] kshitij12345 commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
kshitij12345 commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1305513444

   Gentle ping @AlenkaF @jorisvandenbossche :)


-- 
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] tommydangerous commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "tommydangerous (via GitHub)" <gi...@apache.org>.
tommydangerous commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1411088772

   When will this fix be in PyPi?


-- 
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] tommydangerous commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "tommydangerous (via GitHub)" <gi...@apache.org>.
tommydangerous commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1412978987

   Thank you @rok , I’ll try the nightly builds.


-- 
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] HyukjinKwon commented on a diff in pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #14547:
URL: https://github.com/apache/arrow/pull/14547#discussion_r1090511701


##########
python/pyarrow/tests/test_array.py:
##########
@@ -991,6 +991,16 @@ def test_map_labelled():
     assert len(arr) == 2
 
 
+def test_map_from_dict():
+    # ARROW-17832
+    tup_arr = pa.array([[('a', 1), ('b', 2)], [('c', 3)]],
+                       pa.map_(pa.string(), pa.int64()))
+    dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],

Review Comment:
   Thanks guys. I filed an issue here: https://github.com/apache/arrow/issues/33928



-- 
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] kshitij12345 commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
kshitij12345 commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1295771832

   MacOS failure looks irrelevant
   
   Ref: https://github.com/apache/arrow/actions/runs/3348431666/jobs/5547482119#step:5:175


-- 
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] jorisvandenbossche commented on a diff in pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on code in PR #14547:
URL: https://github.com/apache/arrow/pull/14547#discussion_r1016460167


##########
python/pyarrow/src/arrow/python/python_to_arrow.cc:
##########
@@ -760,6 +760,11 @@ class PyListConverter : public ListConverter<T, PyConverter, PyConverterTrait> {
       RETURN_NOT_OK(AppendSequence(value));
     } else if (PySet_Check(value) || (Py_TYPE(value) == &PyDictValues_Type)) {
       RETURN_NOT_OK(AppendIterable(value));
+    } else if (PyDict_Check(value) && this->options_.type->name() == "map") {

Review Comment:
   ```suggestion
       } else if (PyDict_Check(value) && this->options_.type->id() == Type::MAP) {
   ```



##########
python/pyarrow/tests/test_array.py:
##########
@@ -991,6 +991,18 @@ def test_map_labelled():
     assert len(arr) == 2
 
 
+def test_map_from_dict():
+    # ARROW-17832
+    tup_arr = pa.array([[('a', 1), ('b', 2)], [('c', 3)]],
+                       pa.map_(pa.string(), pa.int64()))
+    dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],
+                        pa.map_(pa.string(), pa.int64()))
+
+    assert tup_arr.type.key_field == dict_arr.type.key_field
+    assert tup_arr.type.item_field == dict_arr.type.item_field
+    assert tup_arr == dict_arr

Review Comment:
   ```suggestion
       assert tup_arr.equals(dict_arr)
   ```
   
   I think this should be sufficient for testing that it worked



-- 
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] tommydangerous commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "tommydangerous (via GitHub)" <gi...@apache.org>.
tommydangerous commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1412819533

   @rok how can we starting using this fix in Python immediately please?


-- 
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] rok commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1412906640

   @tommydangerous until the release (I guess mid-April) you could [build pyarrow yourself](https://arrow.apache.org/docs/developers/python.html#building-on-linux-and-macos) or use [nightly builds](https://arrow.apache.org/docs/developers/python.html#installing-nightly-packages). Nightly builds are meant for testing only and not recommended for other uses.


-- 
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] HyukjinKwon commented on a diff in pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #14547:
URL: https://github.com/apache/arrow/pull/14547#discussion_r1089871427


##########
python/pyarrow/tests/test_array.py:
##########
@@ -991,6 +991,16 @@ def test_map_labelled():
     assert len(arr) == 2
 
 
+def test_map_from_dict():
+    # ARROW-17832
+    tup_arr = pa.array([[('a', 1), ('b', 2)], [('c', 3)]],
+                       pa.map_(pa.string(), pa.int64()))
+    dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],

Review Comment:
   Thanks for this fix. Just had a quick followup question though. Should the nested dict work too? e.g.)
   
   ```python
   import pyarrow as pa
   pa.array([[{'a': 1, 'b': 2}, {'c': 3}]], pa.list_(pa.map_(pa.string(), pa.int64())))
   ```
   
   It currently fails w/
   
   ```
   pyarrow.lib.ArrowTypeError: Could not convert {'a': 1, 'b': 2} with type dict: was not a sequence or recognized null for conversion to list type
   ```
   



-- 
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] jorisvandenbossche commented on a diff in pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on code in PR #14547:
URL: https://github.com/apache/arrow/pull/14547#discussion_r1090456349


##########
python/pyarrow/tests/test_array.py:
##########
@@ -991,6 +991,16 @@ def test_map_labelled():
     assert len(arr) == 2
 
 
+def test_map_from_dict():
+    # ARROW-17832
+    tup_arr = pa.array([[('a', 1), ('b', 2)], [('c', 3)]],
+                       pa.map_(pa.string(), pa.int64()))
+    dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],

Review Comment:
   I would assume the nested case to work as well. Can you open a new issue about this?



-- 
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] kshitij12345 commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
kshitij12345 commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1301099553

   Gentle ping @AlenkaF @jorisvandenbossche :)


-- 
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] ursabot commented on pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #14547:
URL: https://github.com/apache/arrow/pull/14547#issuecomment-1309036864

   Benchmark runs are scheduled for baseline = 0fb8d413e831d28af9ff41be687ac71b36feb540 and contender = 734059e29be6f731f93162d048e2a0df59c73896. 734059e29be6f731f93162d048e2a0df59c73896 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/9823cf6623e54bbd8d50bf8b661024a6...a62dc4a5558c48a981047cbb7b31281a/)
   [Finished :arrow_down:0.34% :arrow_up:0.0%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/8c801f549fb54c9a8970e5220503e268...c63249444280429595846fc75fb65649/)
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/39be9a27440e4fea9ccb97464379025a...ee4f733b27264f4db1a426a58444bf56/)
   [Finished :arrow_down:0.11% :arrow_up:0.07%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/f9d345f667aa42cb87a5dc301954532e...6cc7f6b0f74e42c69d90f59aed2ad121/)
   Buildkite builds:
   [Finished] [`734059e2` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/1835)
   [Finished] [`734059e2` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/1857)
   [Finished] [`734059e2` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/1823)
   [Finished] [`734059e2` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/1849)
   [Finished] [`0fb8d413` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/1834)
   [Finished] [`0fb8d413` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/1856)
   [Finished] [`0fb8d413` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/1822)
   [Finished] [`0fb8d413` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/1848)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


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