Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Unable to edit a Javascript string following Fixed File Input

  1. #1
    Join Date
    Dec 2007
    Posts
    1

    Default Unable to edit a Javascript string following Fixed File Input

    I started with a working program that reads a single record from two files using Fixed File Input step. Each is passed to a Select/Rename to filter the fields and then merged in a Join step.

    The top flow has a file identifer CefFileId = "yyyyMMddHHmmss" that is also a datetime, which is converted to an additional field using a Javascript step.

    Code:
    java;
    var
    CefDateTime = CefFileId; CefDateTime = CefDateTime.substring(0,8) + " " + CefDateTime.substring(8,10) + ":" + CefDateTime.substring(10,12) + ":" + CefDateTime.substring(12,14);
    When this is run (compatatibility is off) I get the following error:

    Convert Datetime.0 - ERROR (version 3.0.0, build 500 from 2007/11/14 14:59:11) : Unexpected error :
    Convert Datetime.0 - ERROR (version 3.0.0, build 500 from 2007/11/14 14:59:11) : org.pentaho.di.core.exception.KettleValueException:
    Convert Datetime.0 - ERROR (version 3.0.0, build 500 from 2007/11/14 14:59:11) : Javascript error:
    Convert Datetime.0 - ERROR (version 3.0.0, build 500 from 2007/11/14 14:59:11) : Java class "[B" has no public instance field or method named "substring". (script#5)

    If I replace the Fixed File Input with a Generate Rows with identical structure and default data, the process runs fine. I have tried MANY different combination of old/new javascript with and without compatability and they all fail in one way or another. My first version used the older scripting form:

    Code:
    var
    CefDateTime = CefFileId.Clone(); CefDateTime = CefDateTime.substr(0,8);
    With compatability mode on, this will run until I try to write the field to a database (note that running to a Dummy step is ok) where I got this error.

    2007/12/05 15:49:27 - org.pentaho.di.ui.core.dialog.Previe...alog$6@11af7bb - ERROR (version 3.0.0, build 500 from 2007/11/14 14:59:11) : org.pentaho.di.core.exception.KettleValueException:
    2007/12/05 15:49:27 - org.pentaho.di.ui.core.dialog.Previe...alog$6@11af7bb - ERROR (version 3.0.0, build 500 from 2007/11/14 14:59:11) : CefFileId String(14)<binary-string> : There was a data type error: the data type of java.lang.String object [20071029124905] does not correspond to value meta [String(14)<binary-string>]

    The problem seems to originate back at the Javascript because if I look at the field output from that the CefFileId is shown blank. The Clone() does not appear to stop the field from being clobbered even though I don't write to it.

    And I can get this to work also, by creating the initial record via a Generate Rows in place of the Fixed File Input.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

  3. #3
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Lazy conversion exposes byte[] objects in the input row and as such also in the javascript variables.
    I think this is a mistake.

    For a quick solution: turn of lazy conversion.
    Also file a bug report and I'll fix it in the morning (CET) :-)

    Matt

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.