LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Issues converting data (double, number, string)

    Employee
    Posted 09-09-2015 01:20

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gabygyy

    hi,
    1.
    i'm trying to write some data into an orcale table and the data is not inserted as expected
    the logic is:
    step1 read an xls files as unicode
    step2 using a configuration table and change metadata i give to every column the desired data type(for eg: if in the configuration table type is varchar2 then the type is string, for number type is double)
    step3 adapted result from step2 is inserted without errors in the table
    After checking the result in the table i see that values from table like
    1373697122130450793
    is inserted like this
    1,37369712213045E18

    2.
    same input data i want to write in to an output file and the data is writen with the power of E
    I 'am aware of the function format("%0.0F",field) but the data has around 100 columns and on these columns we have also null values. The format function return error if the field is null.


    For writing the data i'm using a filter node in which i have a strcat with all the columns concatenated.
    if the input is customerid type double 1932476965.0
    when existing from filter node has value echo "1.93248e+09

    Please help me with the two cases!


  • 2.  RE: Issues converting data (double, number, string)

    Employee
    Posted 09-09-2015 07:16

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    Originally posted by: gabygyy
    					

    hi,
    1.
    i'm trying to write some data into an orcale table and the data is not inserted as expected
    the logic is:
    step1 read an xls files as unicode
    step2 using a configuration table and change metadata i give to every column the desired data type(for eg: if in the configuration table type is varchar2 then the type is string, for number type is double)
    step3 adapted result from step2 is inserted without errors in the table
    After checking the result in the table i see that values from table like
    1373697122130450793
    is inserted like this
    1,37369712213045E18
    Thanks. Interesting question. I' curious what this number represents. Are you really doing something where you need that many digits?
    For a double, there is really no difference between these two representations of the same number. This shows the limitation of the double datatype most often used for representing floating point numbers in all software. You can read about all the details of how this type works here, https://en.wikipedia.org/wiki/Double...g-point_format
    The double gives you 15 to 17 "significant decimal digits precision". It looks to me like it is performing as expected because the first 15 digits of the two numbers are exactly the same. Any representation of a real number is an approximation and will have limits. And usually 15 digits is much more accuracy than required.
    A long datatype gives you a few more digits but depending on what you are needing, it might not work. But you are right up near the limit of what it can do for you. So what is the use case?

    Originally posted by: gabygyy
    					

    2.
    same input data i want to write in to an output file and the data is writen with the power of E
    I 'am aware of the function format("%0.0F",field) but the data has around 100 columns and on these columns we have also null values. The format function return error if the field is null.


    For writing the data i'm using a filter node in which i have a strcat with all the columns concatenated.
    if the input is customerid type double 1932476965.0
    when existing from filter node has value echo "1.93248e+09

    Please help me with the two cases!
    So your current code is probably this:
    emit format("%0.0F",field) as "Field Name"
    To deal correctly with nulls you can change it to this:
    emit (if field.isNull() then str(null) else format("%0.0F",field)) as "Field Name"


  • 3.  RE: Issues converting data (double, number, string)

    Employee
    Posted 09-09-2015 07:20

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gabygyy

    YES, I've used allready this workaround to test if the value is null and then apply the conversion.
    the number is an id - for exampla customer id or offer id, and i need all digits.
    another workaround is to transform the target column in string instead of number


  • 4.  RE: Issues converting data (double, number, string)

    Employee
    Posted 09-09-2015 07:30

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    Great. So the long type could work, but string is probably safer for id's like this.


  • 5.  RE: Issues converting data (double, number, string)

    Employee
    Posted 09-09-2015 08:25

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gabygyy

    long does not work. the problem is that these must be done manualy while i'm trying to use something generic.
    i'm using metadata node and change metadata to adapt types of data but i can not use format in these nodes.