Class BigqueryUtils

java.lang.Object
google.registry.bigquery.BigqueryUtils

public class BigqueryUtils extends Object
Utilities related to Bigquery.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Destination formats for Bigquery extract jobs.
    static enum 
    Bigquery schema field types.
    static enum 
    Bigquery table types (i.e.
    static enum 
    Bigquery write dispositions (i.e.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.joda.time.format.DateTimeFormatter
    A DateTimeFormatter that defines how to print DateTimes in a string format that BigQuery can interpret and how to parse the string formats that BigQuery emits into DateTimes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.joda.time.DateTime
    Returns the DateTime for a given human-readable string-formatted BigQuery timestamp.
    static String
    toBigqueryTimestamp(long timestamp, TimeUnit unit)
    Converts a time (in TimeUnits since the epoch) into a numeric string that BigQuery understands as a timestamp: the decimal number of seconds since the epoch, precise up to microseconds.
    static String
    toBigqueryTimestamp(org.joda.time.DateTime dateTime)
    Converts a DateTime into a numeric string that BigQuery understands as a timestamp: the decimal number of seconds since the epoch, precise up to microseconds.
    static String
    toBigqueryTimestampString(org.joda.time.DateTime dateTime)
    Returns the human-readable string version of the given DateTime, suitable for conversion within BigQuery from a string literal into a BigQuery timestamp type.
    static String
    toJobReferenceString(com.google.api.services.bigquery.model.JobReference jobRef)
    Returns the canonical string format for a JobReference object (the project ID and then job ID, delimited by a single colon) since JobReference.toString() is not customized to return it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BIGQUERY_TIMESTAMP_FORMAT

      public static final org.joda.time.format.DateTimeFormatter BIGQUERY_TIMESTAMP_FORMAT
      A DateTimeFormatter that defines how to print DateTimes in a string format that BigQuery can interpret and how to parse the string formats that BigQuery emits into DateTimes.

      The general format definition is "YYYY-MM-DD HH:MM:SS.SSS[ ZZ]", where the fractional seconds portion can have 0-6 decimal places (although we restrict it to 0-3 here since Joda DateTime only supports up to millisecond precision) and the zone if not specified defaults to UTC.

      Although we expect a zone specification of "UTC" when parsing, we don't emit it when printing because in some cases BigQuery does not allow any time zone specification (instead it assumes UTC for whatever input you provide) for input timestamp strings (see b/16380363).

      See Also:
  • Constructor Details

    • BigqueryUtils

      public BigqueryUtils()
  • Method Details

    • toBigqueryTimestampString

      public static String toBigqueryTimestampString(org.joda.time.DateTime dateTime)
      Returns the human-readable string version of the given DateTime, suitable for conversion within BigQuery from a string literal into a BigQuery timestamp type.
    • fromBigqueryTimestampString

      public static org.joda.time.DateTime fromBigqueryTimestampString(String timestampString)
      Returns the DateTime for a given human-readable string-formatted BigQuery timestamp.
    • toBigqueryTimestamp

      public static String toBigqueryTimestamp(long timestamp, TimeUnit unit)
      Converts a time (in TimeUnits since the epoch) into a numeric string that BigQuery understands as a timestamp: the decimal number of seconds since the epoch, precise up to microseconds.
      See Also:
    • toBigqueryTimestamp

      public static String toBigqueryTimestamp(org.joda.time.DateTime dateTime)
      Converts a DateTime into a numeric string that BigQuery understands as a timestamp: the decimal number of seconds since the epoch, precise up to microseconds.

      Note that since DateTime only stores milliseconds, the last 3 digits will be zero.

      See Also:
    • toJobReferenceString

      public static String toJobReferenceString(com.google.api.services.bigquery.model.JobReference jobRef)
      Returns the canonical string format for a JobReference object (the project ID and then job ID, delimited by a single colon) since JobReference.toString() is not customized to return it.