Customer Portal

Denormalizer example

Comments 6

  • Avatar
    admin
    0
    Comment actions Permalink
    Hi pro7,

    It looks like bug in Clover, but you didn't provide me enough information to advise you. Please send me:

    * version of clover
    * your graph (possibly simplified, privacy detail removed, ...)
    * sample of data

    Then I can reproduce and solve your problem.
  • Avatar
    pro7
    0
    Comment actions Permalink
    Thanks.
    We are running 3.0. Probably not a bug. Most likely my misunderstanding. A simple example below.


    Restaurant Rated
    Name Category Score

    Daniel Cost A
    Daniel Service B
    Daniel Food A+

    Blue Hill Cost B-
    Blue Hill Service A
    Blue Hill Food B
    Blue Hill Parking C

    Antonio's Cost A
    Antonio's Service B
    Antonio's Food A-


    Now let's say we are looking for a result like :

    Daniel | A | B | A+

    Blue Hill | B- | A | B | C

    Antonio's | A | B | A-

    Is Normalizer a correct choice for this type of transformation?

    If I understand correctly, we need to implement, at a minimum, a count() function, and a transform() function. What might they look like for the above example?

    Thank You

    pro7
  • Avatar
    pro7
    0
    Comment actions Permalink
    Sorry...I meant to say "Is Denormalizer a correct choice for this type of transformation?"
  • Avatar
    admin
    0
    Comment actions Permalink
    Hi pro7,

    yes, denormalizer is good component for this. See attached sample I created.

    It produces:

    INFO [TRASH0_0] - +-------+------------+-------+----------+-------+----------+
    INFO [TRASH0_0] - |Record |name |Cost |Service |Food |Parking |
    INFO [TRASH0_0] - +-------+------------+-------+----------+-------+----------+
    INFO [TRASH0_0] - |# 1 |Antonio's |A |B |A- | |
    INFO [TRASH0_0] - |# 2 |Blue Hill |B- |A |B |C |
    INFO [TRASH0_0] - |# 3 |Daniel |A |B |A+ | |
    INFO [TRASH0_0] - +-------+------------+-------+----------+-------+----------+
  • Avatar
    pro7
    0
    Comment actions Permalink
    Thank you. I'll study in detail but I'm wondering if the sample is using some feature not supported in my release (3.0)?

    I say this because when I open the graph I see errors.

    Unable to resolve input metadata 'in'
    Unable to resolve input metadata 'out'


    The sample has a Metadata named Result, and another named to_normalize_txt. I can change $in to $to_normalize_txt but I still get an error on the line
    of code in transform:

    $out.0.* = res.*;


    I tried a number of things here but can't get rid of the error. Anyway, thanks again, this might be enough to get me going in the right direction.

    pro7
  • Avatar
    admin
    0
    Comment actions Permalink
    For 3.0 you need to change CTL2 transformation to:


    //#CTL2

    Result res;

    function integer append() {
    //set name

    res.name = $0.Name;

    if ($0.Type=="Cost") {
    res.Cost = $0.Rate;
    } else if ($0.Type=="Service") {
    res.Service = $0.Rate;
    } else if ($0.Type=="Food") {
    res.Food = $0.Rate;
    } else if ($0.Type=="Parking") {
    res.Parking = $0.Rate;
    } else {
    raiseError("Unknown type '"+$0.Type+"'");
    }

    return OK;
    }

    function integer transform() {
    //send prepared record to output
    $0.* = res.*;
    return OK;
    }

    function void clean() {
    res.name = "";
    res.Cost = "";
    res.Service = "";
    res.Food = "";
    res.Parking = "";
    }

Please sign in to leave a comment.