mosche commented on code in PR #24288:
URL: https://github.com/apache/beam/pull/24288#discussion_r1038150214
##########
runners/spark/3/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/batch/ParDoTranslatorBatch.java:
##########
@@ -83,61 +86,74 @@
ClassTag.apply(Tuple2.class);
@Override
- public void translate(ParDo.MultiOutput<InputT, OutputT> transform, Context
cxt)
- throws IOException {
- String stepName = cxt.getCurrentTransform().getFullName();
-
- SparkCommonPipelineOptions opts =
cxt.getOptions().as(SparkCommonPipelineOptions.class);
- StorageLevel storageLevel =
StorageLevel.fromString(opts.getStorageLevel());
+ public boolean canTranslate(ParDo.MultiOutput<InputT, OutputT> transform) {
+ DoFn<InputT, OutputT> doFn = transform.getFn();
+ DoFnSignature signature = DoFnSignatures.signatureForDoFn(doFn);
- // Check for not supported advanced features
// TODO: add support of Splittable DoFn
- DoFn<InputT, OutputT> doFn = transform.getFn();
checkState(
- !DoFnSignatures.isSplittable(doFn),
+ !signature.processElement().isSplittable(),
"Not expected to directly translate splittable DoFn, should have been
overridden: %s",
doFn);
// TODO: add support of states and timers
checkState(
- !DoFnSignatures.isStateful(doFn), "States and timers are not supported
for the moment.");
+ !signature.usesState() && !signature.usesTimers(),
+ "States and timers are not supported for the moment.");
checkState(
- !DoFnSignatures.requiresTimeSortedInput(doFn),
+ signature.onWindowExpiration() == null, "onWindowExpiration is not
supported: %s", doFn);
+
+ checkState(
+ !signature.processElement().requiresTimeSortedInput(),
"@RequiresTimeSortedInput is not supported for the moment");
+
SparkSideInputReader.validateMaterializations(transform.getSideInputs().values());
+ return true;
Review Comment:
The right place to check in that case is the javadocs of the default
implementation I suppose. Should I rephrase / clarify the javadocs further or
does it make sense as is?
```
/**
* Checks if a composite / primitive transform can be translated.
Composites that cannot be
* translated as is, will be exploded further for translation of their
parts.
*
* <p>This should be overridden where necessary. If a transform is know to
be unsupported, this
* should throw a runtime exception to give early feedback before any part
of the pipeline is run.
*/
protected boolean canTranslate(TransformT transform)
```
--
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]