Search in sources :

Example 56 with DataflowException

use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.

the class ComparableMatcher method compareDate.

private boolean compareDate(Tuple inputTuple) throws DataflowException {
    LocalDate date = inputTuple.getField(predicate.getAttributeName(), DateField.class).getValue();
    String compareToString = predicate.getCompareToValue().toString();
    // try to parse the input as date string first
    try {
        LocalDate compareToDate = LocalDate.parse(compareToString);
        return compareValues(date, compareToDate, predicate.getComparisonType());
    } catch (DateTimeParseException e) {
        // if it fails, then try to parse as date time string
        try {
            LocalDateTime compareToDateTime = LocalDateTime.parse(compareToString);
            return compareValues(date, compareToDateTime.toLocalDate(), predicate.getComparisonType());
        } catch (DateTimeParseException e2) {
            throw new DataflowException("Unable to parse date or time: " + compareToString);
        }
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) DateTimeParseException(java.time.format.DateTimeParseException) DataflowException(edu.uci.ics.texera.api.exception.DataflowException) DateField(edu.uci.ics.texera.api.field.DateField) LocalDate(java.time.LocalDate)

Aggregations

DataflowException (edu.uci.ics.texera.api.exception.DataflowException)56 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)23 AttributeType (edu.uci.ics.texera.api.schema.AttributeType)20 Schema (edu.uci.ics.texera.api.schema.Schema)20 Tuple (edu.uci.ics.texera.api.tuple.Tuple)18 IOException (java.io.IOException)14 Span (edu.uci.ics.texera.api.span.Span)11 Collectors (java.util.stream.Collectors)10 SchemaConstants (edu.uci.ics.texera.api.constants.SchemaConstants)9 ArrayList (java.util.ArrayList)9 Attribute (edu.uci.ics.texera.api.schema.Attribute)8 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)7 IField (edu.uci.ics.texera.api.field.IField)7 ListField (edu.uci.ics.texera.api.field.ListField)7 List (java.util.List)7 AbstractSingleInputOperator (edu.uci.ics.texera.dataflow.common.AbstractSingleInputOperator)6 ErrorMessages (edu.uci.ics.texera.api.constants.ErrorMessages)5 StorageException (edu.uci.ics.texera.api.exception.StorageException)5 IntegerField (edu.uci.ics.texera.api.field.IntegerField)4 DataflowUtils (edu.uci.ics.texera.dataflow.utils.DataflowUtils)4