BigQuery's Main Data Types

Explore the main data types in BigQuery, including Numeric, String, Boolean, Time and Date, Geography, and Other types, and understand their specific uses.
Published
August 12, 2024
Author

What are the Main Data Types in BigQuery?

BigQuery offers a variety of data types to efficiently store and process data. These data types are categorized into Numeric Types, String Types, Boolean Type, Time and Date Types, Geography Types, and Other Data Types.

  • Numeric Types: These represent numerical data and include INTEGER (INT64), NUMERIC (NUMERIC), BIGNUMERIC (BIGNUMERIC), and FLOAT64 (FLOAT).
  • String Types: These represent textual data and include STRING.
  • Boolean Type: This represents logical values and includes BOOLEAN.
  • Time and Date Types: These represent dates, times, and timestamps and include DATE, TIME, DATETIME, and TIMESTAMP.
  • Geography Types: These represent geographic data and include GEOGRAPHY.
  • Other Data Types: BigQuery also supports other data types like ARRAY and STRUCT.

What are Numeric Types in BigQuery?

Numeric Types in BigQuery represent numerical data. They include INTEGER (INT64), NUMERIC (NUMERIC), BIGNUMERIC (BIGNUMERIC), and FLOAT64 (FLOAT).

  • INTEGER (INT64): This is used for whole numbers, for example, -100, 0, 9223372036854775807.
  • NUMERIC (NUMERIC): This is used for high-precision decimal numbers for financial calculations, for example, 12345.678901.
  • BIGNUMERIC (BIGNUMERIC): This is used for arbitrary-precision decimal numbers for very large or precise calculations, commonly used in scientific computing.
  • FLOAT64 (FLOAT): This is used for numbers with a decimal point for representing real numbers, for example, 3.14159, -12.5.

How are String Types Defined in BigQuery?

String Types in BigQuery represent textual data. The STRING data type is used for variable-length sequences of characters.

  • STRING: This is used for variable-length sequences of characters, for example, "Hello, world!", "This is a string".

What is the Boolean Type in BigQuery?

The Boolean Type in BigQuery represents logical values. The BOOLEAN data type is used for True or False values.

  • BOOLEAN: This is used for logical values, either True or False.

What are Time and Date Types in BigQuery?

Time and Date Types in BigQuery represent dates, times, and timestamps. They include DATE, TIME, DATETIME, and TIMESTAMP.

  • DATE: This represents a specific year, month, and day, for example, "2024-06-05".
  • TIME: This represents a time of day, for example, "14:35:00".
  • DATETIME: This combines date and time, for example, "2024-06-05 14:35:00".
  • TIMESTAMP: This represents a point in time with optional microsecond precision, for example, "2024-06-05 14:35:00.123456".

What are Geography and Other Data Types in BigQuery?

Geography Types in BigQuery represent geographic data, while Other Data Types include ARRAY and STRUCT.

  • GEOGRAPHY: This stores geospatial data, for example, latitude and longitude coordinates.
  • ARRAY: This is an ordered collection of values of the same data type, for example, an array of integers or an array of strings.
  • STRUCT: This is a complex data type that groups multiple fields of different data types together, for example, a record with a name field of type string and an age field of type integer.

Keep reading

View all