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
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is grammatically unclear: “second find DiscoverSchema action name”. Consider rephrasing (e.g., “Then try the DiscoverSchema action name”) so it’s easier to follow when debugging action selection.

Suggested change
// second find DiscoverSchema action name
// Then try the DiscoverSchema action name.

Copilot uses AI. Check for mistakes.
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()
Comment on lines +453 to 458
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stream uses sorted(...).findFirst() just to prefer schema_extended over schema. This sorts the entire candidate list (O(n log n)) even though you only need the best match. Consider replacing it with min(comparator) (or equivalent) to select the preferred action in a single pass and keep intent clearer.

Suggested change
.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()
.min((action1, action2) -> {
boolean action1IsExtended = action1.getType().equals(SCHEMA_EXTENDED_TYPE);
boolean action2IsExtended = action2.getType().equals(SCHEMA_EXTENDED_TYPE);
return Boolean.compare(!action1IsExtended, !action2IsExtended);
})

Copilot uses AI. Check for mistakes.
.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.
Comment on lines 245 to 246
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the “For inputs” action selection list, the last step says to “search an action of type @DiscoverSchema” (without matching the dataset name), but TaCoKitGuessSchema.guessSchemaThroughAction() doesn’t implement this fallback when action is empty (it returns false and falls back to the mock job). Update the documentation to reflect the actual behavior, or implement the documented fallback in code so the docs remain accurate.

Suggested change
.. search an action of type `@DiscoverSchema`.
. Execute a fake job with component to retrieve output schema.
. If no matching action is found, execute a fake job with the component to retrieve the output schema.

Copilot uses AI. Check for mistakes.

Expand Down
Loading