Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-17078

Dedup ALL in child query could lose rows if not fully read (e.g. if above a CHOOSEN/EXISTS)

    XMLWordPrintable

    Details

      Description

      The following code produces different results from a SORT/DEDUP versus a DEDUP, ALL on a nested child dataset (W20170214-145408):

      layout_vehicle := RECORD
         unsigned8 personid;
         string2 orig_state;
         unsigned2 year_make;
         string5 make_code;
         string4 vehicle_type;
         string3 model;
         string5 body_code;
         string1 vehicle_use;
         string3 major_color_code;
         string3 minor_color_code;
         unsigned2 model_year;
         string3 vina_series;
         string3 vina_model;
         string2 vina_body_style;
         string36 make_description;
         string36 model_description;
         string25 body_style_description;
         string2 number_of_cylinders;
         string4 engine_size;
         string1 fuel_code;
         unsigned4 vina_price;
         string1 history;
         string5 best_make_code;
         string3 best_series_code;
         string3 best_model_code;
         string5 best_body_code;
         unsigned2 best_model_year;
         string3 best_major_color_code;
         string3 best_minor_color_code;
         string8 purch_date;
        END;
      
      layout_Taxrecs := RECORD
          integer8 propertyid;
          string4 document_year;
          unsigned4 total_val_calc;
          unsigned4 land_val_calc;
          unsigned4 improvement_value_calc;
          unsigned4 assd_total_val;
          unsigned4 tax_amount;
          unsigned4 mkt_total_val;
          unsigned4 mkt_land_val;
          unsigned4 mkt_improvement_val;
          unsigned4 tax_year;
          unsigned4 land_square_footage;
          unsigned4 adjusted_gross_square_feet;
          unsigned4 living_square_feet;
          unsigned2 bedrooms;
          unsigned2 full_baths;
          unsigned2 half_baths;
          unsigned2 stories_number;
         END;
      
      layout_proptax := RECORD
         unsigned8 personid;
         integer8 propertyid;
         string10 house_number;
         string10 house_number_suffix;
         string2 predir;
         string30 street;
         string5 streettype;
         string2 postdir;
         string6 apt;
         string40 city;
         string2 state;
         string5 zip;
         unsigned4 total_value;
         unsigned4 assessed_value;
         unsigned2 year_acquired;
         unsigned4 land_square_footage;
         unsigned4 living_square_feet;
         unsigned2 bedrooms;
         unsigned2 full_baths;
         unsigned2 half_baths;
         unsigned2 year_built;
         unsigned1 childcount;
         DATASET(layout_Taxrecs) taxrecs{maxcount(20)};
        END;
      
      Layout := RECORD
        unsigned8 id;
        string15 firstname;
        string25 lastname;
        string15 middlename;
        string2 namesuffix;
        string8 filedate;
        string1 gender;
        string8 birthdate;
        unsigned1 childvcount;
        unsigned1 childpcount;
        DATASET(layout_vehicle) vehiclerecs{maxcount(20)};
        DATASET(layout_proptax) proprecs{maxcount(20)};
       END;
      
      
      People   := DATASET('~CLASS::RT::OUT::PeopleAll',Layout,THOR);
      Vehicle  := People.Vehiclerecs;
      Property := People.PropRecs;
      Taxdata  := People.PropRecs.TaxRecs;
      
      SortedVehicles := SORT(Vehicle,Make_code);
      DedupVehicles1  := DEDUP(SortedVehicles,Make_code);
      CountUniqueMakeVehicles := IF(~EXISTS(DedupVehicles1),
                                           -9,
                                           COUNT(DedupVehicles1));
      
      DedupVehicles2     := DEDUP(Vehicle,Make_code,ALL);
      CountUniqueMakeVehiclesAll := IF(~EXISTS(DedupVehicles2),
                                              -9,
                                              COUNT(DedupVehicles2));
      c1 := COUNT(People(CountUniqueMakeVehicles > 0));
      c2 := COUNT(People(CountUniqueMakeVehicles < 0));
      c3 := COUNT(People(CountUniqueMakeVehiclesALL > 0));
      c4 := COUNT(People(CountUniqueMakeVehiclesALL < 0));
      c5 := COUNT(People(EXISTS(People.Vehiclerecs)));
      
      DATASET([
      	{'CountUniqueMakeVehicles > 0',c1},
      	{'CountUniqueMakeVehicles < 0',c2},
      	{'CountUniqueMakeVehiclesAll > 0',c3},
      	{'CountUniqueMakeVehiclesAll < 0',c4},
      	{'EXISTS(People.Vehiclerecse)',c5}],
      	{STRING30 prompt,INTEGER val});
      	
      SetID1 := SET(People(CountUniqueMakeVehicles > 0),id);
      SetID2 := SET(People(CountUniqueMakeVehiclesALL > 0),id);
      
      ds1 := DATASET(SetID1,{unsigned8 id});
      ds2 := DATASET(SetID2,{unsigned8 id});
      
      SetNonMatches := SET(JOIN(ds1,ds2,left.id=right.id,LEFT ONLY),id);
      
      OUTPUT(People(id IN SetNonMatches),{CountUniqueMakeVehicles,CountUniqueMakeVehiclesALL,people});
      

        Attachments

          Activity

            People

            • Assignee:
              jakesmith Jake Smith
              Reporter:
              richardtaylorhpcc Richard Taylor
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: