Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,10 @@ private static <T> Coder<T> getDefaultCreateCoder(CoderRegistry registry, Iterab
throws CannotProvideCoderException {
checkArgument(
!Iterables.isEmpty(elems),
"Elements must be provided to construct the default Create Coder. To Create an empty "
+ "PCollection, either call Create.empty(Coder), or call 'withCoder(Coder)' on the "
+ "result PTransform");
"Can not determine a default Coder for a 'Create' PTransform that "
+ "has no elements. Either add elements, call Create.empty(Coder),"
+ " Create.empty(TypeDescriptor), or call 'withCoder(Coder)' or "
+ "'withType(TypeDescriptor)' on the PTransform.");
// First try to deduce a coder using the types of the elements.
Class<?> elementClazz = Void.class;
for (T elem : elems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ public void testCreateEmptyIterableRequiresCoder() {
p.enableAbandonedNodeEnforcement(false);

thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("default Create Coder");
thrown.expectMessage("determine a default Coder");
thrown.expectMessage("Create.empty(Coder)");
thrown.expectMessage("Create.empty(TypeDescriptor)");
thrown.expectMessage("withCoder(Coder)");
thrown.expectMessage("withType(TypeDescriptor)");
p.apply(Create.of(Collections.emptyList()));
}

Expand Down Expand Up @@ -280,9 +282,11 @@ public void testCreateTimestampedEmptyUnspecifiedCoder() {
p.enableAbandonedNodeEnforcement(false);

thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("default Create Coder");
thrown.expectMessage("determine a default Coder");
thrown.expectMessage("Create.empty(Coder)");
thrown.expectMessage("Create.empty(TypeDescriptor)");
thrown.expectMessage("withCoder(Coder)");
thrown.expectMessage("withType(TypeDescriptor)");
p.apply(Create.timestamped(new ArrayList<TimestampedValue<Object>>()));
}

Expand Down