use of com.facebook.presto.sql.tree.RoutineCharacteristics.NullCallClause in project presto by prestodb.
the class AstBuilder method getRoutineCharacteristics.
private RoutineCharacteristics getRoutineCharacteristics(SqlBaseParser.RoutineCharacteristicsContext context) {
Language language = null;
Determinism determinism = null;
NullCallClause nullCallClause = null;
for (SqlBaseParser.RoutineCharacteristicContext characteristic : context.routineCharacteristic()) {
if (characteristic.language() != null) {
if (language != null) {
throw new ParsingException(format("Duplicate language clause: %s", characteristic.language().getText()), getLocation(characteristic.language()));
}
if (characteristic.language().SQL() != null) {
language = Language.SQL;
} else {
language = new Language(((Identifier) visit(characteristic.language().identifier())).getValue());
}
} else if (characteristic.determinism() != null) {
if (determinism != null) {
throw new ParsingException(format("Duplicate determinism characteristics: %s", characteristic.determinism().getText()), getLocation(characteristic.determinism()));
}
determinism = characteristic.determinism().NOT() == null ? DETERMINISTIC : NOT_DETERMINISTIC;
} else if (characteristic.nullCallClause() != null) {
if (nullCallClause != null) {
throw new ParsingException(format("Duplicate null-call clause: %s", characteristic.nullCallClause().getText()), getLocation(characteristic.nullCallClause()));
}
nullCallClause = characteristic.nullCallClause().CALLED() != null ? CALLED_ON_NULL_INPUT : RETURNS_NULL_ON_NULL_INPUT;
} else {
throw new IllegalArgumentException(format("Unsupported RoutineCharacteristic: %s", characteristic.getText()));
}
}
return new RoutineCharacteristics(Optional.ofNullable(language), Optional.ofNullable(determinism), Optional.ofNullable(nullCallClause));
}
Aggregations