|
| 1 | +# Array type |
| 2 | + |
| 3 | +Arrays provide a convenient way to represent a sequence of values of the same |
| 4 | +type. |
| 5 | + |
| 6 | +## Basics |
| 7 | + |
| 8 | +### Building an array |
| 9 | + |
| 10 | +```{literalinclude} ../../rbc/tests/heavydb/test_howtos.py |
| 11 | +:language: python |
| 12 | +:caption: from ``test_udf_array`` of ``rbc/tests/heavydb/test_howtos.py`` |
| 13 | +:start-after: magictoken.udf.array.new.begin |
| 14 | +:end-before: magictoken.udf.array.new.end |
| 15 | +:dedent: 4 |
| 16 | +:linenos: |
| 17 | +``` |
| 18 | + |
| 19 | +:::{dropdown} Example SQL Query |
| 20 | + |
| 21 | +```{literalinclude} ../../rbc/tests/heavydb/test_howtos.py |
| 22 | +:language: python |
| 23 | +:caption: from ``test_geopoint`` of ``rbc/tests/heavydb/test_howtos.py`` |
| 24 | +:start-after: magictoken.udf.array.new.sql.begin |
| 25 | +:end-before: magictoken.udf.array.new.sql.end |
| 26 | +:dedent: 4 |
| 27 | +:linenos: |
| 28 | +``` |
| 29 | + |
| 30 | +::: |
| 31 | + |
| 32 | + |
| 33 | +### Computing the length of an array |
| 34 | + |
| 35 | +```{literalinclude} ../../rbc/tests/heavydb/test_howtos.py |
| 36 | +:language: python |
| 37 | +:caption: from ``test_udf_array`` of ``rbc/tests/heavydb/test_howtos.py`` |
| 38 | +:start-after: magictoken.udf.array.length.begin |
| 39 | +:end-before: magictoken.udf.array.length.end |
| 40 | +:dedent: 4 |
| 41 | +:linenos: |
| 42 | +``` |
| 43 | + |
| 44 | +:::{dropdown} Example SQL Query |
| 45 | + |
| 46 | +```{literalinclude} ../../rbc/tests/heavydb/test_howtos.py |
| 47 | +:language: python |
| 48 | +:caption: from ``test_geopoint`` of ``rbc/tests/heavydb/test_howtos.py`` |
| 49 | +:start-after: magictoken.udf.array.length.sql.begin |
| 50 | +:end-before: magictoken.udf.array.length.sql.end |
| 51 | +:dedent: 4 |
| 52 | +:linenos: |
| 53 | +``` |
| 54 | + |
| 55 | +::: |
| 56 | + |
| 57 | +### Using the [array_api](https://data-apis.org/array-api/2022.12/) |
| 58 | + |
| 59 | +RBC partially implements the array api standard. For a list of supported |
| 60 | +functions, check the [API](API) page. |
| 61 | + |
| 62 | +```{literalinclude} ../../rbc/tests/heavydb/test_howtos.py |
| 63 | +:language: python |
| 64 | +:caption: from ``test_udf_array`` of ``rbc/tests/heavydb/test_howtos.py`` |
| 65 | +:start-after: magictoken.udf.array.array_api.begin |
| 66 | +:end-before: magictoken.udf.array.array_api.end |
| 67 | +:dedent: 4 |
| 68 | +:linenos: |
| 69 | +``` |
| 70 | + |
| 71 | +:::{dropdown} Example SQL Query |
| 72 | + |
| 73 | +```{literalinclude} ../../rbc/tests/heavydb/test_howtos.py |
| 74 | +:language: python |
| 75 | +:caption: from ``test_geopoint`` of ``rbc/tests/heavydb/test_howtos.py`` |
| 76 | +:start-after: magictoken.udf.array.array_api.sql.begin |
| 77 | +:end-before: magictoken.udf.array.array_api.sql.end |
| 78 | +:dedent: 4 |
| 79 | +:linenos: |
| 80 | +``` |
| 81 | + |
| 82 | +::: |
0 commit comments