BigFunctionsΒΆ
BigFunctions are open-source BigQuery routines that give you SQL-superpowers in BigQuery πͺ.
β You can call ANY of the following public BigFunctions from your Google Cloud Project (no install).
- The functions are deployed in
bigfunctions
GCP project in 39 datasets for all of the 39 BigQuery regions. - They are public, so they can be called by anyone.
- For any question or difficulties, please read Getting Started.
- If you prefer to deploy the BigFunction in your own project, read Getting Started.
- Found a bug? Please raise an issue here
All BigFunctions Datasets >
Region | Dataset |
---|---|
{% for dataset in dataset.split(',') -%} | |
{{ dataset.replace('_', '-') }} |
{{ project }}.{{ dataset }} |
{% endfor %} |
π§ AIΒΆ
ask_ai(prompt, model)
: Ask Anything!ask_appstore_reviews(prompt, app_url_in_appstore)
: Ask AI what your app users think.ask_my_data(question, fully_qualified_table)
: Ask your data anyquestion
in natural language.categorize(items)
: Categorizeitems
in categories and subcategories.classify_text(text, candidate_labels)
: Classifytext
amongcandidate_labels
generate_categories(items)
: Returncategories
ofitems
.generate_face_embedding(image_url)
: Detect Face on image and Generate its Embeddinggenerate_sql(question, fully_qualified_table)
: Transformquestion
to a SQL query.
π¬ NotifyΒΆ
send_google_chat_message(message, webhook_url)
: Sendsmessage
to google chat spacesend_mail(to, subject, content, attachment_filename, attachment_content)
: Sends an emailsend_mail_with_excel(to, subject, content, excel_filename, table_or_view_or_query)
: Sends an email withtable_or_view_or_query
data attached as excel filesend_slack_message(message, webhook_url)
: Sendsmessage
to a slack channel.send_sms(message, phone_number)
: Sendsmessage
via SMS tophone_number
send_teams_message(message, webhook_url)
: Sendsmessage
to a Microsoft Teams channel.
π’ Get DataΒΆ
exchange_rate(base, to)
: Getexchange_rate
faker(what, locale)
: Generates fake dataget(url, headers)
: Requesturl
get_appstore_reviews(url)
: GET Apple App Store Reviews of an appget_github_data(public_repo, destination_dataset, streams)
: Get data frompublic_repo
intodestination_dataset
get_google_trends(keywords, category, timeframe, geo, gprop)
: GET Google Trends dataget_json(url, headers)
: GET jsondata
fromurl
get_meteo(latitude, longitude, date)
: Getmeteo
get_playstore_reviews(app_id, country, language)
: GET Google Play Store Reviews of an appget_transport_emissions(distance_km)
: Get the transport CO2 emissions given thedistance_km
get_webpage_data(prompt, url)
: Extractdata
fromurl
usingprompt
get_webpage_metadata(url)
: Get webpage metadataget_webpage_structured_data(url)
: Get webpage Structured Datalist_public_datasets()
: Returns list of BigQuerypublic_datasets
load_api_data(source, source_config, streams, destination_dataset)
: Load data from 250+ sources using Airbyte Python Connectorsload_api_data_into_temp_dataset(source, source_config, streams, state)
: Load data from 250+ sources using Airbyte Python Connectorsload_duckdb_database(duckdb_file_url, destination_dataset)
: Download duckdb database intodestination_dataset
load_duckdb_database_into_temp_dataset(duckdb_file_url)
: Download duckdb database into a temp datasetload_file(url, file_type, destination_table, options)
: Download web file intodestination_table
load_file_into_temp_dataset(url, file_type, options)
: Download web file into a temp dataset
π ExportΒΆ
export_table_to_datastore(fully_qualified_table, key_column, datastore_path)
: Exportfully_qualified_table
to datastoreexport_to_datastore(datastore_path, key, data)
: Exportsdata
to Datastoreexport_to_pubsub(project, topic, data, attributes)
: Exportsdata
andattributes
to Pub/Subtopic
.post(url, data, headers)
: POSTdata
tourl
.upload_table_to_gsheet(table_or_view_or_query, max_rows, spreadsheet_url, worksheet_name, write_mode)
: Upload data fromtable_or_view_or_query
to Google Sheetupload_to_gsheet(data, spreadsheet_url, worksheet_name, write_mode)
: Uploaddata
(a json array of objects) to a Google Sheet
π¨ Trigger EventΒΆ
refresh_powerbi(dataset_id, workspace_id, tenant_id, app_id, token_secret, custom_refresh_param)
: Refresh a Power BI dataset (semantic model)refresh_tableau(workbook_or_datasource_title, site, server, token_name, token_secret)
: Refresh a tableau datasource or workbook
1οΈβ£ Transform NumericΒΆ
format_percentage(first_number, second_number, nb_decimals)
: Returnfirst_number / second_number
as a formatted percentagequantize_into_bins(value, bin_bounds)
: Get thebin_range
in which belongsvalue
quantize_into_bins_with_labels(value, bin_bounds, labels)
: Get thelabel
of the bin in which belongsvalue
quantize_into_fixed_width_bins(value, min_bound, max_bound, nb_bins)
: Get thebin_range
in which belongsvalue
weighted_average(element, weight)
: Returns the weigthed average elements.
β¨ Transform StringΒΆ
camel2snake(camelCaseString)
: Convertstring
from camelCase to snake_caseconvert_non_ascii_characters_to_unicode_escape_sequences(text)
: Replace all non ASCII characters with escape unicodedeidentify(text, info_types)
: Masks sensitive information of typeinfo_types
intext
detect_sensitive_info(text)
: Detect sensitive information intext
ip2asn(ip)
: Getasn
ofip
ip2continent(ip)
: Getcontinent_code
ofip
ip2continent_name(ip)
: Getcontinent
ofip
ip2country(ip)
: Getcountry_code
ofip
ip2country_name(ip)
: Getcountry_name
ofip
ip_range2ip_networks(first_ip, last_ip)
: Convert an IP range into a json list of IP networks in CIDR notationis_email_valid(email)
: Return true ifemail
is validis_phone_number_valid(phone_number, options)
: Return ifphone_number
is validmarkdown2html(markdown)
: Convertmarkdown
tohtml
ngram_frequency_similarity(string1, string2, n)
: Calculates n-gram similarity between two stringsparse_url(url)
: Returnurl
partsparse_user_agent(user_agent_string)
: Parses User Agent strings into several componentsphone_number_info(phone_number, options)
: Getphone_number
inforemove_accents(str)
: Remove accentsremove_extra_whitespaces(str)
: Remove unwanted whitespacesremove_strings(string, strings_to_remove)
: Remove any string ofstrings_to_remove
fromstring
remove_words(string, words_to_remove)
: Remove any word ofwords_to_remove
fromstring
render_handlebars_template(template, context)
: Render template with context using handlebars.js templating libraryrender_template(template, context)
: Render template with context using nunjucks.js templating libraryreplace_special_characters(string, replacement)
: Replace most common special characters in astring
withreplacement
translate(text, target_language)
: Translatetext
intotarget_language
url_decode(url_encoded_string)
: Decodeurl_encoded_string
xml_extract(xml, x_path)
: Returns content extracted from XML from given XPATH
π Transform Geo DataΒΆ
geocode(address)
: Getaddress
details from Google Mapsh3(function_name, arguments)
: Wrapper around Uber H3reverse_geocode(latitude, longitude)
: Get address details atlatitude
,longitude
validate_address(address)
: Validateaddress
using Google Maps
π Transform DateΒΆ
date_sub_isoyear(date, years)
: Returns same dayyears
beforegenerate_dates(start_date, end_date)
: Generate a table of datesgregorian2hijri(gregorian_date)
: Convert Gregorian Date to Hijri Date (taken from here)is_public_holiday(date, country_code)
: Return true ifdate
corresponds to a public holiday incountry_code
parse_date(date_string)
: Parse date with automatic format detectiontranslated_month_name(date, language)
: Gettranslated_month_name
translated_weekday_name(date, language)
: Gettranslated_weekday_name
{...} Transform JsonΒΆ
create_materialized_view_w_flattened_json_column(fully_qualified_table, fully_qualified_materialized_view, json_column)
: Create a Materialized view of a table withjson_column
flatteneditems2json(key_value_items)
: Returnsjson
object from array ofkey_value_items
json_column_schema(data)
: Returns the schema of a json columnjson_items(json_string)
: Extractkey_value_items
fromjson_string
json_keys(json_string)
: Extractkeys
fromjson_string
json_merge(json_string1, json_string2)
: Mergejson_string1
andjson_string2
json_query(json_string, query)
: Extract data fromjson_string
using advanced json queryingjson_schema(data)
: Returns the schema ofdata
json_values(json_string)
: Extractvalues
fromjson_string
sql_to_flatten_json_column(data, fully_qualified_column)
: Generate the SQL to flatten a jsoncolumn
[...] Transform ArrayΒΆ
are_arrays_equal(array1, array2)
: Return true ifarray1
=array2
array_intersect(array1, array2)
: Returns the intersection of two arrays.array_union(array1, array2)
: Returns the union of two arrays.benford_distance(values)
: Calculate the distance from Benford's Law for givenvalues
.distinct_values(arr)
: Return distinct valuesfind_greater_value(arr, x)
: Return theoffset
(zero-based index) of the firstvalue
inarr
wherevalue >= x
find_lower_value(arr, x)
: Return theoffset
(zero-based index) of the firstvalue
inarr
wherevalue <= x
find_value(arr, value)
: Return the firstoffset
(zero-based index) ofvalue
in arrayarr
frequent_values(values, frequency_threshold)
: Returnsfrequent_values
among array ofvalues
get_value(key_value_items, search_key)
: Return the firstvalue
with a keysearch_key
fromkey_value_items
last_value(arr)
: Return last value of arraymax_value(arr)
: Return max value of arraymedian_value(arr)
: Return median value of arraymin_max_scaler(arr)
: Performs min-max scaling on an array.min_value(arr)
: Return min value of arraypercentile_value(arr, percentile)
: Returns percentile of an array with percentile a float in range [0, 1].rare_values(values, frequency_threshold)
: Returnsrare_values
among array ofvalues
remove_value(arr, value)
: Return an array with all values exceptvalue
.sort_values(arr)
: Return sorted array (ascending)sort_values_desc(arr)
: Return sorted array (descending)sum_values(arr)
: Return the sum of array valuesz_scores(arr)
: Computez_scores
π§ Machine LearningΒΆ
precision_recall_auc(predictions)
: Returns the Area Under the Precision Recall Curve (a.k.a. AUC PR)precision_recall_curve(predictions)
: Returns the Precision-Recall Curveprophet(records, periods, kwargs)
: Return Time Series Forecast as json using prophetprophet_table(records, periods, kwargs)
: Return Time Series Forecast as table using prophetroc_auc(predictions)
: Returns the Area Under the Receiver Operating Characteristic Curve (a.k.a. ROC AUC)roc_curve(predictions)
: Returns the Receiver Operating Characteristic Curve (a.k.a. ROC Curve)sentiment_score(content)
: Compute sentiment score ofcontent
π GraphΒΆ
connected_components(fully_qualified_table)
: Compute the connected components of a non-directed graph.
π¨ Convert Data FormatΒΆ
html2pdf(html)
: Converthtml
topdf
json2excel(data)
: Dump data to excel filejson2xml(json)
: Returns XML for given JSON stringxml2json(xml)
: Returns JSON as a string for given XML string
π ExploreΒΆ
chart(data, chart_type, ylabel)
: Return html with a chartjs chartexplore_column(fully_qualified_column)
: Show column statisticsexplore_dataset(fully_qualified_dataset)
: Show infos about dataset tablesexplore_table(fully_qualified_table)
: Show table infos and column statisticslist_dataset_tables(fully_qualified_dataset)
: List tables offully_qualified_dataset
sankey_chart(data)
: Return html with a Sankey Google chart
π¨ UtilsΒΆ
deduplicate_rows(query_or_table_or_view)
: Returns the deduplicated rows ofquery_or_table_or_view
get_latest_partition_timestamp(fully_qualified_table)
: Return the maximum of the partition column offully_qualified_table
get_table_columns(fully_qualified_table)
: Get the column information of the given table fromINFORMATION_SCHEMA.COLUMNS
get_view_history(fully_qualified_view)
: Get BigQuery View historylist_scheduled_queries(project)
: Returnsscheduled_queries
of projectproject
.run_python(python_code, requirements, kwargs)
: Run anypython_code
.sleep(seconds)
: Sleep duringseconds
secondstimestamp_from_unix_date_time(unix_date_time, date_time_part)
: Interpretsunix_date_time
as the number ofdate_time_part
since1970-01-01 00:00:00 UTC
.timestamp_to_unix_date_time(timestamp_expression, date_time_part)
: Returns the number ofdate_time_part
since1970-01-01 00:00:00 UTC
.upsert(query_or_table_or_view, destination_table, insertion_mode, primary_keys, recency_field)
: Mergesquery_or_table_or_view
into thedestination_table
.