Interpolate query

Moderator: NorbertKrupa

Post Reply
malargopal
Newbie
Newbie
Posts: 23
Joined: Mon Feb 04, 2013 10:54 am

Interpolate query

Post by malargopal » Mon Jul 01, 2013 12:30 pm

Hi All,

Normal table out put;

x | y
----------+----------
12:40:23 | 12:40:23
14:40:25 |
14:45:00 |
14:49:55 |
| 14:00:00
(5 rows)

Full outer join with interpolation:


SELECT * FROM t FULL OUTER JOIN t1 ON t.x INTERPOLATE PREVIOUS VALUE t1.y;


x | y
----------+----------
12:40:23 | 12:40:23
12:40:23 | 14:00:00
14:40:25 | 14:00:00
14:45:00 | 14:00:00
14:49:55 | 14:00:00
(5 rows)

as per the query the y's previous values are padded with null values.

But how we got the value '14:49:55' in x.

Please explain 'X' values.

Thanks,
Malar

User avatar
nnani
Master
Master
Posts: 302
Joined: Fri Apr 13, 2012 6:28 am
Contact:

Re: Interpolate query

Post by nnani » Mon Jul 01, 2013 3:20 pm

Hello Malar,

Interpolate joins are time series joins, basically a simple extension to outer joins( Full, Left, Right)

It will look for the matches between the t.x and t1.y
If it finds one, then The records can be seen together and there will be no null pads corresponding to that value as here

Code: Select all

x | y
----------+----------
12:40:23 | 12:40:23
But if there are no matches then we can see the previous records in the null table columns.
Basically you can think of it as sorting the columns in ascending order with matching columns

The value '14:49:55' is already in the table 't' and its a FULL OUTER JOIN. so there should be no surprises, If we see this value

Fow a deeper understanding on this, you can refer this topic
http://stackoverflow.com/questions/1707 ... te-feature

Hope this helps you :)
nnani........
Long way to go

You can check out my blogs at vertica-howto

malargopal
Newbie
Newbie
Posts: 23
Joined: Mon Feb 04, 2013 10:54 am

Re: Interpolate query

Post by malargopal » Tue Jul 02, 2013 2:30 pm

Hi

Thank you for the reply.
In this interpolated query result
x|y
------------------------
12:40:23 | 12:40:23
12:40:23 | 14:00:00
14:40:25 | 14:00:00
14:45:00 | 14:00:00
14:49:55 | 14:00:00

in x this value is repeated one more time (12:40:23).

Post Reply

Return to “Vertica Database Development”