{"record":{"id":"bd9f21ed807544b8","repo":"apache/cassandra","slug":"the-floor-on-s-values-cannot-be-computed-for-the","errorCode":null,"errorMessage":"The floor on %s values cannot be computed for the %s duration as precision is below 1 day","messagePattern":"The floor on (.+?) values cannot be computed for the (.+?) duration as precision is below 1 day","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/TimeFcts.java","lineNumber":460,"sourceCode":"         }\n\n         private FloorDateFunction(AbstractType<?> returnType,\n                                   AbstractType<?>... argTypes)\n         {\n             super(returnType, argTypes);\n         }\n\n         protected ByteBuffer fromTimeInMillis(long timeInMillis)\n         {\n             return SimpleDateType.instance.fromTimeInMillis(timeInMillis);\n         }\n\n         @Override\n         protected void validateDuration(Duration duration)\n         {\n             // Checks that the duration has no data below days.\n             if (duration.getNanoseconds() != 0)\n                 throw invalidRequest(\"The floor on %s values cannot be computed for the %s duration as precision is below 1 day\",\n                                      SimpleDateType.instance.asCQL3Type(), duration);\n         }\n     }\n\n     /**\n      * Function that rounds a time down to the closest multiple of a duration.\n      */\n     public static final NativeScalarFunction floorTime = new NativeScalarFunction(\"floor\", TimeType.instance, TimeType.instance, DurationType.instance)\n     {\n         @Override\n         protected boolean isPartialApplicationMonotonic(List<ByteBuffer> partialParameters)\n         {\n             return partialParameters.get(0) == UNRESOLVED && partialParameters.get(1) != UNRESOLVED;\n         }\n\n         @Override\n         public ByteBuffer execute(Arguments arguments)\n         {","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java#L442-L478","documentation":"The date-truncation variant in TimeFcts (floor on SimpleDateType values) overrides validateDuration: a date value has only day granularity, so any duration containing a component below one day (i.e. getNanoseconds() != 0, which includes hours/minutes/seconds/ms/ns components stored as nanoseconds) makes the floor uncomputable and throws this error.","triggerScenarios":"Calling the date floor function, e.g. floor(date_col, 12h) or floor(date_col, 30m) — any duration smaller than or not a whole multiple of 1 day on a date column.","commonSituations":"Users applying the same duration they used for timestamp flooring to a date column; assuming date supports hour-level rounding; query templating that reuses a sub-day duration parameter across timestamp and date columns.","solutions":["Use a whole-day duration such as 1d, 7d, or 1mo when flooring date values","Cast/convert the date to a timestamp if sub-day rounding is actually needed, then floor the timestamp","Guard the client-side duration parameter to disallow sub-day components for date flooring"],"exampleFix":"// before: sub-day duration on a date\nSELECT floor(the_date, 12h) FROM t;\n// after\ndatastax session.execute(\"SELECT floor(the_date, 1d) FROM t\");","handlingStrategy":"validation","validationCode":"function dateFloorDurationOk(dur) { return /^[1-9]\\d*d$|^[1-9]\\d*mo$|^[1-9]\\d*y$/.test(dur); } // whole-day or larger only","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only 1d/7d/1mo/1y-style durations when flooring date values","Separate date-column rounding from timestamp rounding in query templates","Convert date to timestamp first if sub-day rounding is required"],"tags":["cql","time-functions","duration"],"backgroundTag":"invalid-duration-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}