typhon-project / typhonql

Typhon Query Language
Eclipse Public License 2.0
4 stars 1 forks source link

[BUG] Datetime filtering in clauses does not seem to work #111

Closed zolotas4 closed 3 years ago

zolotas4 commented 3 years ago

Describe the bug

We execute a query (see example query below) that filters results based on a datetime field (a range). The result set (see example result set below) we get back include results that are outside the time range

Query

{
 "query" : "from VehicleWeatherData e select e.temperature, e.timeStamp where e.VIN == 1277000015 && e.timeStamp > $2020-12-16T14:00:30Z$ && e.timeStamp < $2020-12-16T14:10:30Z$"
}

Result Set

"values": [
    [
      "5.5",
      "2020-12-03T00:00:00Z"
    ],
    [
      "5.5",
      "2020-12-03T00:03:02Z"
    ],
    [
      "5.5",
      "2020-12-03T00:06:04Z"
    ],

Model

entity VehicleWeatherData {
    VIN: int
    timeStamp : datetime
    vehicle_position : point
    temperature: float
    rain_Intensity: float
    solar_Intensity: int
}

entity VehicleMetaData{
    VIN: int
    brand: string[30]
    model: string[30]
    constr_year: int
    color: string
    t_sensor_h: int
    engine_type: string
}

entity ESPData{
    VIN: int
    timeStamp : datetime
    vehicle_position : point
    esp_edl: bool
    esp_idd: bool
    esp_abs: bool
}

entity AppData {
    timeStamp : datetime
    vehicle_position : point
    esp -> ESPData[0..*]
    wwd -> WarningWeatherData[0..*] 
    vwd -> VehicleWeatherData[0..*]
    pw -> ProcessedWarnings[0..*]
}

entity WarningWeatherData {
    time_start : datetime
    time_end : datetime
    warningType : string
    severity : int
    area : polygon
}

entity RawTextWarnings {
    timeStamp : datetime
    warning : text
    //ew : freetext[RelationExtraction[workflow1], TermExtraction[workflow1]] 
    pw -> ProcessedWarnings[1]
}  

entity ProcessedWarnings {
    ORGANIZATION : string
    WEATHER_EVENT : string
    WEATHER_EVENT_INTENSITY : float
    WEATHER_EVENT_COUNT : int
    LOCATION : point
    WARNING_LEVEL : int
    DAY: string
    DATE : date
    TIME : string
    DISTANCE : string
    DIRECTION : string
    SPEED : float
    SIZE : string
    TEMPERATURE : float
    NUMBER : int // what is the use for this field, check with NLP people
}

relationaldb RelationalDB { 
    tables { 
        table { 
            vehicleMetaData : VehicleMetaData 
            index metadataIndex { 
                attributes ("VIN")  
            } 
            idSpec ("VIN") 
        }
        table {
            appData : AppData 
            index appIndex {
                attributes ("timeStamp", "vehicle_position") // to get the warning in the app we search in the oder databases by VIN, timestamp and vehicle_position
            }   
        }
        table {
            processedWarnings : ProcessedWarnings 
            index analyticsIndex {
                attributes ("DAY", "TIME", "LOCATION")
            }
        }
    } 
 } 

documentdb DocumentDB {
    collections {
        rawTextWarnings : RawTextWarnings
        warningWeatherData : WarningWeatherData
        vehicleWeatherData : VehicleWeatherData 
        eSPData : ESPData 
    }
}

Expected behavior

We only expect to receive those results that lay in between the time range.

tvdstorm commented 3 years ago

Fixed in d4b905d8