मेरे पास एक Integer फ़ील्ड है जिसका नाम year है, जिसमें आश्चर्यजनक रूप से चालू वर्ष शामिल है:

2019

मैं साल का आखिरी अंक निकालना चाहता हूं। इस मामले में, 9, आउटपुट एक String (एकल वर्ण) होगा।

मैंने एक User defined Java Expression की कोशिश इस प्रकार की है:

Integer.toString(year).substring(Integer.toString(year).length() - 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
0
M.E. 14 फरवरी 2019, 11:45

1 उत्तर

सबसे बढ़िया उत्तर

आप इस मुद्दे को जटिल बना रहे हैं।

उत्तर से पहले, कुछ याद रखें, कई चरण हैं, और चरणों के संयोजन, प्रयोग करने योग्य पैटर्न बनाने के लिए अविश्वसनीय संख्या में परिवर्तन प्राप्त करते हैं, अंतिम उपाय IS उपयोगकर्ता परिभाषित जावा अभिव्यक्ति.

अपने पूर्णांक को स्ट्रिंग में बदलने के लिए मान चुनें चरण का उपयोग करें, उसके बाद कोड के साथ एक नया स्तंभ बनाने के लिए सूत्र चरण का उपयोग करें RIGHT([year];1)।

enter image description here

1
Cristian Curti 14 फरवरी 2019, 17:02