tkaymak commented on code in PR #40090: URL: https://github.com/apache/beam/pull/40090#discussion_r3991143242
########## runners/spark/4/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/PipelineTranslatorStreaming.java: ########## @@ -0,0 +1,114 @@ +/* + * 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.spark.structuredstreaming.translation; + +import java.util.Collection; +import org.apache.beam.runners.spark.SparkCommonPipelineOptions; +import org.apache.beam.runners.spark.structuredstreaming.translation.batch.PipelineTranslatorCommon; +import org.apache.beam.runners.spark.structuredstreaming.translation.streaming.ReadUnboundedTranslator; +import org.apache.beam.sdk.annotations.Internal; +import org.apache.beam.sdk.transforms.Combine; +import org.apache.beam.sdk.transforms.GroupByKey; +import org.apache.beam.sdk.transforms.Impulse; +import org.apache.beam.sdk.transforms.PTransform; +import org.apache.beam.sdk.transforms.ParDo; +import org.apache.beam.sdk.transforms.reflect.DoFnSignature; +import org.apache.beam.sdk.transforms.reflect.DoFnSignatures; +import org.apache.beam.sdk.util.construction.SplittableParDo; +import org.apache.beam.sdk.values.PInput; +import org.apache.beam.sdk.values.POutput; +import org.apache.spark.sql.SparkSession; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * Pipeline translator for streaming pipelines on Spark 4. It extends the common registry to reuse + * the stateless single output ParDo, Window.Assign, Flatten and Reshuffle translators, which are + * safe on a streaming Dataset. Every other primitive fails at translation, the batch translators + * for them persist or collect the Dataset, which Spark rejects for streaming plans. + */ +@Internal +public class PipelineTranslatorStreaming extends PipelineTranslatorCommon { + + private static final String NOT_SUPPORTED = + " is not supported by the Spark 4 streaming runner yet, see" + + " https://github.com/apache/beam/issues/36841"; + + /** Returns a {@link TransformTranslator} for the given {@link PTransform} if known. */ + @Override + @Nullable + protected <InT extends PInput, OutT extends POutput, TransformT extends PTransform<InT, OutT>> + TransformTranslator<InT, OutT, TransformT> getTransformTranslator(TransformT transform) { + + if (transform instanceof SplittableParDo.PrimitiveUnboundedRead) { + @SuppressWarnings("unchecked") + TransformTranslator<InT, OutT, TransformT> read = + (TransformTranslator<InT, OutT, TransformT>) Review Comment: Sorry for this, I am investigating the SparkSession stopping bug and will clean this. -- 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]
