Weird behavior with RANDOMINT

Moderator: NorbertKrupa

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Weird behavior with RANDOMINT

Post by id10t » Tue Sep 24, 2013 4:42 pm

Hi!

@heather
everything is ok, I think Jim already explained to you or you understood from examples :)))

Im an idiot!!!
I thought that RANDOMINT generated only once :D


PS
https://github.com/sKwa/vertica/blob/ma ... _funcs.sql

Code: Select all

------
-- Returns random timestamp between 2 other timestamps
-- @ts1 - lower bound timestamp candidate
-- @ts2 - upper bound timestamp candidate
-- @return - random timestamp between LowB and UpB
------
CREATE OR REPLACE FUNCTION random_ts(ts1 TIMESTAMP, ts2 TIMESTAMP)
RETURN TIMESTAMP
  AS BEGIN
    RETURN TO_TIMESTAMP(
               EXTRACT(EPOCH FROM ts1) +
               RANDOMINT(FLOOR(@ EXTRACT(EPOCH FROM ts2) - EXTRACT(EPOCH FROM ts1))::INT));
  END;

Post Reply

Return to “New to Vertica Database Development”