parse_useragent - BigQuery

Function

parse_useragent(useragent)

Description

Parse Useragent - Parses the details from a <useragent> string.

Example Query


SELECT `justfunctions.eu.parse_useragent`("Mozilla/5.0 (iPad; CPU OS 12_5_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1")
                                            
/*--Output--
name : Mobile Safari | browser.version : 12.1.2 | browser.major : 12 | engine.name : WebKit | engine.version : 605.1.15 | os.name : iOS | os.version : 12.5.7 | device.vendor : Apple | device.model : iPad | device.type : tablet | arch : null
*/

Statement

CREATE OR REPLACE FUNCTION `your_project_id.your_dataset_id.parse_useragent`(`useragent` STRING) RETURNS STRUCT<
browser STRUCT<name STRING, version STRING, major STRING>,
engine  STRUCT<name STRING, version STRING>,
os      STRUCT<name STRING, version STRING>,
device  STRUCT<vendor STRING, model STRING, type STRING>,
arch    STRING
>

	LANGUAGE js AS r'''let a = UAParser(useragent);
a.arch = a.cpu.architecture;
return a;
''' OPTIONS ( description = '''Parses the details from a <useragent> string.'''  , library = [  "gs://justfunctions/bigquery-functions/ua-parser.min.js" ]  )

Regions

justfunctions.eu.parse_useragent(useragent),
justfunctions.us.parse_useragent(useragent)

Type

JavaScript User Defined Function (JavaScript UDF)

How to Use

Frequently Asked Questions

User-Defined Functions (UDFs) in Google BigQuery are custom functions that you can create to perform operations that aren't available through the standard SQL functions. These UDFs allow you to extend BigQuery's SQL capabilities to suit your specific data processing needs. JustFunctions is a collection of open-source user-defined functions (UDFs).

JustFunctions is a collection of open-source User-Defined Functions (UDFs) designed to extend the capabilities of Google BigQuery. These functions cover a wide range of applications, including text manipulation, URL processing, date processing, email handling, similarity measures, and more. Moreover, JustFunctions is frequently updated to include more use cases.

We welcome any feedback or questions you may have. You can Contact us or report an issue on Github.

Functions and procedures from JustFunctions can be used directly in any of your projects.
To start, simply click 👆 on any function,  Copy  the 'Example Query' and run it in your BigQuery console.
You can also  Copy  the 'Statement' to create your own private user-defined function.

Yes, JustFunctions is completely free to use.

Yes, currently JustFunctions is only available for Google BigQuery. In the future, we will also support PostgreSQL.

See something wrong? Contact us or report an issue on Github.