Problem with emiting jsonobject in OnNext

Four Stars

Problem with emiting jsonobject in OnNext

 

I have a component, that takes generic input and then does some processing and then returns a generic object,

however it seems the values of all cells are  getting  dropped

Below is code snippet This is just a simpler version of what I am trying to do, but just forwarding what I received, to show the issue

@ElementListener

    public void onNext(

            @Input final JsonObject defaultInput,

            @Output("output_2") final OutputEmitter<JsonObject> output2Output) {

                                output2Output.emit(defaultInput );

               

    }

I see that my output has same number of rows and columns, but all values get dropped.

talend empty result.png

As you see in the attached image, there are 8 rows and bunch of semi-columns because semi colon is the "Field Seperator" for the tFileOutputMSDelimited, but values are empty

 

 


Accepted Solutions
Employee

Re: Problem with emiting jsonobject in OnNext

Hi @bhupendra_patil,

 

As Anas mentionned, the Studio requires you to have a "schema" up to date to then generate the job as efficiently as possible. The first step is to ensure each component have a properly set up schema. To keep it simple I recommand you to start from the beginning of the job and move forward component by component to "propagate" the schema as needed if not already done (the designer is sometimes clever enough to show you a popup to do it on the fly).

 

To edit a schema you can click on a component and then you have access to the related schemas of the components (inputs and outputs).

For outputs and for Talend Component Kit components, you have a "Guess schema" button you can hit to execute the job and auto populate the schema from the fetched data. It is very important to not do it on component writing data if you don't want them to actually write anything but it means it works for almost all components except outputs which can just get their input schemas auto-propagated.

 

guess-schema.pngGuess Schema

Once you have filled the schema or if you want to enter it manually and skip the "guess" logic, then you can hit the ellipsis button "..." and you will see the current schema on the right and the incoming one on the left. There are shortcuts to auto-synchronize them if desired (avoid to type a lot of columns in general) but what is important is it gives you a way to validate what attributes are available in the job generation.

schema.pngSchema Edition

Last important point: the studio "flattens" the data and doesn't natively handle hierarchic data in its schema (compared to JSON which is hierarchic) so it is recommanded to try to produce flat data otherwise the JSON will be flattened for nested objects in "Talend Object" columns (you can see it as a Java Object if it helps).

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

All Replies
Employee

Re: Problem with emiting jsonobject in OnNext

Hello,
It seems like the schema of your component is missing. have you configured the incoming schema in the component.
Can you provide more details (screenshots) of how your job configuration so that we can provide you more accurate support. 


--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: Problem with emiting jsonobject in OnNext

I am new to Talend, so may be wrong, but I did setup the metadata in repository and used it on read csv, and then on my custom component thsi is what i have for schema, whihc is basically propogated from read csv. Does this helpschema.png

Employee

Re: Problem with emiting jsonobject in OnNext

Hi @bhupendra_patil,

 

As Anas mentionned, the Studio requires you to have a "schema" up to date to then generate the job as efficiently as possible. The first step is to ensure each component have a properly set up schema. To keep it simple I recommand you to start from the beginning of the job and move forward component by component to "propagate" the schema as needed if not already done (the designer is sometimes clever enough to show you a popup to do it on the fly).

 

To edit a schema you can click on a component and then you have access to the related schemas of the components (inputs and outputs).

For outputs and for Talend Component Kit components, you have a "Guess schema" button you can hit to execute the job and auto populate the schema from the fetched data. It is very important to not do it on component writing data if you don't want them to actually write anything but it means it works for almost all components except outputs which can just get their input schemas auto-propagated.

 

guess-schema.pngGuess Schema

Once you have filled the schema or if you want to enter it manually and skip the "guess" logic, then you can hit the ellipsis button "..." and you will see the current schema on the right and the incoming one on the left. There are shortcuts to auto-synchronize them if desired (avoid to type a lot of columns in general) but what is important is it gives you a way to validate what attributes are available in the job generation.

schema.pngSchema Edition

Last important point: the studio "flattens" the data and doesn't natively handle hierarchic data in its schema (compared to JSON which is hierarchic) so it is recommanded to try to produce flat data otherwise the JSON will be flattened for nested objects in "Talend Object" columns (you can see it as a Java Object if it helps).

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

Re: Problem with emiting jsonobject in OnNext

Thank you @rmannibucau @anas

My problem ended up been the metadata was messed up in the twritedelimited 

Your screen shot provided me the hint to see the log first and then it worked out fine