1 Reply Latest reply: May 22, 2018 4:19 AM by kaan erisen RSS

    The load script issues

    junzai xiao

      I have the following two tables,

      table1:

      abcd
      1234
      5678
      11223344
      55667788
      1111
      2222
      3333
      4444
      5555

       

      table2:

       

      ijkl
      4321
      9876
      99887766
      55443322
      1111
      2222
      9999
      8888
      7777

       

      What I want to do is to match the content of table1 with the content of table2. If the content of table2 exists in table1, it is deleted in table1, and if it does not exist, the content of table2 is inserted into table1.

      Thanks a lot!

        • Re: The load script issues
          kaan erisen

          Hi junzai,

           

          You can use AutoNumberHash128 and Exists functions to check if the row occurs in both table.

           

          Script:

           

          Table1:

          Load *,AutoNumberHash128(A,B,C,D) as RowKey1 inline [

          "A","B","C","D"

          1,2,3,4

          5,6,7,8

          11,22,33,44

          55,66,77,88

          1,1,1,1

          2,2,2,2

          3,3,3,3

          4,4,4,4

          5,5,5,5

          ];

           

          Table2:

          Load *,AutoNumberHash128(I, J, K, L) as RowKey2 inline [

          "I","J","K","L"

          4,3,2,1

          9,8,7,6

          99,88,77,66

          55,44,33,22

          1,1,1,1

          2,2,2,2

          9,9,9,9

          8,8,8,8

          7,7,7,7

          ];

           

          Master:

          LOAD A,B,C,D Resident Table1

          WHERE NOT Exists(RowKey2,RowKey1);

          Concatenate

          LOAD I AS A, J AS B, K AS C, L AS D Resident Table2

          WHERE NOT Exists(RowKey1,RowKey2);

           

          DROP TABLES Table1,Table2;

           

          Output:

          Untitled.png