HaeSe0ng commented on code in PR #26889:
URL: https://github.com/apache/beam/pull/26889#discussion_r1251112985


##########
sdks/python/apache_beam/examples/snippets/snippets.py:
##########
@@ -1181,6 +1189,32 @@ def model_bigqueryio(
       create_disposition=beam.io.BigQueryDisposition.CREATE_IF_NEEDED)
   # [END model_bigqueryio_write]
 
+  # [START model_bigqueryio_write_with_storage_write_api]
+  quotes | beam.io.WriteToBigQuery(
+      table_spec,
+      schema=table_schema,
+      method=beam.io.WriteToBigQuery.Method.STORAGE_WRITE_API)
+  # [END model_bigqueryio_write_with_storage_write_api]

Review Comment:
   Hi, @ahmedabu98 .
   I tried to write 'TIMESTAMP' type, but I got an error message
   ```
   java.lang.IllegalArgumentException: Input schema is not assignable to output 
schema.
   Input schema=Fields:
   .......
   INFO 2023-07-03T09:27:24.015855Z Field{name=ts, description=, 
type=LOGICAL_TYPE<beam:logical_type:micros_instant:v1>, options={{}}}
   .......
   , Output schema=Fields:
   .......
   INFO 2023-07-03T09:27:24.016054Z Field{name=ts, description=, type=DATETIME, 
options={{}}}
   .......
   ``` 
   I looked into beam source codes and found that [input 
mapping](https://github.com/apache/beam/blob/master/sdks/python/apache_beam/typehints/schemas.py#L36)
 and [output 
mapping](https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java#L324)
 are not matched in the [schema validation 
code](https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java#L414)).
 I think output mapping should be `FieldType.logicalType(SqlTypes.TIMESTAMP)`.
   Is there a way to avoid this error, or is `TIMESTAMP` type not supported yet?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to