You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by afancy <gr...@gmail.com> on 2010/11/15 10:09:19 UTC

How to generate global unique ID?

Hi,

Does anybody know how to generate a unique ID in Hive? I have a table:
hive> describe results;
OK
id int
test string

Time taken: 0.091 seconds


When I insert data into the table results, i want to generate a unqiue Id,
which is like a sequence in RDBMS.

Regards,
afancy

Re: How to generate global unique ID?

Posted by "איל (Eyal)" <ey...@gmail.com>.
Write a UDF that generates a UUID in Java

something like this:

@description(name = "uuid", value = "_FUNC_() - Generate a unique uuid")
@SuppressWarnings({"UnusedDeclaration"})
public class Uuid extends UDF{
  public Text evaluate() {
    return new Text(UUID.randomUUID().toString());
  }
}

On Tue, Nov 16, 2010 at 10:23 AM, afancy <gr...@gmail.com> wrote:

> Hi, Tim,
>
> I think sequential integer would be better. Is it difficult to generate a
> global integer?
> BTW: how to generate UUID in Hive? thanks
>
> Regards,
> afancy
>
> On Tue, Nov 16, 2010 at 9:11 AM, Tim Robertson <ti...@gmail.com>wrote:
>
>> Does it need to be a sequential INT? If not, then a UUID works very well.
>>
>> Cheers,
>> Tim
>>
>>
>> On Tue, Nov 16, 2010 at 8:55 AM, afancy <gr...@gmail.com> wrote:
>> > Hi, Zhang,
>> > How to integrate this snowflake with Hive?  Thanks!
>> > Regards,
>> > afancy
>> >
>> > On Mon, Nov 15, 2010 at 10:35 AM, Jeff Zhang <zj...@gmail.com> wrote:
>> >>
>> >> Please refer https://github.com/twitter/snowflake
>> >>
>> >>
>> >>
>> >> On Mon, Nov 15, 2010 at 5:09 PM, afancy <gr...@gmail.com> wrote:
>> >> > Hi,
>> >> > Does anybody know how to generate a unique ID in Hive? I have a
>> table:
>> >> > hive> describe results;
>> >> > OK
>> >> > id int
>> >> > test string
>> >> > Time taken: 0.091 seconds
>> >> >
>> >> > When I insert data into the table results, i want to generate a
>> unqiue
>> >> > Id,
>> >> > which is like a sequence in RDBMS.
>> >> > Regards,
>> >> > afancy
>> >>
>> >>
>> >>
>> >> --
>> >> Best Regards
>> >>
>> >> Jeff Zhang
>> >
>> >
>>
>
>

Re: How to generate global unique ID?

Posted by afancy <gr...@gmail.com>.
Hi, Tim,

I think sequential integer would be better. Is it difficult to generate a
global integer?
BTW: how to generate UUID in Hive? thanks

Regards,
afancy

On Tue, Nov 16, 2010 at 9:11 AM, Tim Robertson <ti...@gmail.com>wrote:

> Does it need to be a sequential INT? If not, then a UUID works very well.
>
> Cheers,
> Tim
>
>
> On Tue, Nov 16, 2010 at 8:55 AM, afancy <gr...@gmail.com> wrote:
> > Hi, Zhang,
> > How to integrate this snowflake with Hive?  Thanks!
> > Regards,
> > afancy
> >
> > On Mon, Nov 15, 2010 at 10:35 AM, Jeff Zhang <zj...@gmail.com> wrote:
> >>
> >> Please refer https://github.com/twitter/snowflake
> >>
> >>
> >>
> >> On Mon, Nov 15, 2010 at 5:09 PM, afancy <gr...@gmail.com> wrote:
> >> > Hi,
> >> > Does anybody know how to generate a unique ID in Hive? I have a table:
> >> > hive> describe results;
> >> > OK
> >> > id int
> >> > test string
> >> > Time taken: 0.091 seconds
> >> >
> >> > When I insert data into the table results, i want to generate a unqiue
> >> > Id,
> >> > which is like a sequence in RDBMS.
> >> > Regards,
> >> > afancy
> >>
> >>
> >>
> >> --
> >> Best Regards
> >>
> >> Jeff Zhang
> >
> >
>

Re: How to generate global unique ID?

Posted by Tim Robertson <ti...@gmail.com>.
Does it need to be a sequential INT? If not, then a UUID works very well.

Cheers,
Tim


On Tue, Nov 16, 2010 at 8:55 AM, afancy <gr...@gmail.com> wrote:
> Hi, Zhang,
> How to integrate this snowflake with Hive?  Thanks!
> Regards,
> afancy
>
> On Mon, Nov 15, 2010 at 10:35 AM, Jeff Zhang <zj...@gmail.com> wrote:
>>
>> Please refer https://github.com/twitter/snowflake
>>
>>
>>
>> On Mon, Nov 15, 2010 at 5:09 PM, afancy <gr...@gmail.com> wrote:
>> > Hi,
>> > Does anybody know how to generate a unique ID in Hive? I have a table:
>> > hive> describe results;
>> > OK
>> > id int
>> > test string
>> > Time taken: 0.091 seconds
>> >
>> > When I insert data into the table results, i want to generate a unqiue
>> > Id,
>> > which is like a sequence in RDBMS.
>> > Regards,
>> > afancy
>>
>>
>>
>> --
>> Best Regards
>>
>> Jeff Zhang
>
>

Re: How to generate global unique ID?

Posted by afancy <gr...@gmail.com>.
Hi, Zhang,

How to integrate this snowflake <https://github.com/twitter/snowflake> with
Hive?  Thanks!

Regards,
afancy

On Mon, Nov 15, 2010 at 10:35 AM, Jeff Zhang <zj...@gmail.com> wrote:

> Please refer https://github.com/twitter/snowflake
>
>
>
> On Mon, Nov 15, 2010 at 5:09 PM, afancy <gr...@gmail.com> wrote:
> > Hi,
> > Does anybody know how to generate a unique ID in Hive? I have a table:
> > hive> describe results;
> > OK
> > id int
> > test string
> > Time taken: 0.091 seconds
> >
> > When I insert data into the table results, i want to generate a unqiue
> Id,
> > which is like a sequence in RDBMS.
> > Regards,
> > afancy
>
>
>
> --
> Best Regards
>
> Jeff Zhang
>

Re: How to generate global unique ID?

Posted by Jeff Zhang <zj...@gmail.com>.
Please refer https://github.com/twitter/snowflake



On Mon, Nov 15, 2010 at 5:09 PM, afancy <gr...@gmail.com> wrote:
> Hi,
> Does anybody know how to generate a unique ID in Hive? I have a table:
> hive> describe results;
> OK
> id int
> test string
> Time taken: 0.091 seconds
>
> When I insert data into the table results, i want to generate a unqiue Id,
> which is like a sequence in RDBMS.
> Regards,
> afancy



-- 
Best Regards

Jeff Zhang