Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
yura_ratu
Partner - Creator II
Partner - Creator II

Upload new data and replace old one

Hi all,

I load new data every day and need not just concatenate it to previous one, but also make changes in old data according to a new data. Here is an example of tables

load * Inline [

a, b

1,2

2,3

3,8

];

load * Inline [

a, b

1,5

2,3

4,3

5,4

];

As a result of joining/concatenating them I would like to have

a, b

1,5

2,3

3,8

4,3

5,4

How can I do that?

1 Solution

Accepted Solutions
nagaiank
Specialist III
Specialist III

Try loading in the following order:

load * Inline [

a, b

1,5

2,3

4,3

5,4

];

Concatenate

load * Inline [

a, b

1,2

2,3

3,8

]

where not exists(a);

View solution in original post

9 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Here it is:

A:

NoConcatenate

load * Inline [

a, b

1,2

2,3

3,8

];

B:

NoConcatenate

load * Inline [

a, b

1,5

2,3

4,3

5,4

];

AB:

NoConcatenate

LOAD * Resident A;

Concatenate

LOAD * Resident B;

DROP Tables A, B;

Left Join

LOAD a, Max(b) as M Resident AB Group by a;

Final:

NoConcatenate

LOAD * Resident AB Where M = b;

DROP Table AB;

Not applicable

Can you try this

A:

load * Inline [

a, b

1,2

2,3

3,8

];

Concatenate

B:

load * Inline [

a, b

1,5

2,3

4,3

5,4

];

NoConcatenate

AB:

load distinct a, b

Resident A;

drop table A;

yura_ratu
Partner - Creator II
Partner - Creator II
Author

Thanks Alessandro!

But what if values are not numbers, or number which become both less or more. In final table should be value from second load, not matter what there

yura_ratu
Partner - Creator II
Partner - Creator II
Author

Result will be

1,2

1,5

2,3

3,8

4,3

5,4

nagaiank
Specialist III
Specialist III

Try loading in the following order:

load * Inline [

a, b

1,5

2,3

4,3

5,4

];

Concatenate

load * Inline [

a, b

1,2

2,3

3,8

]

where not exists(a);

Not applicable

You mean the result should be Ordered??

Not applicable

I get exactly the way you asked for the code snippet post my me earlier. Plz. see the screen shot.

yura_ratu
Partner - Creator II
Partner - Creator II
Author

I meant that should be unique "a" values, and "b" values from the latest load

yura_ratu
Partner - Creator II
Partner - Creator II
Author

It works! Thank you.

Could you please explain how this "where not exists(a)" statement works here?