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

Create index command implementation #1526

Merged
merged 21 commits into from
Oct 11, 2024
Merged

Create index command implementation #1526

merged 21 commits into from
Oct 11, 2024

Conversation

maheshrajamani
Copy link
Contributor

@maheshrajamani maheshrajamani commented Oct 10, 2024

What this PR does:

Which issue(s) this PR fixes:
Fixes #

Checklist

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

@maheshrajamani maheshrajamani requested a review from a team as a code owner October 10, 2024 15:16
@maheshrajamani maheshrajamani self-assigned this Oct 10, 2024
@maheshrajamani maheshrajamani changed the title Create index command implementation [WIP] Create index command implementation Oct 10, 2024
@maheshrajamani maheshrajamani changed the title [WIP] Create index command implementation Create index command implementation Oct 10, 2024

/**
* An extension of the {@link DefaultCreateIndex} class, This is needed because the column name
* appended to the builder needs to use `asCql(true)` to keep the quotes.
Copy link
Contributor

@tatu-at-datastax tatu-at-datastax Oct 11, 2024

Choose a reason for hiding this comment

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

Is this really true? Can the caller not pass properly constructed CqlIdentifier to ensure this?
And if not, is this a bug?

EDIT: base class does have things as CqlIdentifier so it looks like a bug to report. And if so, we are doing override in the meantime so as not to be blocked.
If so, makes sense.

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., reported this to drivers team.

TextIndexOptions textIndexOptions,
VectorIndexOptions vectorIndexOptions,
boolean ifNotExists) {
super(position, schemaObject, new SchemaRetryPolicy(2, Duration.ofMillis(10)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the idea that we'll always retry? Even with ifNotExists being false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH, we didn't spec ifNotExists but did it since we have support in query builder. If it's creating confusion should I remove this feature?

Copy link
Contributor

Choose a reason for hiding this comment

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

May be worth discussing: we should probably always enable "IF NOT EXISTS" for idempotent operation.

But since we already have that for CreateTableCommand, maybe it makes sense to expose it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good catch, not sure what it means to retry with if not exists is false. In other words what to do on timeouts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly.

similarityFunction = SimilarityFunction.COSINE;
}

var attempt =
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok: so since pretty much everything is already available, not sure there's even need for Builder is there? Or if there is, should at least pass more of settings (at least "columnName", "indexName", "ifNotExists") to constructor.

Copy link
Contributor

@tatu-at-datastax tatu-at-datastax left a comment

Choose a reason for hiding this comment

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

Looks good overall, but have some questions/suggestions. Important ones:

  1. Handling of identifiers: should probably more eagerly construct CqlIdentifiers
  2. Operation attempt builder: should pass more of settings to constructor -- or even eliminate builder altogether -- since it seems all settings are available by the time builder is constructed
  3. Questions on bugs in Java driver: overrides are probably fine but wanted to make sure these are just work-arounds (esp. wrt use of CqlIdentifier)

@maheshrajamani
Copy link
Contributor Author

  • Handling of identifiers: should probably more eagerly construct CqlIdentifiers

Will change the constructor to use CqlIdentifier.

3. overrides are probably fine but wanted to make sure these are just work-arounds (esp. wrt use of CqlIdentifier)

They are reported to driver team, these are work around until fixes are available.

2. Operation attempt builder: should pass more of settings to constructor -- or even eliminate builder altogether -- since it seems all settings are available by the time builder is constructed

Agree, Atleast for this will have the Builders do the CqlIdentifier conversion. Just trying to stick with the template how other commands are done.

@tatu-at-datastax
Copy link
Contributor

tatu-at-datastax commented Oct 11, 2024

Agree, Atleast for this will have the Builders do the CqlIdentifier conversion. Just trying to stick with the template how other commands are done.

I am not sure there is value in making builders more flexible than we need them -- or to even use builders, if they are not needed. They really should be used for optional parts, not for things that are always required. So that should be the guideline: mandatory properties should be passed in constructors, optional ones via builder methods.

EDIT: looks like builder is changed to have most things immutable, that works.

@maheshrajamani maheshrajamani merged commit b1147b9 into main Oct 11, 2024
3 checks passed
@maheshrajamani maheshrajamani deleted the create-index branch October 11, 2024 19:47
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.

3 participants