Chapter 3. Data Types, Functions, and Operators
In the bike rental queries in the previous chapters, when we divided the trip duration by 60, we were able to do so because trip duration was a numeric type. Trying to divide the gender by 60 would not have worked because gender is a string. The functions and operations you have at your disposal might be restricted based on the type of data to which you are applying them.
BigQuery supports several data types to store numeric, string, time, geographic, structured, and semi-structured data:
INT64
- This is the only integer type. It can represent numbers ranging from approximately 10–19 to 1019. For real-valued numbers, use
FLOAT64
, and for Booleans, useBOOL
. NUMERIC
NUMERIC
offers 38 digits of precision and 9 decimal digits of scale and is suitable for exact calculations, such as in finance.STRING
- This is a first-class type and represents variable-length sequences of Unicode characters.
BYTES
are variable-length sequences of characters (not Unicode). TIMESTAMP
- This represents an absolute point in time.
DATETIME
- This represents a calendar date and time.
DATE
andTIME
are also available separately. GEOGRAPHY
GEOGRAPHY
represents points, lines, and polygons on the surface of the Earth.STRUCT
andARRAY
- See the description for each of these in Chapter 2.
Numeric Types and Functions
As just stated, there is only one integer type (INT64
) and only one floating-point type (FLOAT64
). Both of these types support the typical arithmetic operations ...
Get Google BigQuery: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.