Package google.registry.bigquery
Class BigqueryUtils
java.lang.Object
google.registry.bigquery.BigqueryUtils
Utilities related to Bigquery.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic 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
Modifier and TypeFieldDescriptionstatic final org.joda.time.format.DateTimeFormatter
ADateTimeFormatter
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.joda.time.DateTime
fromBigqueryTimestampString
(String timestampString) 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 aDateTime
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.
-
Field Details
-
BIGQUERY_TIMESTAMP_FORMAT
public static final org.joda.time.format.DateTimeFormatter BIGQUERY_TIMESTAMP_FORMATADateTimeFormatter
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
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
Returns the DateTime for a given human-readable string-formatted BigQuery timestamp. -
toBigqueryTimestamp
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
Converts aDateTime
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.
-