Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing datetime string with 0 to 6 decimal points for BigQuery #21599

Closed
damccorm opened this issue Jun 5, 2022 · 2 comments
Closed

Parsing datetime string with 0 to 6 decimal points for BigQuery #21599

damccorm opened this issue Jun 5, 2022 · 2 comments

Comments

@damccorm
Copy link
Contributor

damccorm commented Jun 5, 2022

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.

 


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);

 

Error stack:


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)

Imported from Jira BEAM-14114. Original Jira may contain additional context.
Reported by: heejong.

@proost
Copy link
Contributor

proost commented Aug 10, 2024

.take-issue

@proost
Copy link
Contributor

proost commented Aug 10, 2024

.close-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants