Array Functions
Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Functions and operators for inspecting, accessing, and transforming array values. Use array functions to:
- Access and inspect array elements by index or search for values.
- Measure and analyze arrays by checking length and finding positions.
- Modify and transform arrays by adding, removing, or deduplicating elements.
- Perform vector operations for similarity searches on embeddings.
Considerations
- 1-based indexing: Array indices start at 1, not 0.
- Element types: Many functions require matching element types between arrays.
- NULL handling: NULL elements are preserved unless explicitly removed with
For more information about supported types, see Array Type.
Access and Inspection
Access array elements and check for content:
Array Building
Create and build arrays:
Array Transformation
Sort and clean up arrays:
Vector and Similarity
Perform vector operations for similarity searches on embeddings:
Examples
Filtering by Array Content
Find products with specific tags.
1SELECT product_name
2FROM products
3WHERE array_contains(tags, 'sale');
Find products matching any search tag.
1SELECT product_name
2FROM products
3WHERE array_contains_any(tags, array['new', 'featured', 'popular']);
Array Manipulation
Build a complete list by combining arrays.
1SELECT array_cat(primary_categories, secondary_categories) AS all_categories
2FROM products;
Clean up arrays by removing nulls and duplicates.
1SELECT array_distinct(array_compact(values)) AS clean_values
2FROM data;
Vector Search
Find top five most similar products using embeddings
1SELECT
2 name,
3 dot_product('[0.1, -0.2, 0.7, -0.3]'::REAL[], description_vec) AS score
4FROM products
5ORDER BY score DESC
6LIMIT 5;
Related Documentation