给Kudu表增加字段
发布时间
阅读量:
阅读量
命令行方式无法给kudu增加字段,现用java代码实现
package org.kududb.examples.sample;
import org.apache.kudu.Type;
import org.apache.kudu.client.*;
public class Test_Kudu {
//获取系统环境变量
private static final String KUDU_MASTER = System.getProperty(
"kuduMaster", "10.138.232.87");
public static void main(String[] args) {
System.out.println("Will try to connect to Kudu master at " + KUDU_MASTER);
System.out.println("Run with -DkuduMaster=myHost:port to override.");
String tableName = "test.test_kudu";
KuduClient client = new KuduClient.KuduClientBuilder(KUDU_MASTER).build();
//新增一列
AlterTableOptions alterTableOptions = new AlterTableOptions();
alterTableOptions.addNullableColumn("village", Type.STRING);
try {
client.alterTable(tableName, alterTableOptions);
System.out.println("增加一列");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
client.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
全部评论 (0)
还没有任何评论哟~
