You can try getting the partition information from metadata.
1> get the metadata information from hive-site.xml file (location: /hive/installation/location/hive/hive-2.1/conf)
2> Get the env and credentials
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>[hostname]</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>UserName</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>PWD</value>
<description>password to use against metastore database</description>
</property>
3> connect to metastore, and below is the query to get partition information.
select D.NAME, P.PART_NAME, T.TBL_NAME from PARTITIONS P INNER JOIN TBLS T ON P.TBL_ID=T.TBL_ID INNER JOIN DBS D ON T.DB_ID=D.DB_ID WHERE D.NAME=<DBNAME> AND T.TBL_NAME=<TBLNAME> AND P.PART_NAME LIKE '%class=2%';
Once you have partition information, then you can make use of replace and concat function to derive alter statement.
Hope this helps.