Showing posts with label table. Show all posts
Showing posts with label table. Show all posts
Wednesday, February 18, 2015
Kettle Pass parameters from job to transformation in PDI Retrieve data from table by passing table name as parameter
This post will talk about basic understanding of parameters concept in PDI.
Software Setup :
PDI 5.1.0 CE
PostgreSQL
Concept : Retrieve data from table by passing table name as parameter.
You will learn below things
1) Table input step & database connections
2) Creating parameter(s) in Transformation(s) & Job(s)
3) Passing parameter(s) from job to transformation.
Lets say in foodmart database you have below tables 1) region 2) product 3) customer and etc.
Every time when you pass different table name as parameter you should able to fetch the data coming from the passed table.
1) Table input step & database connections
2) Creating parameter(s) in Transformation(s) & Job(s)
1) Create a new transformation & drag and drop "Table Input" step from Design Pane.

2) Double Click on "Table input" step & Click on New tab to give database connections as shown in below image

3) Define the parameter in transformation ( in this example the table name should go as parameter).
Image A : Right Click on the empty space to get the transformation settings.
Image B : Database Connection Details
Parameter Name is : tableName


4) Come back to the properties of "Table input" & write select statement to retrieve the data.
Eg : SELECT * FROM product LIMIT 100
In above example "product" is the table name that you have to replace with the parameter.
i.e., SELECT * FROM ${tableName} LIMIT 100
Once you write the query, come down check "Replace variables in script"

5) Take a "Dummy" step and connect it to "Table input step" . Save the transformation & run it on "Dummy Step"( Right click dummy step and click on "Preview".
OUTPUT : Test 1 : With "region" table

OUTPUT : Result 1

OUTPUT : Test 2 : With "product" table
* Right click Dummy step then click on Preview
* Click on Configure & then in parameters tab give "product" for tableName value parameter.
OUTPUT : Result 2

3) Passing parameter(s) from job to transformation
* Crtl+Alt to create a new job
* From the "General" node of Design tab ( Appears left side) drag and drop "Transoformation step".
* Drag and drop "START" step and connect these two as shown in below image.

* Double click on "Transformation" step to set the properties & parameter information.
* Browse for the transformation file and then move to parameters tab
* Click on "Get Parameters" then you can find parameter get apper under Parameter tab.
* Right click on empty canvas of job to get its settings & move to Parameters tab and give parameter name as "tableName" and provide default value.
Save the job and run it.
IMP NOTE :
1) Parameter names in job & transformation should match.
2) You can create n number of parameters in job but can pass as many you wish.
3) In job design you should take "START" step to tell the job to start execution from there.
If you ignore you will get below error ( which took me awhile to solve it for the very first time).
Start of job execution
:A serious error occurred during job execution:
Couldnt find starting point in this job.
org.pentaho.di.core.exception.KettleJobException:
Couldnt find starting point in this job.
at org.pentaho.di.job.Job.execute(Job.java:516)
at org.pentaho.di.job.Job.run(Job.java:422)
Spoon - Job has ended.
References :
1) http://wiki.pentaho.com/display/EAI/Named+Parameters
2) http://diethardsteiner.blogspot.in/2013/07/pentaho-kettle-parameters-and-variables.html
3) http://wiki.pentaho.com/display/EAI/Substituting+variable+references+in+Job+Parameter+values
Hope this helps some one like me for the first time who is looking for parameters(named) concept :-)
Cheers :-)
:-) Happy New Year - Welcome - 2015 :-)
Software Setup :
PDI 5.1.0 CE
PostgreSQL
Concept : Retrieve data from table by passing table name as parameter.
You will learn below things
1) Table input step & database connections
2) Creating parameter(s) in Transformation(s) & Job(s)
3) Passing parameter(s) from job to transformation.
Lets say in foodmart database you have below tables 1) region 2) product 3) customer and etc.
Every time when you pass different table name as parameter you should able to fetch the data coming from the passed table.
1) Table input step & database connections
2) Creating parameter(s) in Transformation(s) & Job(s)
1) Create a new transformation & drag and drop "Table Input" step from Design Pane.

2) Double Click on "Table input" step & Click on New tab to give database connections as shown in below image

3) Define the parameter in transformation ( in this example the table name should go as parameter).
Image A : Right Click on the empty space to get the transformation settings.
Image B : Database Connection Details
Parameter Name is : tableName


