Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tJavaRow set Null to output row

Hi,

I have a tJavaRow with some input and output rows

I have a random column name and  I want to set that output column as null

How can I do that ?

Thank all.

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

What you could try will take a fair amount of work, will perform a little slower, but will not require quite as much coding as my previous suggestion. You could try connecting your data source to a tFlowToIterate. This will iterate over the dataset once row at a time. However, what it does is load each row into the globalMap HashMap. The "key" to the value can either be the default {row}.{column} String or something you specify for each column. After your tFlowToIterate, connect to a tJavaFlex. In the "Start Code" section you could write something to iterate over the globalMap using your String variable to find the columns that should be null and change them. Then in the "Main Code" section you can simply have code to map the corresponding globalMap value with the correct output column. Your dynamic functionality would be in the Start Code section and what you have in the Main Code (albeit a lot of lines of code) would be fixed.

View solution in original post

10 Replies
Anonymous
Not applicable
Author

It will be null unless you set it to something else

Anonymous
Not applicable
Author

I have set all input_row to ouput_row,
Now I want set some column to null, I have list of column name but I don't know exactly what they are.
Do you have some idea?
Anonymous
Not applicable
Author

If you want the column set to null for every row, just don't set a value. For example, if your input and out columns are set as below....

 

output_row.newColumn = input_row.newColumn;
output_row.newColumn1 = input_row.newColumn1;
output_row.newColumn2 = input_row.newColumn2;
output_row.newColumn3 = input_row.newColumn3;

....and you want to ensure that "newColumn2" is null, you can either....

 

output_row.newColumn = input_row.newColumn;
output_row.newColumn1 = input_row.newColumn1;
output_row.newColumn3 = input_row.newColumn3;

... or....

output_row.newColumn = input_row.newColumn;
output_row.newColumn1 = input_row.newColumn1;
output_row.newColumn2 = null;
output_row.newColumn3 = input_row.newColumn3;
Anonymous
Not applicable
Author

Thank you, but I don't know the column name, I just have it as a String variable
Anonymous
Not applicable
Author

So something more dynamic? You could try something like this...

 

if(myStringVar.equals("newColumn")){
output_row.newColumn = null;
output_row.newColumn1 = input_row.newColumn1;
output_row.newColumn2 = input_row.newColumn2;
output_row.newColumn3 = input_row.newColumn3;
}else if(myStringVar.equals("newColumn1")){
output_row.newColumn = input_row.newColumn;
output_row.newColumn1 = null;
output_row.newColumn2 = input_row.newColumn2;
output_row.newColumn3 = input_row.newColumn3;
} //..... etc

 

Anonymous
Not applicable
Author

My input row has more than 1000 column, I can't use 'if else' for this.
If I don't use tJavaRow, is there any way to set some column of an input row to null ?
Anonymous
Not applicable
Author

OK, lets go back a few steps. Why do you need to do this? What is the requirement? I'm sure your requirement can be met, but I will need to know all of the information before I can suggest something sensible 

Anonymous
Not applicable
Author

I have some data rows with 1000 coulmns each row, some column have invalid data and I use tSchemaComplianceCheck to get all the name of invalid column,
Now I want to export all data row, and set null to invalid column. Keep all right column.
Anonymous
Not applicable
Author

What you could try will take a fair amount of work, will perform a little slower, but will not require quite as much coding as my previous suggestion. You could try connecting your data source to a tFlowToIterate. This will iterate over the dataset once row at a time. However, what it does is load each row into the globalMap HashMap. The "key" to the value can either be the default {row}.{column} String or something you specify for each column. After your tFlowToIterate, connect to a tJavaFlex. In the "Start Code" section you could write something to iterate over the globalMap using your String variable to find the columns that should be null and change them. Then in the "Main Code" section you can simply have code to map the corresponding globalMap value with the correct output column. Your dynamic functionality would be in the Start Code section and what you have in the Main Code (albeit a lot of lines of code) would be fixed.