Skip to content

Commit a65c120

Browse files
authored
Add bytearray_function documentation
1 parent c000f5c commit a65c120

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/reference/dune-v2/query-engine.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ The byte array conversion functions throw an overflow exception if the byte arra
6969
[Here is an example query](https://dune.com/queries/1847704?d=11) that covers all of the above functions.
7070

7171

72+
## Byte Array Functions in Dune SQL
73+
74+
Dune SQL currently represents byte arrays as `0x`-prefixed strings. In the future we will represent byte arrays using the `varbinary`. To make it simpler to work with byte arrays we have the following helper functions. They simplify interactions with byte arrays, as they automatically account for the `0x`-prefix and use byte index instead of characther index. For instance, the `bytearray_substring` methods take indexes by byte, not by characther (twice the byte array length). If there is an operation you need to do on byte arrays which is not covered by a function in the list below you should reach out to the Dune team.
75+
76+
| Function | Return Type | Argument Types | Description |
77+
| --- | --- | --- | --- |
78+
| bytearray_concat | varchar | varchar, varchar | Concatenates two byte arrays |
79+
| bytearray_length | bigint | varchar | Returns the length of a byte array |
80+
| bytearray_ltrim | varchar | varchar | Removes zero bytes from the beginning of a byte array |
81+
| bytearray_position | bigint | varchar, varchar | Returns the index of a given bytearray (or 0 if not found) |
82+
| bytearray_replace | varchar | varchar, varchar, varchar | Greedily replaces occurrences of a pattern within a byte array |
83+
| bytearray_reverse | varchar | varchar | Reverse a given byte array |
84+
| bytearray_rtrim | varchar | varchar | Removes zero bytes from the end of a byte array |
85+
| bytearray_starts_with | boolean | varchar, varchar | Determines whether a byte array starts with a prefix |
86+
| bytearray_substring | varchar | varchar, integer | Suffix byte array starting at a given index |
87+
| bytearray_substring | varchar | varchar, integer, integer | Sub byte array of given length starting at an index |
88+
89+
7290
## Query queries as views in Dune SQL
7391

7492
All queries written using Dune SQL can be queried as views in other queries using the identifier `query_<queryId>`. For instance:

0 commit comments

Comments
 (0)