4) Come back to the properties of "Table input" & write select statement to retrieve the data.
Eg : SELECT * FROM product LIMIT 100
In above example "product" is the table name that you have to replace with the parameter.
i.e., SELECT * FROM ${tableName} LIMIT 100
Once you write the query, come down check "Replace variables in script"

5) Take a "Dummy" step and connect it to "Table input step" . Save the transformation & run it on "Dummy Step"( Right click dummy step and click on "Preview".
OUTPUT : Test 1 : With "region" table

OUTPUT : Result 1

OUTPUT : Test 2 : With "product" table
* Right click Dummy step then click on Preview
* Click on Configure & then in parameters tab give "product" for tableName value parameter.
OUTPUT : Result 2

3) Passing parameter(s) from job to transformation
* Crtl+Alt to create a new job
* From the "General" node of Design tab ( Appears left side) drag and drop "Transoformation step".
* Drag and drop "START" step and connect these two as shown in below image.

* Double click on "Transformation" step to set the properties & parameter information.
* Browse for the transformation file and then move to parameters tab
* Click on "Get Parameters" then you can find parameter get apper under Parameter tab.
* Right click on empty canvas of job to get its settings & move to Parameters tab and give parameter name as "tableName" and provide default value.
Save the job and run it.
IMP NOTE :
1) Parameter names in job & transformation should match.
2) You can create n number of parameters in job but can pass as many you wish.
3) In job design you should take "START" step to tell the job to start execution from there.
If you ignore you will get below error ( which took me awhile to solve it for the very first time).
Start of job execution
:A serious error occurred during job execution:
Couldnt find starting point in this job.
org.pentaho.di.core.exception.KettleJobException:
Couldnt find starting point in this job.
at org.pentaho.di.job.Job.execute(Job.java:516)
at org.pentaho.di.job.Job.run(Job.java:422)
Spoon - Job has ended.
References :
1) http://wiki.pentaho.com/display/EAI/Named+Parameters
2) http://diethardsteiner.blogspot.in/2013/07/pentaho-kettle-parameters-and-variables.html
3) http://wiki.pentaho.com/display/EAI/Substituting+variable+references+in+Job+Parameter+values
Hope this helps some one like me for the first time who is looking for parameters(named) concept :-)
Cheers :-)
:-) Happy New Year - Welcome - 2015 :-)
Tuesday, February 17, 2015
Freebie Pricing Table PSD Template
.jpg)
Free Download Pricing Table PSD Template. Download our Pricing Table Template brought to you by Webdesigneraid’s Team. Enjoy!
Type : PSD
Category : Web Elements
License : Free
Author : Webdesigneraid
Download
Monday, February 16, 2015
C Program to print table of any number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n;
cout<<"Enter a ny number:";
cin>>n;
cout<<"
";
for(i=1;i<=10;++i)
cout<<" "<<n<<"*"<<i<<"="<<n*i<<"
";
getch();
}
Professional Pricing Table PSD
.jpg)
Free Download Professional Pricing Table PSD. A trendy design yet very well organized to maximize the numbers of your clients. Enjoy!
Type : PSD
Category : Web Elements
License : Free
Author : Inspiredcore
Download
Sunday, February 15, 2015
Pricing Table PSD File
.jpg)
Free Download Pricing Table PSD. Fully vector price list ui for your landing pages. Enjoy!
Type : PSD
Category : Web Elements
License : Free
Author : 1000psd
Download
Saturday, February 14, 2015
Slick Pricing Table PSD UI
.jpg)
Free Download Slick Pricing Table UI PSD. I created this Slick Price Table with the help of a great tutorial and the help of Photoshop CS5. Enjoy!
Type : PSD
Category : Web Elements
License : Free
Author : Deviantart
Download
Thursday, February 12, 2015
Fetch selected columns from SQL query on Table Component using Penaho CDE
Hi....
A requirement made me to write this post which will talk about fetching few columns on the table component from SQL query.....
Requirement :
Get 5 columns using query in CDA but fetch only 4 columns on the table component...
Fetch columns first column to fifth column excluding 4th column...
Write below code PostFetch of table Component.
function removeColumns(cdaData) {
var valueColIndex = 3;
//var valueColIndex2=2; /*initializing 2nd colum with its index */
//var valueColIndex3=1; /*initializing 1st column with its index */
// Remove metadata column
cdaData.metadata.splice(valueColIndex, 1/*remove count*/);
//cdaData.metadata.splice(valueColIndex2, 1/*remove count*/);
//cdaData.metadata.splice(valueColIndex3, 1/*remove count*/);
// Remove resultset column, from each row
cdaData.resultset.forEach(function(row) {
row.splice(valueColIndex, 1/*remove count*/);
//row.splice(valueColIndex2, 1/*remove count*/);
//row.splice(valueColIndex3, 1/*remove count*/);
});
// Return modified cda data set
return cdaData;
}
Write below code in Pre Execution of Table Component
//Specify the columns which you are removin
function f() {
this.chartDefinition.readers = [
{indexes: 3 /* Value2 */},
//{indexes: 1 /* Value2 */}
//{indexes: 2 /* Value2 */}
];
}
Alternative solution which will reduce writing above code :
Write below code in "Post Execution" of table component. column indexes start from 1 ,2,3 and etc if you write this code.
function myTip()
{
$(th:nth-child(5),td:nth-child(5)).hide(); //hides 5th column
$(th:nth-child(),td:nth-child(10)).hide();//hides 10th column
}
NOTE:
1) Query fields indexes start from 0 and ends with N-1 where N is the number of fields coming from query.
2) You can fetch as many columns from the query result set as you want.
3) See the commented code to remove the other columns...
NOTE that the code in Pre Execution may not accurate but worked fine for the requirement.
Thank you.
References :
1) http://forums.pentaho.com/archive/index.php/t-143075.html
2) http://forums.pentaho.com/showthread.php?143075-specifying-columns-for-pie-chart-in-CDE
3)http://www.webdetails.pt/ctools/charts/jsdoc/symbols/pvc.options.charts.Chart.html#readers
A requirement made me to write this post which will talk about fetching few columns on the table component from SQL query.....
Requirement :
Get 5 columns using query in CDA but fetch only 4 columns on the table component...
Fetch columns first column to fifth column excluding 4th column...
Write below code PostFetch of table Component.
function removeColumns(cdaData) {
var valueColIndex = 3;
//var valueColIndex2=2; /*initializing 2nd colum with its index */
//var valueColIndex3=1; /*initializing 1st column with its index */
// Remove metadata column
cdaData.metadata.splice(valueColIndex, 1/*remove count*/);
//cdaData.metadata.splice(valueColIndex2, 1/*remove count*/);
//cdaData.metadata.splice(valueColIndex3, 1/*remove count*/);
// Remove resultset column, from each row
cdaData.resultset.forEach(function(row) {
row.splice(valueColIndex, 1/*remove count*/);
//row.splice(valueColIndex2, 1/*remove count*/);
//row.splice(valueColIndex3, 1/*remove count*/);
});
// Return modified cda data set
return cdaData;
}
Write below code in Pre Execution of Table Component
//Specify the columns which you are removin
function f() {
this.chartDefinition.readers = [
{indexes: 3 /* Value2 */},
//{indexes: 1 /* Value2 */}
//{indexes: 2 /* Value2 */}
];
}
Alternative solution which will reduce writing above code :
Write below code in "Post Execution" of table component. column indexes start from 1 ,2,3 and etc if you write this code.
function myTip()
{
$(th:nth-child(5),td:nth-child(5)).hide(); //hides 5th column
$(th:nth-child(),td:nth-child(10)).hide();//hides 10th column
}
NOTE:
1) Query fields indexes start from 0 and ends with N-1 where N is the number of fields coming from query.
2) You can fetch as many columns from the query result set as you want.
3) See the commented code to remove the other columns...
NOTE that the code in Pre Execution may not accurate but worked fine for the requirement.
Thank you.
References :
1) http://forums.pentaho.com/archive/index.php/t-143075.html
2) http://forums.pentaho.com/showthread.php?143075-specifying-columns-for-pie-chart-in-CDE
3)http://www.webdetails.pt/ctools/charts/jsdoc/symbols/pvc.options.charts.Chart.html#readers
Wednesday, February 11, 2015
C program to print table of a given number
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr(); //to clear the screen
printf("Enter any number:");
scanf("%d",&n);
printf("Table of %d is:
",n);
for(i=1;i<=10;++i)
printf("
%d*%d=%d",n,i,n*i);
getch(); //to stop the screen
}
Subscribe to:
Posts (Atom)