Skip to content
Open
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 @@ -421,22 +421,23 @@ public boolean guessSchemaThroughAction(final Schema schema) {

ServiceMeta.ActionMeta actionRef;
if (action == null || action.isEmpty()) {
// dataset name should be the same as DiscoverSchema action name so let's try to guess from the component
// Dataset name should match the DiscoverSchema or DiscoverSchemaExtended action name, so try to
// guess it from the component (preferring DiscoverSchemaExtended over DiscoverSchema).
actionRef = findFirstComponentDataSetName()
.flatMap(datasetName -> services
.stream()
.flatMap(s -> s.getActions().stream())
.filter(a -> a.getFamily().equals(family) && a.getType().equals(SCHEMA_TYPE))
.filter(a -> a.getFamily().equals(family) && a.getType().equals(SCHEMA_EXTENDED_TYPE))
.filter(a -> a.getAction().equals(datasetName))
.findFirst())
.orElse(null);
if (actionRef == null) {
// let's try DiscoverSchemaExtended action name
// second find DiscoverSchema action name
actionRef = findFirstComponentDataSetName()
.flatMap(datasetName -> services
.stream()
.flatMap(s -> s.getActions().stream())
.filter(a -> a.getFamily().equals(family) && a.getType().equals(SCHEMA_EXTENDED_TYPE))
.filter(a -> a.getFamily().equals(family) && a.getType().equals(SCHEMA_TYPE))
.filter(a -> a.getAction().equals(datasetName))
.findFirst())
.orElse(null);
Expand All @@ -446,10 +447,18 @@ public boolean guessSchemaThroughAction(final Schema schema) {
.stream()
.flatMap(s -> s.getActions().stream())
.filter(a -> a.getFamily().equals(family) && a.getAction().equals(action)
&& a.getType().equals(SCHEMA_TYPE))
&& (a.getType().equals(SCHEMA_EXTENDED_TYPE) || a.getType().equals(SCHEMA_TYPE)))
// When both DiscoverSchemaExtended and DiscoverSchema exist for the same action name,
// prefer the extended schema action by ordering it first.
.sorted((action1, action2) -> {
boolean action1IsExtended = action1.getType().equals(SCHEMA_EXTENDED_TYPE);
boolean action2IsExtended = action2.getType().equals(SCHEMA_EXTENDED_TYPE);
return Boolean.compare(!action1IsExtended, !action2IsExtended);
})
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"No action " + family + "#" + SCHEMA_TYPE + "#" + action));
"No action " + family + "#(" + SCHEMA_TYPE + " or " + SCHEMA_EXTENDED_TYPE + ")#"
+ action));
}
if (actionRef == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ Example:
==== For inputs

. Try to find an action in declared Service class
.. search an action of type `@DiscoverSchema` named like the input dataset.
.. search an action of type `@DiscoverSchemaExtended` named like the input dataset.
.. search an action of type `@DiscoverSchema` named like the input dataset.
.. search an action of type `@DiscoverSchema`.
. Execute a fake job with component to retrieve output schema.

Expand Down
Loading