apache/cassandra · error · InvalidRequestException

The floor cannot be computed for the %s duration as precisio

Error message

The floor cannot be computed for the %s duration as precision is below 1 millisecond

What it means

The timeFloor-family functions in TimeFcts (floor timestamps to a duration multiple) require the rounding duration to have at least millisecond precision. validateDuration checks Duration.hasMillisecondPrecision(); a duration whose smallest unit is finer than 1ms or that is purely sub-millisecond (e.g. 500nanoseconds) cannot be floored and throws this error. Note Cassandra's Duration type can encode months/days/nanoseconds, and nanosecond-only components fail this check.

Source

Thrown at src/java/org/apache/cassandra/cql3/functions/TimeFcts.java:348

          * @param arguments the function arguments
          * @return the time to use as the starting time
          */
         private long getStartingTime(Arguments arguments)
         {
             if (arguments.size() == 3)
                 return arguments.getAsLong(2);

             return ZERO;
         }

         /**
          * Validates that the duration has the correct precision.
          * @param duration the duration to validate.
          */
         protected void validateDuration(Duration duration)
         {
             if (!duration.hasMillisecondPrecision())
                 throw invalidRequest("The floor cannot be computed for the %s duration as precision is below 1 millisecond", duration);
         }

         /**
          * Serializes the specified time.
          *
          * @param timeInMillis the time in milliseconds
          * @return the serialized time
          */
         protected abstract ByteBuffer fromTimeInMillis(long timeInMillis);
     }

    /**
     * Function that rounds a timestamp down to the closest multiple of a duration.
     */
     public static final class FloorTimestampFunction extends FloorFunction
     {
         public static FloorTimestampFunction newInstance()
         {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use a duration of at least 1 millisecond, e.g. 1ms, 10ms, 1s
  2. If sub-ms rounding is needed, do the rounding in application code instead of CQL
  3. Validate duration inputs in client code before sending (reject durations with nanosecond-only components)

Example fix

// before: below 1ms precision
SELECT floor(toTimestamp(now()), 500ns) FROM t;
// after
datastax session.execute("SELECT floor(toTimestamp(now()), 1ms) FROM t");
Defensive patterns

Strategy: validation

Validate before calling

function floorDurationOk(durMs) { return durMs >= 1; } // reject durations below 1 millisecond before sending

Prevention

When it happens

Trigger: SELECT systemTimeFct-style floor(now, 500ns) — i.e. calling TimeFcts floor functions (via CQL like FloorTimestamp with a duration argument) with a duration literal composed below 1ms, e.g. 1microsecond or 500nanoseconds.

Common situations: Users constructing duration parameters programmatically from fine-grained timers; misreading duration syntax (w/d/h/m/s vs ns); porting sub-millisecond interval logic from other systems.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/a7c491283649ac13. Report an issue: GitHub.