Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC for Projection implementation for API Tables #1315

Merged
merged 10 commits into from
Jul 29, 2024

Conversation

tatu-at-datastax
Copy link
Contributor

What this PR does:

Adds support for Projection for API Tables

Which issue(s) this PR fixes:

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

amorton and others added 6 commits July 26, 2024 07:44
Encapsulates behavior for clauses that can be validated and
better supports schema object types.
This PR refactors how we process filters by moving the base class
FilterableResolver that was used by command resolvers to be
standalone class FilterResolver that has CollectionFilterResolver and
TableFilterResolver subclasses. The changes to the resolvers are mostly
to handle this change, other than findOne.

The next part is findOne updated to process the filter for a table. Using
the TableFilterResolver to make filters, which then use the
NativeTypeTableFilter and JSONCodec to map from the types used for JSOn
into what CQL expects.

This is POC work, we then need to expand this to handle all the situations
we expect.
POC to show pushing the projection down how we build the select
and how we build the document from the row.

see OperationProjection
Tis commit changes the InsertTableOperation to use the
same JSONCodec created to process data for a filter to transform the
data from the incoming document into what the driver wants to write
to the CQL column
Expands the JSONCode to support mapping toJSON from the
objects the driver sent, to be used in the projection
@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review July 26, 2024 00:34
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner July 26, 2024 00:34
Copy link
Contributor

@maheshrajamani maheshrajamani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand we are running hard to get a PoC version. But not creating any tests for these table related changes. Are we planning to create issues for these to be handled later?

throws UnknownColumnException, MissingJSONCodecException {

Preconditions.checkNotNull(table, "table must not be null");
Preconditions.checkNotNull(column, "column must not be null");
Preconditions.checkNotNull(columnId, "column must not be null");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be handled in the resolvers? These throws unhandled errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on how we view this: if there is no way to trigger it from outside (which I think is the case), these are assertions for internal state and should be ok this way.

But if there was a way to get null here from request it should throw JsonApiException.


List<ColumnMetadata> columns = projectionDefinition.extractSelectedColumns(columnsByName);

if (columns.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A table can't be with empty columns. Think a redundant check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a TODO, just in case it breaks anything

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not checking whether table has no columns but whether set of columns specified by projection definition matching actual columns is empty.
But if validity of projection columns was performed, this could indeed be redundant (problem caught elsewhere).

Base automatically changed from ajm/projection-codecs to main July 29, 2024 23:13
Yuqi-Du added 2 commits July 29, 2024 16:30
…-poc

# Conflicts:
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/filters/table/NativeTypeTableFilter.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/filters/table/TableFilter.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/filters/table/codecs/JSONCodec.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/filters/table/codecs/JSONCodecRegistry.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/filters/table/codecs/MissingJSONCodecException.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/tables/AllJSONProjection.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/tables/FindTableOperation.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/operation/tables/OperationProjection.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/resolver/FindCommandResolver.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/resolver/FindOneAndUpdateCommandResolver.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/resolver/FindOneCommandResolver.java
#	src/main/java/io/stargate/sgv2/jsonapi/service/resolver/matcher/FilterResolver.java
@Yuqi-Du
Copy link
Contributor

Yuqi-Du commented Jul 29, 2024

Approved.

@Yuqi-Du Yuqi-Du merged commit 2791c22 into main Jul 29, 2024
3 checks passed
@Yuqi-Du Yuqi-Du deleted the tatu/table-projection-poc branch July 29, 2024 23:50
@tatu-at-datastax
Copy link
Contributor Author

tatu-at-datastax commented Aug 12, 2024

I understand we are running hard to get a PoC version. But not creating any tests for these table related changes. Are we planning to create issues for these to be handled later?

Yes, unfortunately we did not have scaffolding yet for tests on API Tables and timing was such that I wanted to complete implementation fro demo. So I ran out of time to add proper testing. I agree we definitely need tests ASAP.

@@ -72,7 +67,7 @@ public Uni<Supplier<CommandResult>> execute(

select = select.limit(params.limit());

// Building a statement using the positional values added by the TableFilter
// Building a statment using the positional values added by the TableFilter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Needs to be fixed in a follow-up.

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants