获取Pentaho数据集成8 CE中的最后一位数字

获取Pentaho数据集成8 CE中的最后一位数字,pentaho,kettle,pentaho-data-integration,Pentaho,Kettle,Pentaho Data Integration,我有一个名为year的Integer字段,其中不出所料地包含了当前年份: 2019 我想提取今年的最后一位数字。在这种情况下,9,输出将是一个字符串(单个字符) 我尝试了用户定义的Java表达式,如下所示: Integer.toString(year).substring(Integer.toString(year).length() - 1) 但它给出了下面包含的错误我怎样才能得到今年的最后一位数? 你把问题复杂化了 在回答之前,请记住,有几个步骤和步骤的组合,可以实现数量惊人的转换,以生

我有一个名为
year
Integer
字段,其中不出所料地包含了当前年份:

2019
我想提取今年的最后一位数字。在这种情况下,
9
,输出将是一个
字符串(单个字符)

我尝试了
用户定义的Java表达式
,如下所示:

Integer.toString(year).substring(Integer.toString(year).length() - 1)
但它给出了下面包含的错误我怎样才能得到今年的最后一位数?


你把问题复杂化了

在回答之前,请记住,有几个步骤和步骤的组合,可以实现数量惊人的转换,以生成可用的模式,最后的手段是用户定义的Java表达式

使用选择值步骤将整数转换为字符串,然后使用公式步骤创建代码正确的新列([year];1)

2019/02/14 09:43:38 - Get last digit of month.0 - ERROR (version 8.2.0.0-342, build 8.2.0.0-342 from 2018-11-14 10.30.55 by buildguy) : Unexpected error
2019/02/14 09:43:38 - Get last digit of month.0 - ERROR (version 8.2.0.0-342, build 8.2.0.0-342 from 2018-11-14 10.30.55 by buildguy) : org.pentaho.di.core.exception.KettleException: 
2019/02/14 09:43:38 - Get last digit of month.0 - org.pentaho.di.core.exception.KettleValueException: 
2019/02/14 09:43:38 - Get last digit of month.0 - org.codehaus.janino.CompileException: Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 - Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 - 
2019/02/14 09:43:38 - Get last digit of month.0 - 
2019/02/14 09:43:38 - Get last digit of month.0 - org.codehaus.janino.CompileException: Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 - Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 - 
2019/02/14 09:43:38 - Get last digit of month.0 - 
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.pentaho.di.trans.steps.janino.Janino.processRow(Janino.java:113)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2019/02/14 09:43:38 - Get last digit of month.0 -   at java.lang.Thread.run(Unknown Source)
2019/02/14 09:43:38 - Get last digit of month.0 - Caused by: org.pentaho.di.core.exception.KettleValueException: 
2019/02/14 09:43:38 - Get last digit of month.0 - org.codehaus.janino.CompileException: Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 - Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 - 
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.pentaho.di.trans.steps.janino.Janino.calcFields(Janino.java:220)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.pentaho.di.trans.steps.janino.Janino.processRow(Janino.java:104)
2019/02/14 09:43:38 - Get last digit of month.0 -   ... 2 more
2019/02/14 09:43:38 - Get last digit of month.0 - Caused by: org.codehaus.janino.CompileException: Line 1, Column 17: No applicable constructor/method found for actual parameters "java.lang.Long"; candidates are: "java.lang.String java.lang.Integer.toString(int, int)", "java.lang.String java.lang.Integer.toString()", "java.lang.String java.lang.Integer.toString(int)", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()", "java.lang.String java.lang.Object.toString()"
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:8185)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:6052)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5923)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5862)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:4424)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.access$11400(UnitCompiler.java:108)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:4066)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2649)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:4086)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5862)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:4424)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.access$11400(UnitCompiler.java:108)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:4066)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2649)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:4086)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:6028)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5923)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5862)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3124)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.access$6300(UnitCompiler.java:108)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:2579)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2650)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:2599)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:3535)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1439)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.access$1700(UnitCompiler.java:108)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler$4.visitReturnStatement(UnitCompiler.java:748)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Java$ReturnStatement.accept(Java.java:1665)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:758)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:777)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.access$700(UnitCompiler.java:108)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler$4.visitBlock(UnitCompiler.java:738)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Java$Block.accept(Java.java:1280)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:758)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1783)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:723)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:705)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:431)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:329)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler$3.visitPackageMemberClassDeclaration(UnitCompiler.java:302)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:703)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:308)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:286)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:420)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:400)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:607)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:443)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Cookable.cook(Cookable.java:72)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Cookable.cook(Cookable.java:64)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.codehaus.janino.Cookable.cook(Cookable.java:114)
2019/02/14 09:43:38 - Get last digit of month.0 -   at org.pentaho.di.trans.steps.janino.Janino.calcFields(Janino.java:171)
2019/02/14 09:43:38 - Get last digit of month.0 -   ... 3 more