You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Heejong Lee (Jira)" <ji...@apache.org> on 2022/03/16 01:54:00 UTC
[jira] [Updated] (BEAM-14114) Parsing datetime string with 0 to 6 decimal points for BigQuery
[ https://issues.apache.org/jira/browse/BEAM-14114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Heejong Lee updated BEAM-14114:
-------------------------------
Description:
DateTimeFormatter for BigQuery only supports 0, 3, 6 decimal point:
[https://github.com/apache/beam/blob/v2.37.0/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java#L165]
We might want to support an arbitrary number of decimal points between 0 to 6.
{code:java}
Pipeline pipeline = Pipeline.create(options);
pipeline.apply(BigQueryIO.readTableRows()
.fromQuery("select cast("2022-02-18 11:09:12.3456" as datetime) "
"UNION ALL "
"select cast("2022-02-18 11:09:12.345678" as datetime) ")
.usingStandardSql()
).apply(ParDo.of(new DoFn<TableRow, TableRow>() {
@ProcessElement
public void processElement(@Element TableRow tableRow) {
System.out.println(tableRow);
{code}
Error stack:
{noformat}
Caused by: java.time.format.DateTimeParseException: Text '2022-02-18T11:09:12.3456' could not be parsed, unparsed text found at index 19
java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
java.time.LocalDateTime.parse(LocalDateTime.java:492)
org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamValue(BigQueryUtils.java:673)
org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamRowFieldValue(BigQueryUtils.java:636)
{noformat}
was:
{code:java}
Pipeline pipeline = Pipeline.create(options);
pipeline.apply(BigQueryIO.readTableRows()
.fromQuery("select cast("2022-02-18 11:09:12.3456" as datetime) "
"UNION ALL "
"select cast("2022-02-18 11:09:12.345678" as datetime) ")
.usingStandardSql()
).apply(ParDo.of(new DoFn<TableRow, TableRow>() {
@ProcessElement
public void processElement(@Element TableRow tableRow) {
System.out.println(tableRow);
{code}
Error stack:
{noformat}
Caused by: java.time.format.DateTimeParseException: Text '2022-02-18T11:09:12.3456' could not be parsed, unparsed text found at index 19
java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
java.time.LocalDateTime.parse(LocalDateTime.java:492)
org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamValue(BigQueryUtils.java:673)
org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamRowFieldValue(BigQueryUtils.java:636)
{noformat}
> Parsing datetime string with 0 to 6 decimal points for BigQuery
> ---------------------------------------------------------------
>
> Key: BEAM-14114
> URL: https://issues.apache.org/jira/browse/BEAM-14114
> Project: Beam
> Issue Type: Improvement
> Components: io-java-gcp
> Reporter: Heejong Lee
> Priority: P2
>
> DateTimeFormatter for BigQuery only supports 0, 3, 6 decimal point:
> [https://github.com/apache/beam/blob/v2.37.0/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java#L165]
> We might want to support an arbitrary number of decimal points between 0 to 6.
>
> {code:java}
> Pipeline pipeline = Pipeline.create(options);
> pipeline.apply(BigQueryIO.readTableRows()
> .fromQuery("select cast("2022-02-18 11:09:12.3456" as datetime) "
> "UNION ALL "
> "select cast("2022-02-18 11:09:12.345678" as datetime) ")
> .usingStandardSql()
> ).apply(ParDo.of(new DoFn<TableRow, TableRow>() {
> @ProcessElement
> public void processElement(@Element TableRow tableRow) {
> System.out.println(tableRow);
> {code}
>
> Error stack:
> {noformat}
> Caused by: java.time.format.DateTimeParseException: Text '2022-02-18T11:09:12.3456' could not be parsed, unparsed text found at index 19
> java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
> java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
> java.time.LocalDateTime.parse(LocalDateTime.java:492)
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamValue(BigQueryUtils.java:673)
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamRowFieldValue(BigQueryUtils.java:636)
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)