Yep. It's not an ideal solution, but it gets you part of the way there. Hive doesn't have a way of specifying default values at schema level.
Phil. On Sep 5, 2012 11:38 PM, "MiaoMiao" <[email protected]> wrote: > You mean COALESCE(value,3)? This does work on int field, and easier than IF > > select value,COALESCE(value,3) from testtest; > 1 1 > 1 1 > 2 2 > NULL 3 > NULL 3 > > On Wed, Sep 5, 2012 at 7:52 PM, Philip Tromans > <[email protected]> wrote: > > You could do something with the coalesce UDF? > > > > Phil. > > > > On Sep 5, 2012 12:24 AM, "MiaoMiao" <[email protected]> wrote: > >> > >> I have a file whose content is: > >> 1,1 > >> 2,1 > >> 3,2 > >> 4, > >> 5, > >> Then I import in into a hive table. > >> create external table testtest (id int,value int) row format delimited > >> fields terminated by ',' stored as textfile location '/wtt/test/def'; > >> select * from testtest; > >> 1 1 > >> 2 1 > >> 3 2 > >> 4 NULL > >> 5 NULL > >> > >> I want to set default value for value, but seems hive simply doesn't > >> have this feature, any idea? > >> 1 1 > >> 2 1 > >> 3 2 > >> 4 3 > >> 5 3 >
