stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

Refactor command validation using ValidatableCommandClause #1310

Closed amorton closed 2 days ago

amorton commented 3 months ago

This builds on https://github.com/stargate/data-api/pull/1309

problems:

This ticket is to take the idea of the ValidatableCommandClause and:

Review all of the validation in different places and move as much as possible to be part of the ValidatableCommandClause process.

there may be some validation that does not make sense, or is hard to do, but we will address those as needed and make exceptions.

Thinking this should cover cases such as:

Additional thoughts:

It probably makes sense to split other tickets off this for each clause, e.g. one for Sort one for Filter so this work is easier to commit.

tatu-at-datastax commented 3 months ago

I am not sure centralization, or -- in particular -- separation of validation step makes sense for all clauses. Many things are best validated when being processed: conversion from one representation (JSON) into another (Java objects) is the natural place to catch some (not necessarily all) problems. Trying to centralize all aspects may be lots of busy work. I guess additional optional step of validation, after conversions, might make sense.

But is that a cross-cutting concern with a single interface? And the only difference being whether command is for Collection or Table? I'll try re-reading #1309 to make sense of this issue.

amorton commented 2 days ago

This was not a good plan, better plan is what we ended up with. Get the user request, and validate it as part of making the internal representation