简体   繁体   English

Pentaho勺子值映射

[英]Pentaho Spoon Value Mapping

I am new to the spoon tool and I am extracting one table values to load another table with same attributes. 我是勺子工具的新手,我正在提取一个表值以加载具有相同属性的另一个表。 In the first table there is a column holding nchar values like 'y' and 'no' which represents(yes and no). 在第一个表中,有一列包含nchar值(例如“ y”和“ no”),分别代表(是和否)。

My problem is the second table has a column that will hold these values as a tinyint like 'y' -> 1 and 'n' -> '0' 我的问题是第二个表有一列将这些值保存为tinyint,如“ y”-> 1和“ n”->“ 0”

table1 表格1

  • y ÿ
  • y ÿ
  • n ñ
  • n ñ
  • y ÿ

table2 表2

  • 1 1
  • 1 1
  • 0 0
  • 0 0
  • 1 1

So is there an easy way for replacing these values and changing their types by mapping them. 因此,有没有一种简便的方法可以替换这些值并通过映射它们来更改其类型。 I can do this job in my sql statement like below 我可以在下面的sql语句中完成此工作

SELECT CASE <variable> 
           WHEN <value>      THEN <returnvalue> 
           WHEN <othervalue> THEN <returnthis> 
           ELSE <returndefaultcase> 
       END 
  FROM <table> 

If there are only 'y' and 'n' values this solution would be okay but since there are lots of values in lots of tables like ('a'->2, 'b'->3, 'c'->4) it is kind of a headache for me now. 如果只有'y'和'n'值,此解决方案可以,但是由于很多表中都有很多值,例如('a'-> 2,'b'-> 3,'c'-> 4 )现在让我有些头疼。 If someone tells me a practical approach I would appreciate it. 如果有人告诉我一种实用的方法,我将不胜感激。

Use the value mapper step for something so simple or just use the case statement like you have. 对于简单的事情,可以使用值映射器步骤,或者像您一样使用case语句。 I wouldn't store that mapping in the database since it is so simple. 因为它是如此简单,所以我不会将其存储在数据库中。

In the valuemapper add a target field since the data types don't line up. 由于数据类型不对齐,因此在valuemapper中添加目标字段。 Then if you want to rename or replace the old column use the select values step 然后,如果要重命名或替换旧列,请使用“选择值”步骤

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM