Full support for DATE, TIME, and DATETIME in BigQuery#1819
Full support for DATE, TIME, and DATETIME in BigQuery#1819garrettjonesgoogle wants to merge 1 commit intogoogleapis:masterfrom
Conversation
|
Note I have fixed the codacy errors - I'll push them with other PR updates. |
|
|
||
| /** | ||
| * Creates a {@code QueryParameterValue} object with a type of DATETIME. | ||
| * Must be in the format "yyyy-MM-dd HH:mm:ss.SSSSSS", e.g. ""2014-08-19 12:41:35.220000". |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * and Spanner DATE | ||
| * (https://cloud.google.com/spanner/docs/data-types#date-type). | ||
| * | ||
| * The DATE type represents a logical calendar date, independent of time zone. A DATE value |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * Represents a time without timezone, e.g. 07:41:35.220000. | ||
| * | ||
| * CivilTime holds values for BigQuery TIME | ||
| * (https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#time-type).0 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } else if (value instanceof String) { | ||
| // verify that the String is in the right format | ||
| timestampFormatter.parseMillis((String) value); | ||
| Timestamp.parseCloudTimestamp((String) value); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@shinfan PTAL |
|
LGTM |
|
Changes Unknown when pulling fee2415 on garrettjonesgoogle:master into ** on GoogleCloudPlatform:master**. |
| * @param date civil date | ||
| */ | ||
| public static CivilDateTime ofDate(CivilDate date) { | ||
| return ofDateAndTime(date, CivilTime.ofHoursMinutesSecondsNanos(0, 0, 0, 0)); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| /** | ||
| * @param dateTime Date plus time: (yyyy-MM-dd HH:mm:ss.SSSSSSSSS) or |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| /** | ||
| * Constructs a new CivilDate instance. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| nanos = (int) TimeUnit.MILLISECONDS.toNanos(fractionalNumber); | ||
| } else if (fractional.length() == 6) { | ||
| nanos = (int) TimeUnit.MICROSECONDS.toNanos(fractionalNumber); | ||
| } else { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return time; | ||
| } | ||
|
|
||
| /** Formats the date and time in the format yyyy-MM-dd HH:mm:ss.SSSSSSSSS */ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| /** Formats the date and time in the format yyyy-MM-dd HH:mm:ss.SSSSSSSSS */ | ||
| public String formatMicroCloudTime() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| this.nanos = nanos; | ||
| } | ||
|
|
||
| public static Timestamp ofTimeMicroseconds(long microseconds) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| */ | ||
| public static CivilDateTime parseDateTime(String dateTime) { | ||
| String splitToken = " "; | ||
| if (dateTime.contains("T")) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Represents a date and time with no timezone, e.g. e.g. 2017-03-17 07:41:35.220000. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| /** Regexp to split timestamps into date-hour-minute-second and fractional second components. */ | ||
| private static final Pattern FORMAT_REGEXP = Pattern.compile("([^\\.]*)(\\.\\d{0,9})?Z"); | ||
| private static final Pattern FORMAT_REGEXP = Pattern.compile("([^.]*)(\\.\\d{0,9})?Z"); | ||
| private static final String DATE_GROUP = "(\\d{4}-\\d{1,2}-\\d{1,2})"; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| private static final String DATE_GROUP = "(\\d{4}-\\d{1,2}-\\d{1,2})"; | ||
| private static final String TIME_GROUP = "(\\d{1,2}:\\d{1,2}:\\d{1,2})"; | ||
| private static final String FRACT_GROUP = "\\.(\\d{1,9})"; | ||
| private static final String TZ_GROUP = "([\\-+]\\d{1,2}(?::\\d{1,2})?)"; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| /** | ||
| * Creates a Timestamp instance from the given string. String is in the format | ||
| * yyyy-MM-dd HH:mm:ss.SSSSSSZZ. If no timezone is given, UTC is assumed. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| DateTime dateTime = new DateTime(); | ||
| dateTime = parseTz(dateTime, tz); | ||
| dateTime = parseDate(dateTime, Preconditions.checkNotNull(date)); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return ofTimeSecondsAndNanos(TimeUnit.MILLISECONDS.toSeconds(dateTime.getMillis()), nanos); | ||
| } | ||
|
|
||
| private static DateTime parseDate(DateTime newDateTime, String dateString) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * Creates a Timestamp instance from the given string. String is in the format | ||
| * yyyy-MM-dd HH:mm:ss.SSSSSSZZ. If no timezone is given, UTC is assumed. | ||
| */ | ||
| public static Timestamp parseCloudTimestamp(String timestamp) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
All so-far-agreed-to feedback has been addressed. |
|
Changes Unknown when pulling 8e26935 on garrettjonesgoogle:master into ** on GoogleCloudPlatform:master**. |
| @@ -252,12 +262,28 @@ public static QueryParameterValue time(String value) { | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| */ | ||
| @SuppressWarnings("unchecked") | ||
| public long getTimestampValue() { | ||
| public Timestamp getTimestampValue() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
I have pushed some doc improvements, PTAL |
|
Changes Unknown when pulling 3151e09 on garrettjonesgoogle:master into ** on GoogleCloudPlatform:master**. |
|
@vkedia do you have any other concerns? |
|
Looks good to me. |
3151e09 to
7a54804
Compare
|
Changes Unknown when pulling 7a54804 on garrettjonesgoogle:master into ** on GoogleCloudPlatform:master**. |
b35947a to
3151e09
Compare
|
Changes Unknown when pulling 3151e09 on garrettjonesgoogle:master into ** on GoogleCloudPlatform:master**. |
3151e09 to
1535cc1
Compare
This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: https://github.com/googleapis/synthtool/commit/ef9fe2ef6d92c7ff967d9d4f704035b3f5c9051d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9
* ci: javadoc job (JDK 17) in ci.yaml (#1819) This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: googleapis/synthtool@ef9fe2e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9 * fix javadoc * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Tomo Suzuki <suztomo@google.com>
This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: googleapis/synthtool@ef9fe2e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* ci: javadoc job (JDK 17) in ci.yaml (#1819) This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: googleapis/synthtool@ef9fe2e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9 * fix errors * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix error --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Neenu1995 <neenushaji@google.com>
This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: https://github.com/googleapis/synthtool/commit/ef9fe2ef6d92c7ff967d9d4f704035b3f5c9051d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* ci: javadoc job (JDK 17) in ci.yaml (#1819) This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: googleapis/synthtool@ef9fe2e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9 * docs: fix java 17 doclint errors --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
* ci: javadoc job (JDK 17) in ci.yaml (#1819) This also changes the JDK distribution from zulu to temurin https://github.com/actions/setup-java#eclipse-temurin Source-Link: googleapis/synthtool@ef9fe2e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:31c8276a1bfb43766597d32645721c029cb94571f1b8d996cb2c290744fe52f9 * docs: fix java 17 doclint errors --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
Also:
Fixes #1792