If you're able to turn off write access to the table from elsewhere temporarily, you could always SELECT the values and store them somewhere else (e.g., a new table) for the moment, drop and recreate the column, and then UPSERT them back in.
It would be nice to think there's a better way, though. When column name indirection is in place, you'll at least be able to do this without needing a new table: add new column, copy data, rename old column to something else, rename new column to whatever old column was called, drop old column. On 22 Feb 2016 9:04 a.m., "Sandeep Nemuri" <[email protected]> wrote: > Hi All, > > We have a situation where we have to change the datatype of the existing > column of a phoenix table from INTEGER to BIGINT. > is there a way to alter the datatype without loosing the existing data? > > Have tried to take the snapshot of hbase table and restored it in a new > pheonix table with new datatype. > > but when selecting the altered columns it throws the following error. > > java.lang.RuntimeException: java.sql.SQLException: ERROR 201 (22000): > Illegal data. ERROR 201 (22000): Illegal data. ERROR 201 (22000): Illegal > data. Expected length of *at least 8 bytes, but had 4* > at sqlline.SqlLine$IncrementalRows.hasNext(SqlLine.java:2440) > at sqlline.SqlLine$TableOutputFormat.print(SqlLine.java:2074) > at sqlline.SqlLine.print(SqlLine.java:1735) > at sqlline.SqlLine$Commands.execute(SqlLine.java:3683) > at sqlline.SqlLine$Commands.sql(SqlLine.java:3584) > at sqlline.SqlLine.dispatch(SqlLine.java:821) > at sqlline.SqlLine.begin(SqlLine.java:699) > at sqlline.SqlLine.mainWithInputRedirection(SqlLine.java:441) > at sqlline.SqlLine.main(SqlLine.java:424) > > > > -- > * Regards* > * Sandeep Nemuri* > ᐧ >
