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

Minor clean up on #1698 fix based on code review comments #1805

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.stargate.sgv2.jsonapi.api.model.command.table.definition.ColumnsDescContainer;
import io.stargate.sgv2.jsonapi.service.cqldriver.executor.TableSchemaObject;
import io.stargate.sgv2.jsonapi.service.operation.InsertAttempt;
import io.stargate.sgv2.jsonapi.service.schema.tables.ApiSupportDef;
import io.stargate.sgv2.jsonapi.service.shredding.DocRowIdentifer;
import io.stargate.sgv2.jsonapi.service.shredding.tables.RowId;
import io.stargate.sgv2.jsonapi.service.shredding.tables.WriteableTableRow;
Expand Down Expand Up @@ -45,7 +44,7 @@ public Optional<ColumnsDescContainer> schemaDescription() {
return Optional.empty();
}
var apiColumns = schemaObject.apiTableDef().primaryKeys();
var unsupported = apiColumns.filterBySupport(ApiSupportDef::isUnsupportedInsert);
var unsupported = apiColumns.filterBySupport(x -> !x.insert());
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I fully understand why Matcher cannot be used in this case. Aaron has the negation example in WriteableTableRowBuilder (sorry, there are so many NO_MATCHES examples and I just randomly picked one previously.)

I tried ApiSupportDef.Matcher.NO_MATCHES.withInsert(false) here and it could pass the test insertValidVectorKey you added in the previous PR. So I think it works? I don't mean we always need to have the same way, just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me this way seems bit simpler than building and using a Matcher, that's all. I am sure Matcher could be used, and would make sense for more complex cases.
So maybe just matter of preference.

if (!unsupported.isEmpty()) {
throw new IllegalStateException("Unsupported columns primary key: %s" + unsupported);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ default boolean isUnsupportedDML() {
return !insert() || !read() || !filter();
}

default boolean isUnsupportedInsert() {
return !insert();
}

/**
* Helper record to be used when the support can be determined at compile time, or easily cached.
*/
Expand Down
Loading