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/09/15 00:23:41 UTC

[GitHub] [arrow] vibhatha commented on a diff in pull request #14123: ARROW-17061: [Python][Substrait] Acero consumer is unable to consume count function from substrait query plan

vibhatha commented on code in PR #14123:
URL: https://github.com/apache/arrow/pull/14123#discussion_r971406616


##########
python/pyarrow/tests/test_substrait.py:
##########
@@ -165,3 +169,108 @@ def test_get_supported_functions():
                         'functions_arithmetic.yaml', 'add')
     assert has_function(supported_functions,
                         'functions_arithmetic.yaml', 'sum')
+
+# TODO: add a test suite to check the integrated functions
+
+
+@pytest.mark.skipif(sys.platform == 'win32',
+                    reason="ARROW-16392: file based URI is" +
+                    " not fully supported for Windows")
+def test_run_aggregate_query(tmpdir):
+    substrait_query = """
+    {
+        "relations": [{
+        "rel": {
+            "aggregate": {
+            "input": {
+                "read": {
+                "base_schema": {
+                    "names": ["A", "B", "C"],
+                    "struct": {
+                    "types": [{
+                        "i64": {}
+                    }, {
+                        "i64": {}
+                    }, {
+                        "i64": {}
+                    }]
+                    }
+                },
+                "local_files": {
+                    "items": [
+                    {
+                        "uri_file": "file://FILENAME_PLACEHOLDER",
+                        "arrow": {}
+                    }
+                    ]
+                }
+                }
+            },
+            "groupings": [{
+                "groupingExpressions": [{
+                "selection": {
+                    "directReference": {
+                    "structField": {
+                        "field": 0
+                    }
+                    }
+                }
+                }]
+            }],
+            "measures": [{
+                "measure": {
+                "functionReference": 0,
+                "arguments": [{
+                    "value": {
+                    "selection": {
+                        "directReference": {
+                        "structField": {
+                            "field": 1
+                        }
+                        }
+                    }
+                    }
+                }],
+                "sorts": [],
+                "phase": "AGGREGATION_PHASE_INITIAL_TO_RESULT",
+                "invocation": "AGGREGATION_INVOCATION_ALL",
+                "outputType": {
+                    "i64": {}
+                }
+                }
+            }]
+            }
+        }
+        }],
+        "extensionUris": [{
+        "extension_uri_anchor": 0,
+        "uri": "AGGREGATE_URI_PLACEHOLDER"
+        }],
+        "extensions": [{
+        "extension_function": {
+            "extension_uri_reference": 0,
+            "function_anchor": 0,
+            "name": "count"
+        }
+        }]
+    }
+    """
+
+    file_name = "read_agg_data.arrow"
+    table = pa.Table.from_arrays([[1, 2, 3, 2, 3, 1, 1],
+                                  [10, 20, 30, 40, 50, 60, 70],
+                                  [3, 4, 5, 1, 2, 0, 20]],
+                                 names=['A', 'B', 'C'])
+    path = _write_dummy_data_to_disk(tmpdir, file_name, table)
+
+    query_with_path = substrait_query.replace("FILENAME_PLACEHOLDER", path)
+    query_with_ext_uri = query_with_path.replace(
+        "AGGREGATE_URI_PLACEHOLDER", _kAggregateURI)

Review Comment:
   This is part of the Substrait query, right? You would stil have to reference it AFAIK.



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