Skip to content

bigfunctions > is_public_holiday

is_public_holiday

Call or Deploy is_public_holiday ?

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

  • This is_public_holiday 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

is_public_holiday(date, country_code)

Description

Return true if date corresponds to a public holiday in country_code

  • Always return false if date is not between year 1974 and year 2076.
  • country_code must be among [AO, AR, AW, AU, AT, AZ, BD, BY, BE, BO, BW, BR, BG, BI, CA, CL, CN, CO, HR, CU, CW, CY, CZ, DK, DJ, DO, EG, EE, ET, FI, FR, GE, DE, GR, HN, HK, HU, IS, IN, IE, IL, IT, JM, JP, KZ, KE, KR, LV, LS, LT, LU, MG, MW, MY, MT, MX, MD, MA, MZ, NA, NL, NZ, NI, NG, MK, NO, PY, PE, PL, PT, RO, RU, SA, RS, SG, SK, SI, ZA, ES, SZ, SE, CH, TW, TN, TR, UA, AE, GB, US, UY, UZ, VE, VN, ZM, ZW]
  • Holiday dates come from python-holidays.

Examples

select bigfunctions.eu.is_public_holiday(date('2022-07-14'), 'FR')
select bigfunctions.us.is_public_holiday(date('2022-07-14'), 'FR')
select bigfunctions.europe_west1.is_public_holiday(date('2022-07-14'), 'FR')
+-------------------+
| is_public_holiday |
+-------------------+
| true              |
+-------------------+

Need help using is_public_holiday?

The community can help! Engage the conversation on Slack

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

Found a bug using is_public_holiday?

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

A common use case for the is_public_holiday function is adjusting business metrics or forecasts based on public holiday occurrences.

Scenario: An e-commerce company wants to analyze daily sales data and understand the impact of public holidays on sales performance.

Implementation using is_public_holiday:

SELECT
    order_date,
    total_sales,
    bigfunctions.YOUR_REGION.is_public_holiday(order_date, 'US') AS is_public_holiday_us -- Replace YOUR_REGION with your BigQuery region
  FROM
    `your_project.your_dataset.sales_data`
  WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31';

Explanation:

  1. The query retrieves order_date and total_sales from the sales_data table.
  2. It then uses the is_public_holiday function to determine whether each order_date falls on a public holiday in the US. The region for bigfunctions should be replaced with your BigQuery region (e.g. bigfunctions.us, bigfunctions.eu).
  3. The result includes a new column is_public_holiday_us indicating whether each date is a public holiday (true/false).

Further analysis:

Having this information, the company can:

  • Compare sales: Compare sales figures on public holidays versus regular days to quantify the impact. They might see lower sales on some holidays (e.g., Christmas, when stores might be closed) and higher sales on others (e.g., Black Friday).
  • Adjust forecasts: Use the historical holiday data to improve sales forecasting accuracy by accounting for the expected impact of upcoming public holidays. For example, they might anticipate increased online sales in the week leading up to a holiday.
  • Identify trends: Identify any specific product categories or customer segments that are particularly affected by public holidays.
  • Optimize marketing campaigns: Plan and execute targeted marketing campaigns around public holidays, taking into account predicted sales fluctuations.

This is just one example. The is_public_holiday function can be useful in various other scenarios involving date analysis, such as:

  • Supply chain management: Predicting potential delays due to public holidays in different countries.
  • Human resources: Calculating employee working hours, considering public holidays.
  • Financial analysis: Understanding market behavior around public holidays.

By integrating the is_public_holiday function into BigQuery queries, businesses can gain valuable insights and make more informed decisions based on a better understanding of the influence of public holidays on their operations.

Spread the word

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

Share on Add a on