How to achieve schema (columns and types) using @DiscoverSchema annotation

Five Stars

How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi All,

I am not able to get schema columns names for my input component as per module name using  @DiscoverSchema,Please help me with code. I have written code like below in service class .I need to write any thing in dataset class.

thanks,

venkat.

 @DiscoverSchema("guessSchema")
public Schema guessSchema(@Option("dataset") final VtigercrmComponentsDataSet dataset ,final RecordBuilderFactory factory)
{

final Schema.Entry.Builder entryBuilder = factory.newEntryBuilder();
final Schema.Builder schemaBuilder = factory.newSchemaBuilder(org.talend.sdk.component.api.record.Schema.Type.RECORD);


Schema.Type type = Schema.Type.STRING;
//return (Schema) schemaBuilder.withEntry(entryBuilder.withName("name").withType(type).withNullable(false).build());

return factory.newSchemaBuilder(Schema.Type.RECORD)
.withEntry(factory.newEntryBuilder().withName("ResponseContent").withType(Schema.Type.LONG).build()).build();
}     

Employee

Re: How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi @Venkat_C ,

 

This guess schema will work only if your dataset is named "guessSchema", is it the case?

 

 

Romain
Talend Component Kit Documentation: https://talend.github.io/component-runtime/
Six Stars

Re: How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi @Venkat_C did you get it working?

My team had same problem see thread:

https://community.talend.com/t5/Component-Development/Producer-and-DiscoverScheme/m-p/149874#M339

If you got it working what TS version you work with and which API version you use to develop your components?

 

Thank you!

Five Stars

Re: How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi @igorbeslic ,

 

Yah,its working perfectly '@DiscoverSchema,i have declare List instance  in my dataset class as like below and written @DiscoverSchema in service class.please find below link,it will use for create schema.

 

https://talend.github.io/component-runtime/main/1.1.3/record-types.html

 

@Option
@Structure(discoverSchema = "guessTableSchema",type=Type.IN)
@Documentation(value = "List of field names to return in the response.")
private List<String> fields = new ArrayList<>();

 

regards,

venkat

Six Stars

Re: How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi @Venkat_C thank you for your hints! Still for me documentation links are worthless. In link you provided there is no any note about:

@Option
@Structure(discoverSchema = "guessTableSchema",type=Type.IN)
@Documentation(value = "List of field names to return in the response.")
private List<String> fields = new ArrayList<>();

Do you have your component code available at GitHub? I sound desperate, but I think it would help more than all Telned documentation links people share in this forum. Or if you can share in this thread all important parts?


I used your hints with "@Structure" annotation but it does not trigger "@DiscoverSchema" method in "@Service" class. I put Talend Studio 7.2.1 M3 in debug mode and it does not track any interaction with service class. The "Discover schema" button in TS UI triggers "@Producer" method in my mapper's source class (invoked by "org.talend.sdk.component.runtime.di.schema.TaCoKitGuessSchema#guessSchemaThroughResult(java.lang.Object)").

 

Are you sure schema you get in your UI really comes from service annotated method "@DiscoverSchema"?

 

Thank you very much!

Employee

Re: How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi Igor

Please dont mix two API - both use the same action.

1. @Structure is to have completion on a configuration field,
2. Guess Schema button is to initialize the struct associated to the component. For inputs, it tries to match a discover schema action based on the dataset used in the input configuration, if none is found it runs the producer method to get data.

I suspect something is fishy in the second case for you - was your action name originally if I recall correctly. Did you fix it, redeployed the component and restarted the studio or used the reload feature?

If still an issue please share your current/updated code to let us check what is missing.
Romain
Talend Component Kit Documentation: https://talend.github.io/component-runtime/
Six Stars

Re: How to achieve schema (columns and types) using @DiscoverSchema annotation

Hi @rmannibucau my component project is here

https://github.com/igorbeslic/talend-poc

 

Service implementation:

https://github.com/igorbeslic/talend-poc/blob/master/src/main/java/com/liferay/ebus/service/EBusServ...

 

Once deployed Talend Studio never invokes:

@DiscoverSchema(value = "Dataset")
public Schema discoverSchema(
	@Option("dataset") Dataset dataset,
	final RecordBuilderFactory recordBuilderFactory) {
//...
}

 

Thank you very much!!!

 

UPDATE:

I debug GuessSchema:

public TaCoKitGuessSchema(final PrintStream out, final Map<String, String> configuration, final String plugin,
            final String family, final String componentName, final String action)

last argument, "action" passed to TaCoKitGuessSchema is null. What could be reason for it?

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now