Skip to content

DatetimeExpression causes trailing input error #985 #2

@priyankc

Description

@priyankc

When using the new reranking functionality in query_points with a formula that includes a DatetimeExpression the following error is raised:

raise _create_rpc_error(
grpc.aio._call.AioRpcError: <AioRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "Wrong input: InvalidArgument: status: InvalidArgument, message: "failed to parse formula: Service internal error: trailing input", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Mon, 05 May 2025 05:31:47 GMT", "content-length": "0"} }"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Wrong input: InvalidArgument: status: InvalidArgument, message: \"failed to parse formula: Service internal error: trailing input\", details: [], metadata: MetadataMap { headers: {\"content-type\": \"application/grpc\", \"date\": \"Mon, 05 May 2025 05:31:47 GMT\", \"content-length\": \"0\"} }", grpc_status:3, created_time:"2025-05-05T07:31:48.460456036+02:00"}"

Formula used:

reranking_query = models.FormulaQuery(
            formula=models.SumExpression(
                sum=[
                    "$score",
                    models.DatetimeExpression(datetime='2025-05-05T07:18:25.401383')
                ]
            )
        )

Code works when replaced by:

reranking_query = models.FormulaQuery(
            formula=models.SumExpression(
                sum=[
                    "$score",
                    datetime.now().timestamp()
                ]
            )
        )

Code did not fail when tested with QdrantClient(":memory:"), only fails with the server mode.

I should have clarified: Creation of the formula doesn't fail. The error is raised only once I call query_points.

We are using a prefetch with two prefetches on two different vectors and then a fusion query models.FusionQuery(fusion=models.Fusion.DBSF) (all inside a prefetch).

The reranking formula is passed to the query argument of query_points.

I am pretty sure there is no problem in the rest of the pipeline, as with the second formula with timestamp() everything works as expected.

This is the input it failed with now:
models.DatetimeExpression(datetime='2025-05-19T19:45:24.063805')
there don't seem to be any spaces, it's the output of datetime.today().isoformat()

Reproduce Goals:

  • Reproduce the error where datetime.today().isoformat() without any trailing whitespace still creates trailing input error as reported at the beginning. This is what we shoudld see "UNKNOWN:Error received from peer {grpc_message:"Wrong input: InvalidArgument: status: InvalidArgument, message: \"failed to parse formula: Service internal error: trailing input\",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions