From 83bccf9c49056de775324e1c580391b59525397f Mon Sep 17 00:00:00 2001 From: Boyuan Zhang Date: Mon, 24 May 2021 11:01:59 -0700 Subject: [PATCH] [BEAM-12384] Infer typeDescriptor from coder if typeDescriptor is not set explicitly. --- .../main/java/org/apache/beam/sdk/values/PCollection.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollection.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollection.java index a637951ff1d8..5e85eb8c4adb 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollection.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollection.java @@ -124,7 +124,13 @@ public void finishSpecifying(PInput input, PTransform transform) { * override this to enable better {@code Coder} inference. */ public @Nullable TypeDescriptor getTypeDescriptor() { - return typeDescriptor; + if (typeDescriptor != null) { + return typeDescriptor; + } + if (coderOrFailure.coder != null) { + return coderOrFailure.coder.getEncodedTypeDescriptor(); + } + return null; } /**