robinyqiu commented on pull request #12054:
URL: https://github.com/apache/beam/pull/12054#issuecomment-650415147
Thanks for patching the precision fix! The only remaining issue revealed
from internal tests is that during `CAST` operation time microsecond-precision
could be lost. Could you please add the following unit test to the end of the
new test lists? If you have time you can look into it a bit more to see if
there is a quick fix. Otherwise feel free to create a new JIRA to track the
problem and then ignore the test.
```
@Test
public void testCastBetweenTimeAndString() {
String sql =
"SELECT CAST(s1 as TIME) as t2, CAST(t1 as STRING) as s2 FROM "
+ "(SELECT '12:34:56.123456' as s1, TIME '12:34:56.123456' as
t1)";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new
ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline,
beamRelNode);
PAssert.that(stream)
.containsInAnyOrder(
Row.withSchema(
Schema.builder()
.addLogicalTypeField("t2", SqlTypes.TIME)
.addStringField("s2")
.build())
.addValues(LocalTime.of(12, 34, 56, 123456000),
"12:34:56.123456")
.build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]