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.  How to check if a Field exists ?

    Employee
    Posted 01-28-2015 10:16

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

    Originally posted by: gauravdb

    Hi,

    I know this question has been asked few times but doesn't answer my question so re-posting again.

    I have a set of data coming into filter node and there is an attribute X which may not be present every time. So How do I emit X attribute as "null" or "Not Present" etc ONLY if it is missing ??



    Thanks
    GK


  • 2.  RE: How to check if a Field exists ?

    Employee
    Posted 01-28-2015 11:22

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

    Originally posted by: ejones

    Assuming the data type is string and you actually want NULL you could do the following.

    default emit str(null) as "X"

    Replace the str(null) with "null" or "Not Present" or whatever you want the default value to be.


  • 3.  RE: How to check if a Field exists ?

    Employee
    Posted 01-28-2015 12:05

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

    Originally posted by: stonysmith

    Are you saying that the Column might not exist, or that some row of the data might be missing?

    Ernest's answer above is correct if you need to (optionally) add a column.

    If you need to fix individual rows, this might help:


    emit *
    override emit MyField=ifNull(Myfield,"Missing)


  • 4.  RE: How to check if a Field exists ?

    Employee
    Posted 01-29-2015 05:16

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

    Originally posted by: gauravdb

    Thanks Ernest and Smith.

    Yeah I was looking for what Ernest said. Solves my issue.
    But thanks to Smith as well for teaching me another trick.

    GK