StringsqlCreateTableSushiLog="CREATE TABLE IF NOT EXISTS sushilog(source TEXT, repository TEXT, rid TEXT, date TEXT, metric_type TEXT, count INT, PRIMARY KEY(source, repository, rid, date, metric_type));";
stmtHive.executeUpdate(sqlCreateTableSushiLog);
// String sqlCopyPublicSushiLog="INSERT INTO sushilog SELECT * FROM public.sushilog;";
// stmt.executeUpdate(sqlCopyPublicSushiLog);
StringsqlcreateRuleSushiLog="CREATE OR REPLACE RULE ignore_duplicate_inserts AS "
+" ON INSERT TO sushilog "
+" WHERE (EXISTS ( SELECT sushilog.source, sushilog.repository,"
+"sushilog.rid, sushilog.date "
+"FROM sushilog "
+"WHERE sushilog.source = new.source AND sushilog.repository = new.repository AND sushilog.rid = new.rid AND sushilog.date = new.date AND sushilog.metric_type = new.metric_type)) DO INSTEAD NOTHING;";
stmtHive.executeUpdate(sqlcreateRuleSushiLog);
StringcreateSushiIndex="create index if not exists sushilog_duplicates on sushilog(source, repository, rid, date, metric_type);";
stmtHive.executeUpdate(createSushiIndex);
stmtHive.close();
ConnectDB.getHiveConnection().close();
logger.info("Sushi Tables Created");
}catch(Exceptione){
logger.error("Failed to create tables: "+e);
thrownewException("Failed to create tables: "+e.toString(),e);