use of com.cronutils.builder.CronBuilder in project hive by apache.
the class ScheduledQueryAnalyzer method getDefaultCronBuilder.
private CronBuilder getDefaultCronBuilder() {
CronDefinition definition = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ);
CronBuilder b = CronBuilder.cron(definition).withYear(always()).withDoM(always()).withMonth(always()).withDoW(questionMark()).withHour(always()).withMinute(always()).withMinute(always()).withSecond(always());
return b;
}
use of com.cronutils.builder.CronBuilder in project hive by apache.
the class ScheduledQueryAnalyzer method interpretEveryNode.
private String interpretEveryNode(int every, int intervalToken, Timestamp ts) throws SemanticException {
CronBuilder b = getDefaultCronBuilder();
switch(intervalToken) {
case HiveParser.TOK_INTERVAL_DAY_LITERAL:
if (every != 1) {
throw new SemanticException("EVERY " + every + " DAY is not supported; only EVERY DAY is supported");
}
b.withSecond(on(ts.getSeconds()));
b.withMinute(on(ts.getMinutes()));
b.withHour(on(ts.getHours()));
break;
case HiveParser.TOK_INTERVAL_HOUR_LITERAL:
b.withSecond(on(ts.getSeconds()));
b.withMinute(on(ts.getMinutes()));
b.withHour(every(on0(ts.getHours()), every));
break;
case HiveParser.TOK_INTERVAL_MINUTE_LITERAL:
b.withSecond(on(ts.getSeconds()));
b.withMinute(every(on0(ts.getMinutes()), every));
break;
case HiveParser.TOK_INTERVAL_SECOND_LITERAL:
b.withSecond(every(on0(ts.getSeconds()), every));
break;
default:
throw new SemanticException("not supported schedule interval(only HOUR/MINUTE/SECOND is supported)");
}
return b.instance().asString();
}
Aggregations