Fri Nov 16, 2018 2:36 pm
Login Register Lost Password? Contact Us


Converting field types of records

Comments and questions related to the Enterprise Control Language

Mon Sep 10, 2018 1:19 pm Change Time Zone

Hey,

I have two published layouts that I cannot change from the source. When ECL tries to join these two, it complains because they both have a field variable COLUMNX, however, in one of the record structures this variable is a string and in the other, it is an integer. I'm trying to find the proper project transform syntax to accomplish converting the entire field to a different datatype(say the integer to a string.) Is this possible? If so please point me in the direction of some good material to help, looking at the ECL manual didn't help much for me.
jtaylor306
 
Posts: 4
Joined: Fri Aug 17, 2018 2:57 pm

Tue Sep 11, 2018 6:40 pm Change Time Zone

There are two topics in the ECL Language Reference that may help:
Type Casting
http://cdn.hpccsystems.com/releases/CE- ... df#page=54

The TRANSFER function
http://cdn.hpccsystems.com/releases/CE- ... f#page=354

HTH,

Jim
JimD
 
Posts: 136
Joined: Wed May 18, 2011 1:35 pm

Tue Sep 11, 2018 8:46 pm Change Time Zone

JimD wrote:There are two topics in the ECL Language Reference that may help:
Type Casting
http://cdn.hpccsystems.com/releases/CE- ... df#page=54

The TRANSFER function
http://cdn.hpccsystems.com/releases/CE- ... f#page=354

HTH,

Jim

Thanks. So is there no way to alter the original field type of record? Or would the best way be to copy the entire record structure, add "string myfield;" copy all values from "integer myfield" to the new string field that I've created.And then somehow delete the field "integer myfield".

Basically, I need to change the way the field is defined within the record structure, not necessarily change each value 1 at a time.
jtaylor306
 
Posts: 4
Joined: Fri Aug 17, 2018 2:57 pm

Thu Sep 13, 2018 7:29 am Change Time Zone

Hi,

Reading:

Basically, I need to change the way the field is defined within the record structure, not necessarily change each value 1 at a time.

You can run a one-off PROJECT (remember to use LOCAL qualifier) to convert to the new structure, OUTPUT it to a differently named logical file. Then use either ECLWatch or the file manipulation functions in the standard Library (STD) to replace the existing file with the one in the new format. Remember to check in your change to the RECORD structure, and there you go, one pristine new file ready to go.

Yours
Allan
Allan
 
Posts: 319
Joined: Sat Oct 01, 2011 7:26 pm

Thu Sep 13, 2018 2:21 pm Change Time Zone

jtaylor306,
So is there no way to alter the original field type of record?
That depends on whether the file was sprayed to your cluster or written to your cluster using ECL.
  • If the file was sprayed, you can just define that field as any type you want it to be (as long as it's consistent with the actual data).
  • If the file was written using ECL, then NO, you cannot change its type (or name) from what it was originally written as. That's because the DFU keeps that information as metadata about the file. In that case, Allan's suggestion would be best.
HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1390
Joined: Wed Oct 26, 2011 7:40 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest

cron