Skip to content

bigfunctions > min_value

min_value

Call or Deploy min_value ?

✅ You can call this min_value bigfunction directly from your Google Cloud Project (no install required).

  • This min_value function is deployed in bigfunctions GCP project in 39 datasets for all of the 39 BigQuery regions. You need to use the dataset in the same region as your datasets (otherwise you may have a function not found error).
  • Function is public, so it can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • You may prefer to deploy the BigFunction in your own project if you want to build and manage your own catalog of functions. This is particularly useful if you want to create private functions (for example calling your internal APIs). Discover the framework

Public BigFunctions Datasets:

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...

Description

Signature

min_value(arr)

Description

Return min value of array (inspired from sql-snippets repo)

Examples

select bigfunctions.eu.min_value([1, 4, 3])
select bigfunctions.us.min_value([1, 4, 3])
select bigfunctions.europe_west1.min_value([1, 4, 3])
+-------+
| value |
+-------+
| 1     |
+-------+

Need help using min_value?

The community can help! Engage the conversation on Slack

For professional suppport, don't hesitate to chat with us.

Found a bug using min_value?

If the function does not work as expected, please

  • report a bug so that it can be improved.
  • or open the discussion with the community on Slack.

For professional suppport, don't hesitate to chat with us.

Use cases

You have a table of products, and each product has an array of prices representing its price history. You want to find the lowest price ever recorded for each product.

WITH Products AS (
    SELECT
        'Product A' AS product_name,
        [10, 12, 8, 15, 9] AS prices
    UNION ALL
    SELECT
        'Product B' AS product_name,
        [20, 18, 18, 19, 21] AS prices
    UNION ALL
    SELECT
        'Product C' AS product_name,
        [5, 7, 5, 6, 4] AS prices
)
SELECT
    product_name,
    bigfunctions.us.min_value(prices) AS min_price
FROM Products;

This query would utilize the min_value function to efficiently determine the minimum value within the prices array for each product, effectively identifying the historical lowest price. You would replace bigfunctions.us with the appropriate dataset for your region.

Spread the word

BigFunctions is fully open-source. Help make it a success by spreading the word!

Share on Add a on