junaiddshaukat commented on code in PR #39546:
URL: https://github.com/apache/beam/pull/39546#discussion_r3689352208


##########
runners/kafka-streams/src/test/java/org/apache/beam/runners/kafka/streams/translation/PortableWindowingStrategyTest.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.kafka.streams.translation;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.beam.model.pipeline.v1.RunnerApi;
+import org.apache.beam.runners.kafka.streams.KafkaStreamsTestRunner;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.coders.KvCoder;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import org.apache.beam.sdk.coders.VarIntCoder;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.GroupByKey;
+import org.apache.beam.sdk.transforms.Impulse;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.transforms.windowing.FixedWindows;
+import org.apache.beam.sdk.transforms.windowing.SlidingWindows;
+import org.apache.beam.sdk.transforms.windowing.Window;
+import org.apache.beam.sdk.transforms.windowing.WindowFn;
+import org.apache.beam.sdk.util.construction.PipelineTranslation;
+import org.apache.beam.sdk.util.construction.RehydratedComponents;
+import org.apache.beam.sdk.util.construction.WindowingStrategyTranslation;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.WindowingStrategy;
+import org.joda.time.Duration;
+import org.junit.Test;
+
+/**
+ * Checks that the runner's windowing is driven by the language-neutral 
windowing strategy in the
+ * pipeline proto, not by anything specific to the Java SDK.
+ *
+ * <p>This matters because the runner executes GroupAlsoByWindow itself (see 
{@link
+ * WindowedGroupByKeyProcessor}), so it has to reconstruct the WindowFn from 
the proto. Beam encodes
+ * the standard WindowFns as a URN plus a parameter payload — {@code
+ * beam:window_fn:fixed_windows:v1} and friends — and only falls back to a 
serialized Java object
+ * for a custom WindowFn. An SDK in another language emits exactly those same 
standard URNs, so if
+ * the runner works from the URN form it works for any SDK, and if it had come 
to depend on the
+ * Java-serialized form it would only ever have worked for Java.
+ *
+ * <p>These tests assert the proto a windowed pipeline produces carries the 
standard URN, and that
+ * hydrating it back — which is what the translator does — yields the right 
WindowFn. They do not
+ * replace running a pipeline from another SDK end to end, which additionally 
exercises the coders
+ * and the SDK harness; that needs the job server against a real broker.
+ */
+public class PortableWindowingStrategyTest {

Review Comment:
   You're right, and the test was overclaiming — I've renamed it from 
PortableWindowingStrategyTest to StandardWindowFnTranslationTest and rewritten 
the docs. What it actually pins down is that the standard WindowFns are rebuilt 
from the language-neutral URNs, so a pipeline from another SDK using 
fixed/sliding/session/global windows produces a strategy we can reconstruct. A 
user-written WindowFn is opaque to us and would have to run through the SDK 
harness that owns it, which we don't support — windowFnFromProto rejects the 
unrecognised URN. That's stated explicitly now.
   
   



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