laysakura opened a new issue, #24510:
URL: https://github.com/apache/beam/issues/24510
### What would you like to happen?
## Example dataset
Per-hour weather data.
```json
{"timestamp": "2022-08-01T00:00:00.000+00:00", "temperature [°C]": 0.0,
"rainfall [mm]": 0.0}
{"timestamp": "2022-08-01T01:00:00.000+00:00", "temperature [°C]": 0.0,
"rainfall [mm]": 0.0}
{"timestamp": "2022-08-01T02:00:00.000+00:00", "temperature [°C]": 0.0,
"rainfall [mm]": 0.0}
```
## Example code
```java
// 1-day session window
PCollection<Float> windowedTemperature = temperatureOver30.apply(
Window.<Float>into(
Sessions.withGapDuration(Duration.standardDays(1))));
PCollection<KV<Instant, Float>> windowedTemperatureWithDate =
windowedTemperature.apply(
ParDo.of(new DoFn<Float, KV<Instant, Float>>() {
@ProcessElement
public void processElement(
@Element Float temperature,
IntervalWindow window,
OutputReceiver<KV<Instant, Float>> out) {
Instant winEnd = window.maxTimestamp();
System.out.println(window); // PRINT HERE
out.output(KV.of(winEnd, temperature));
}
}));
```
See the full codes:
<https://gist.github.com/laysakura/175cf1137c8cb3356236ed7ab2443b71>
## Expected outputs from `println()`
```text
[2022-08-01T00:00:00.000Z..2022-08-02T02:00:00.000Z)
```
## Actual outputs from `println()`
```text
[2022-08-01T00:00:00.000Z..2022-08-02T00:00:00.000Z)
[2022-08-01T01:00:00.000Z..2022-08-02T01:00:00.000Z)
[2022-08-01T02:00:00.000Z..2022-08-02T02:00:00.000Z)
```
## Problem hypothesis and solution
`assignWindows()` has control to `IntervalWindow`:
<https://github.com/apache/beam/blob/ec91ea4f6b83e6a8e3bd2041057fa90d0c8f0dd0/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/WindowFn.java#L59-L60>
but `mergeWindows()` doesn't:
<https://github.com/apache/beam/blob/ec91ea4f6b83e6a8e3bd2041057fa90d0c8f0dd0/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/WindowFn.java#L88>.
So `mergeWindoews()` might have to modify `IntervalWindow.start` and
`IntervalWindow.end` after merges of windows happen.
### Issue Priority
Priority: 2
### Issue Component
Component: sdk-java-core
--
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]