ANY (Lakehouse v1)
Aggregate function.
The ANY() function selects the first encountered (non-NULL) value, unless all rows have NULL values in that column. The query can be executed in any order and even in a different order each time, so the result of this function is indeterminate. To get a determinate result, you can use the ‘min’ or ‘max’ function instead of ‘any’.
Analyze Syntax
Section titled “Analyze Syntax”func.any(<expr>)Analyze Examples
Section titled “Analyze Examples”func.any(table.product_name).alias('any_product_name')
| any_product_name ||------------------|| Laptop |SQL Syntax
Section titled “SQL Syntax”ANY(<expr>)Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<expr> | Any expression |
Return Type
Section titled “Return Type”The first encountered (non-NULL) value, in the type of the value. If all values are NULL, the return value is NULL.
SQL Examples
Section titled “SQL Examples”Create a Table and Insert Sample Data
CREATE TABLE product_data ( id INT, product_name VARCHAR NULL, price FLOAT NULL);
INSERT INTO product_data (id, product_name, price)VALUES (1, 'Laptop', 1000), (2, NULL, 800), (3, 'Keyboard', NULL), (4, 'Mouse', 25), (5, 'Monitor', 150);Query Demo: Retrieve the First Encountered Non-NULL Product Name
SELECT ANY(product_name) AS any_product_nameFROM product_data;Result
| any_product_name ||------------------|| Laptop |