Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Conversion of a String to an Integer

  1. #1

    Default Conversion of a String to an Integer

    HI,
    I have a requirement in which a string(contains only digits) should be concatenated with an integer to give an Integer output

    Year-String
    Period-Integer

    [Period] = [Year]&1

    I gave the above expression in a formula step and used a select values step to convert Period to an integer.

    But it is throwing an error saying

    Period Integer : There was a data type error: the data type of java.lang.String object [20111] does not correspond to value meta [Integer]


    Please help..

  2. #2
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    Have you checked that your formula step creates an Integer data type?
    In addition, I would right click on your "Select Value" step and choose: show output fields..
    check that your "period" field has been converted into an Integer.

    Mick
    Last edited by Mick_data; 12-07-2011 at 07:00 AM. Reason: forgot comment

  3. #3
    Join Date
    Apr 2009
    Posts
    337

    Default

    what is the formula step's return type?
    Regards,
    Madhu

  4. #4

    Default

    The formula step's return type is string.. I tried giving an integer/number, but of no use..

    I checked the 'show output fields' in 'select values'.. Period is shown as an integer..

    But while writing it to some output(textfile/DB) it is throwing the said error..

  5. #5
    Join Date
    Apr 2009
    Posts
    337

    Default

    Try removing the formula and adding a user defined java expression or something which is more "type-cast friendly", than the formula step!
    Regards,
    Madhu

  6. #6
    Join Date
    Dec 2011
    Posts
    2

    Default

    Hi!

    I got he same issue with one field set to number and my target field was also a number

    but when I ran the job I got the error message : can't convert string to number! whereas it was a number!

    So I used a select valeu objet to force the type to number but no way It didn't work

    so finally it worked fine by setting the type value into "String" in the select value objet!

    which not logical but it worked!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.