获取水壶pentaho流量的值
我和pentaho数据集成公司合作,Spoon 简短描述:我想获取从流中读取的每一行的值在流中出现的次数 详细描述:我正在做事实表的转换,当我读取csv文件的数据时,我有一个客户在特定时间乘坐某架飞机旅行。我想添加一个列,available seats,每当它读取客户乘坐混凝土飞机旅行的数据时,在前面的流程中查看该飞机的可用座位数,然后减去1 例如 最初,航班1有160个座位,航班2有320个座位获取水壶pentaho流量的值,pentaho,kettle,pentaho-spoon,pentaho-data-integration,Pentaho,Kettle,Pentaho Spoon,Pentaho Data Integration,我和pentaho数据集成公司合作,Spoon 简短描述:我想获取从流中读取的每一行的值在流中出现的次数 详细描述:我正在做事实表的转换,当我读取csv文件的数据时,我有一个客户在特定时间乘坐某架飞机旅行。我想添加一个列,available seats,每当它读取客户乘坐混凝土飞机旅行的数据时,在前面的流程中查看该飞机的可用座位数,然后减去1 例如 最初,航班1有160个座位,航班2有320个座位 CSV Flight | Client 1 | 1 2 | 2
CSV
Flight | Client
1 | 1
2 | 2
1 | 3
2 | 4
我可以添加一列,该列的值是可用座位的总数
Flight | Customer | Available seats
1 | 1 | 160
2 | 2 | 320
1 | 3 | 160
2 | 4 | 320
但后来我不知道如何在每次流量读数中获得给定航班的可用座位的最小值
我希望在流中得到的最终输出
Flight | Customer | Available seats
1 | 1 | 159
2 | 2 | 319
1 | 3 | 158
2 | 4 | 318
非常感谢您花时间阅读我的问题。您可以使用
添加值字段更改顺序
(在“转换”步骤组下提供)步骤为每个航班生成计数器。该步骤将要求输入按Flight
字段排序。您需要在此步骤中指定航班
字段,以便在新的航班组启动后重置计数器
然后,您将能够使用计算器/JavaScript/Java公式或任何其他步骤从可用座位
字段中减去计数器,以获得当前值
下面是一个示例,您可以将其复制并粘贴到画布上:
<?xml version="1.0" encoding="UTF-8"?>
<transformation-steps>
<steps>
<step>
<name>Add value fields changing sequence</name>
<type>FieldsChangeSequence</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<start>1</start>
<increment>1</increment>
<resultfieldName>counter</resultfieldName>
<fields>
<field>
<name>Flight</name>
</field>
</fields>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>352</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Data Grid</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<name>Flight</name>
<type>Integer</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
<field>
<name>Customer</name>
<type>Integer</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
<field>
<name>Total available seats</name>
<type>Integer</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
</fields>
<data>
<line> <item>1</item><item>1</item><item>160</item> </line>
<line> <item>2</item><item>2</item><item>320</item> </line>
<line> <item>1</item><item>3</item><item>160</item> </line>
<line> <item>2</item><item>4</item><item>320</item> </line>
</data>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>80</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Sort rows (by flight)</name>
<type>SortRows</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<directory>%%java.io.tmpdir%%</directory>
<prefix>out</prefix>
<sort_size>1000000</sort_size>
<free_memory/>
<compress>N</compress>
<compress_variable/>
<unique_rows>N</unique_rows>
<fields>
<field>
<name>Flight</name>
<ascending>Y</ascending>
<case_sensitive>N</case_sensitive>
<collator_enabled>N</collator_enabled>
<collator_strength>0</collator_strength>
<presorted>N</presorted>
</field>
</fields>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>192</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Calculator</name>
<type>Calculator</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<calculation>
<field_name>Available seats</field_name>
<calc_type>SUBTRACT</calc_type>
<field_a>Total available seats</field_a>
<field_b>counter</field_b>
<field_c/>
<value_type>Integer</value_type>
<value_length>-1</value_length>
<value_precision>-1</value_precision>
<remove>N</remove>
<conversion_mask/>
<decimal_symbol/>
<grouping_symbol/>
<currency_symbol/>
</calculation>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>496</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
</steps>
<order>
<hop>
<from>Add value fields changing sequence</from>
<to>Calculator</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Data Grid</from>
<to>Sort rows (by flight)</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows (by flight)</from>
<to>Add value fields changing sequence</to>
<enabled>Y</enabled>
</hop>
</order>
<notepads>
</notepads>
<step_error_handling>
</step_error_handling>
</transformation-steps>
添加值字段更改顺序
FieldSchange序列
Y
1.
没有一个
1.
1.
柜台
航班
352
96
Y
数据网格
数据网格
Y
1.
没有一个
航班
整数
-1
-1
N
顾客
整数
-1
-1
N
可用座位总数
整数
-1
-1
N
11160
22320
13160
24320
80
96
Y
对行进行排序(;乘航班);
索特罗斯
Y
1.
没有一个
%%;java.io.tmpdir%%;
出来
1000000
N
N
航班
Y
N
N
0
N
192
96
Y
计算器
计算器
Y
1.
没有一个
空位
减去
可用座位总数
柜台
整数
-1
-1
N
496
96
Y
添加值字段更改顺序
计算器
Y
数据网格
对行进行排序(;乘航班);
Y
对行进行排序(;乘航班);
添加值字段更改顺序
Y
您可以使用添加值字段更改顺序
(在“转换”步骤组下提供)步骤为每个航班生成计数器。该步骤将要求输入按Flight
字段排序。您需要在此步骤中指定航班
字段,以便在新的航班组启动后重置计数器
然后,您将能够使用计算器/JavaScript/Java公式或任何其他步骤从可用座位
字段中减去计数器,以获得当前值
下面是一个示例,您可以将其复制并粘贴到画布上:
<?xml version="1.0" encoding="UTF-8"?>
<transformation-steps>
<steps>
<step>
<name>Add value fields changing sequence</name>
<type>FieldsChangeSequence</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<start>1</start>
<increment>1</increment>
<resultfieldName>counter</resultfieldName>
<fields>
<field>
<name>Flight</name>
</field>
</fields>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>352</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Data Grid</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<name>Flight</name>
<type>Integer</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
<field>
<name>Customer</name>
<type>Integer</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
<field>
<name>Total available seats</name>
<type>Integer</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
</fields>
<data>
<line> <item>1</item><item>1</item><item>160</item> </line>
<line> <item>2</item><item>2</item><item>320</item> </line>
<line> <item>1</item><item>3</item><item>160</item> </line>
<line> <item>2</item><item>4</item><item>320</item> </line>
</data>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>80</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Sort rows (by flight)</name>
<type>SortRows</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<directory>%%java.io.tmpdir%%</directory>
<prefix>out</prefix>
<sort_size>1000000</sort_size>
<free_memory/>
<compress>N</compress>
<compress_variable/>
<unique_rows>N</unique_rows>
<fields>
<field>
<name>Flight</name>
<ascending>Y</ascending>
<case_sensitive>N</case_sensitive>
<collator_enabled>N</collator_enabled>
<collator_strength>0</collator_strength>
<presorted>N</presorted>
</field>
</fields>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>192</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Calculator</name>
<type>Calculator</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<calculation>
<field_name>Available seats</field_name>
<calc_type>SUBTRACT</calc_type>
<field_a>Total available seats</field_a>
<field_b>counter</field_b>
<field_c/>
<value_type>Integer</value_type>
<value_length>-1</value_length>
<value_precision>-1</value_precision>
<remove>N</remove>
<conversion_mask/>
<decimal_symbol/>
<grouping_symbol/>
<currency_symbol/>
</calculation>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>496</xloc>
<yloc>96</yloc>
<draw>Y</draw>
</GUI>
</step>
</steps>
<order>
<hop>
<from>Add value fields changing sequence</from>
<to>Calculator</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Data Grid</from>
<to>Sort rows (by flight)</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows (by flight)</from>
<to>Add value fields changing sequence</to>
<enabled>Y</enabled>
</hop>
</order>
<notepads>
</notepads>
<step_error_handling>
</step_error_handling>
</transformation-steps>
添加值字段更改顺序
FieldSchange序列
Y
1.
没有一个
1.
1.
柜台
航班
352
96
Y
数据网格
数据网格
Y
1.
没有一个
航班
整数
-1
-1
N
顾客
整数
-1
-1
N
可用座位总数
整数
-1
-1
N
11160
22320
13160
24320
80
96
Y
对行进行排序(;乘航班);
索特罗斯
Y
1.
没有一个
%%;java.io.tmpdir%%;
出来
1000000
N
N
航班
Y
N
N
0
N
192
96
Y
计算器
计算器
Y
1.
没有一个
空位
减去
可用座位总数
柜台
整数
-1
-1
N
496
96
Y
添加值字段更改顺序
计算器
Y
数据网格
对行进行排序(;乘航班);
Y
对行进行排序(;乘航班);
添加值字段更改顺序