You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
I edited a draft document at the request of @amitkdutta and @kgpai to
help prepare that document for publication as the blog post [Presto vs
Prestissimo – Known differences and
workarounds](https://prestodb.io/blog/2026/01/22/presto-vs-prestissimo-known-differences-and-workarounds/).
I thought the content in the blog post was valuable and should be added
to the Presto documentation. In this PR I have revised the blog post to
follow the format and style of Presto documentation to add to the Presto
docs.
Following feedback I incorporated the content of the blog post into
[presto_cpp/limitations.rst](https://github.com/prestodb/presto/blob/master/presto-docs/src/main/sphinx/presto_cpp/limitations.rst).
## Motivation and Context
Improves Presto documentation of Presto C++, helping readers to be aware
of limitations when running Presto queries in C++, and advise how to
rewrite Presto queries to run successfully in Presto C++.
## Impact
Documentation.
## Test Plan
Local doc builds.
## Contributor checklist
- [ ] Please make sure your submission complies with our [contributing
guide](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md),
in particular [code
style](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#code-style)
and [commit
standards](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-standards).
- [ ] PR description addresses the issue accurately and concisely. If
the change is non-trivial, a GitHub Issue is referenced.
- [ ] Documented new properties (with its default value), SQL syntax,
functions, or other functionality.
- [ ] If release notes are required, they follow the [release notes
guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines).
- [ ] Adequate tests were added if applicable.
- [ ] CI passed.
- [ ] If adding new dependencies, verified they have an [OpenSSF
Scorecard](https://securityscorecards.dev/#the-checks) score of 5.0 or
higher (or obtained explicit TSC approval for lower scores).
## Release Notes
Please follow [release notes
guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines)
and fill in the release notes below.
```
== RELEASE NOTES ==
General Changes
* Add documentation for Presto queries to run in Presto C++ to :doc:`/presto_cpp/limitations`.
```
## Summary by Sourcery
Documentation:
- Introduce a Presto C++ queries documentation page covering known
behavioral differences and recommended query workarounds.
Co-authored-by: Amit Dutta <amit.kolorob@gmail.com>
Co-authored-by: Krishna Pai <kgpai@meta.com>
Copy file name to clipboardExpand all lines: presto-docs/src/main/sphinx/presto_cpp/limitations.rst
+360-3Lines changed: 360 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ Presto C++ Limitations
7
7
:backlinks: none
8
8
:depth: 1
9
9
10
+
10
11
General Limitations
11
12
===================
12
13
@@ -38,13 +39,369 @@ The C++ evaluation engine has a number of limitations:
38
39
* The reserved pool is not supported.
39
40
* In general, queries may use more memory than they are allowed to through memory arbitration. See `Memory Management <https://facebookincubator.github.io/velox/develop/memory.html>`_.
40
41
42
+
41
43
Functions
42
44
=========
43
45
44
-
reduce_agg
45
-
----------
46
46
47
+
Aggregate Functions
48
+
-------------------
49
+
50
+
reduce_agg
51
+
^^^^^^^^^^
47
52
In C++ based Presto, ``reduce_agg`` is not permitted to return ``null`` in either the
48
53
``inputFunction`` or the ``combineFunction``. In Presto (Java), this is permitted
49
54
but undefined behavior. For more information about ``reduce_agg`` in Presto,
50
-
see `reduce_agg <../functions/aggregate.html#reduce_agg>`_.
55
+
see `reduce_agg <../functions/aggregate.html#reduce_agg>`_.
56
+
57
+
reduce lambda
58
+
^^^^^^^^^^^^^
59
+
For the reduce lambda function, the array size is controlled by the session property
60
+
``native_expression_max_array_size_in_reduce``, as it is inefficient to support such
61
+
cases for arbitrarily large arrays. This property is set at ``100K``. Queries that
62
+
fail due to this limit must be revised to meet this limit.
63
+
64
+
65
+
Array Functions
66
+
---------------
67
+
68
+
Array sort with lambda comparator
69
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70
+
``Case`` is not supported for the lambda comparator. Use ``If`` Instead. The following
71
+
example is not supported in Presto C++:
72
+
73
+
.. code-block:: sql
74
+
75
+
(x, y) ->
76
+
CASE
77
+
WHEN x.event_time < y.event_time THEN
78
+
-1
79
+
WHEN x.event_time > y.event_time THEN
80
+
1
81
+
ELSE 0
82
+
END
83
+
84
+
To work with Presto C++, the best option is to use transform lambda whenever possible.
85
+
For example:
86
+
87
+
.. code-block:: sql
88
+
89
+
(x) -> x.event_time
90
+
91
+
Or, rewrite using ``if`` as in the following example:
92
+
93
+
.. code-block:: sql
94
+
95
+
(x, y) -> IF (x.event_time < y.event_time, -1,
96
+
IF (x.event_time > y.event_time, 1, 0))
97
+
98
+
When using ``If``, follow these rules when using a lambda in array sort:
99
+
100
+
* The lambda should use ``if else``. Case is not supported.
101
+
* The lambda should return ``1``, ``0``, ``-1``. Cover all the cases.
102
+
* The lambda should use the same expression when doing the comparison.
103
+
For example, in the above case ``event_time`` is used for comparison throughout the lambda.
104
+
If we rewrote the expression as following, where ``x`` and ``y`` have different fields, it will fail:
105
+
``(x, y) -> if (x.event_time < y.event_start_time, -1, if (x.event_time > y.event_start_time, 1, 0))``
106
+
* Any additional nesting other than the two ``if`` uses shown above will fail.
107
+
108
+
``Array_sort`` can support any transformation lambda that returns a comparable type.
109
+
This example is not supported in Presto C++:
110
+
111
+
.. code-block:: sql
112
+
113
+
"array_sort"("map_values"(m), (a, b) -> (
114
+
CASE WHEN (a[1] [2] > b[1] [2]) THEN 1
115
+
WHEN (a[1] [2] < b[1] [2]) THEN -1
116
+
WHEN (a[1] [2] = b[1] [2]) THEN
117
+
IF((a[3] > b[3]), 1, -1) END)
118
+
119
+
To run in Presto C++, rewrite the query as shown in this example:
0 commit comments