Returns a random universally unique identifier (UUID) as a STRING.
The returned STRING consists of 32 hexadecimal
digits in five groups separated by hyphens in the form 8-4-4-4-12. The
hexadecimal digits represent 122 random bits and 6 fixed bits, in compliance
with RFC 4122 section 4.4.
The returned STRING is lowercase.
Takes an expression and gets the name of the data type for that
expression.
Return type
STRING
Examples
The following example produces the name of the data type for the expression
passed into the TYPEOF function. When NULL is passed in, the
supertype, INT64, is produced.
SELECTTYPEOF(NULL)ASA,TYPEOF('hello')ASB,TYPEOF(12+1)ASC,TYPEOF(4.7)ASD/*-------+--------+-------+--------* | A | B | C | D | +-------+--------+-------+--------+ | INT64 | STRING | INT64 | FLOAT64 | *-------+--------+-------+--------*/
The following example produces the name of the data type for field y in a
struct.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eGoogleSQL for BigQuery offers utility functions, including one for generating UUIDs.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGENERATE_UUID\u003c/code\u003e function creates a random universally unique identifier (UUID).\u003c/p\u003e\n"],["\u003cp\u003eThe UUID is returned as a \u003ccode\u003eSTRING\u003c/code\u003e with 32 hexadecimal digits in a specific format, following RFC 4122 standards.\u003c/p\u003e\n"],["\u003cp\u003eThe output of \u003ccode\u003eGENERATE_UUID\u003c/code\u003e will always be lowercase.\u003c/p\u003e\n"]]],[],null,["# Utility functions\n\nGoogleSQL for BigQuery supports the following utility functions.\n\nFunction list\n-------------\n\n`GENERATE_UUID`\n---------------\n\n GENERATE_UUID()\n\n**Description**\n\nReturns a random universally unique identifier (UUID) as a `STRING`.\nThe returned `STRING` consists of 32 hexadecimal\ndigits in five groups separated by hyphens in the form 8-4-4-4-12. The\nhexadecimal digits represent 122 random bits and 6 fixed bits, in compliance\nwith [RFC 4122 section 4.4](https://tools.ietf.org/html/rfc4122#section-4.4).\nThe returned `STRING` is lowercase.\n\n**Return Data Type**\n\nSTRING\n\n**Example**\n\nThe following query generates a random UUID. \n\n SELECT GENERATE_UUID() AS uuid;\n\n /*--------------------------------------*\n | uuid |\n +--------------------------------------+\n | 4192bff0-e1e0-43ce-a4db-912808c32493 |\n *--------------------------------------*/\n\n`TYPEOF`\n--------\n\n TYPEOF(expression)\n\n**Description**\n\nTakes an expression and gets the name of the data type for that\nexpression.\n\n**Return type**\n\n`STRING`\n\n**Examples**\n\nThe following example produces the name of the data type for the expression\npassed into the `TYPEOF` function. When `NULL` is passed in, the\n[supertype](/bigquery/docs/reference/standard-sql/conversion_rules#supertypes), `INT64`, is produced. \n\n SELECT\n TYPEOF(NULL) AS A,\n TYPEOF('hello') AS B,\n TYPEOF(12+1) AS C,\n TYPEOF(4.7) AS D\n\n /*-------+--------+-------+--------*\n | A | B | C | D |\n +-------+--------+-------+--------+\n | INT64 | STRING | INT64 | FLOAT64 |\n *-------+--------+-------+--------*/\n\nThe following example produces the name of the data type for field `y` in a\nstruct. \n\n SELECT\n TYPEOF(STRUCT\u003cx INT64, y STRING\u003e(25, 'apples')) AS struct_type,\n TYPEOF(STRUCT\u003cx INT64, y STRING\u003e(25, 'apples').y) AS field_type;\n\n /*---------------------------+------------*\n | struct_type | field_type |\n +---------------------------+------------+\n | STRUCT\u003cx INT64, y STRING\u003e | STRING |\n *---------------------------+------------*/\n\nThe following example produces the name of the data type for elements in an\narray. \n\n SELECT\n TYPEOF(ARRAY\u003cINT64\u003e[25, 32]) AS array_type,\n TYPEOF(ARRAY\u003cINT64\u003e[25, 32][0]) AS element_type;\n\n /*--------------+--------------*\n | array_type | element_type |\n +--------------+--------------+\n | ARRAY\u003cINT64\u003e | INT64 |\n *--------------+--------------*/"]]