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

List tables command #1510

Merged
merged 45 commits into from
Oct 8, 2024
Merged

List tables command #1510

merged 45 commits into from
Oct 8, 2024

Conversation

maheshrajamani
Copy link
Contributor

@maheshrajamani maheshrajamani commented Oct 8, 2024

What this PR does:

Which issue(s) this PR fixes:
Fixes #1500

Checklist

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

…needed because tables need multiple vector config.
…te/data-api into schema-outject-multiple-vectorize
@maheshrajamani maheshrajamani requested a review from a team as a code owner October 8, 2024 00:21
jsonGenerator.writeEndObject();
}

public record ApiSupport(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could/should this be private?

Copy link
Contributor

Choose a reason for hiding this comment

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

... or, should the 2 separate definitions be combined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made to private for now. But this will evolve as we analyze how different unsuported format are handled.


/** Interface for primitive column types similar to what is defined in cassandra java driver. */
public class PrimitiveTypes {
public enum PrimitiveTypes implements ColumnType {
Copy link
Contributor

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

Choose a reason for hiding this comment

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

Nice simplification by changing to Enum!

columnVectorDefinition.vectorizeConfig().modelName(),
columnVectorDefinition.vectorizeConfig().authentication(),
columnVectorDefinition.vectorizeConfig().parameters());
return new ComplexTypes.VectorType(PrimitiveTypes.FLOAT, vt.getDimensions(), vectorizeConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do any verification wrt vector being of "Float" type? I know we currently only support that, but is there any benefit from future-proofing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this to have a format hardcoded since cql driver has it. If and when cassandra adds support for other type, We can enable it with minimal changes and exposing it in api request.

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 mostly good, but did have some notes on CqlIdentifier handling, integration tests that I'd like clarified.

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.

LGTM

@maheshrajamani maheshrajamani merged commit ad246c6 into main Oct 8, 2024
3 checks passed
@maheshrajamani maheshrajamani deleted the list-tables-command branch October 8, 2024 19:08
Copy link
Contributor

@amorton amorton left a comment

Choose a reason for hiding this comment

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

I would have -1 this PR, it needs changes to use the OperationAttempt model and there are a number of code quality issues.

import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(description = "Command that lists all available tables in a namespace.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should say keyspace not namespace

public record ListTablesCommand(Options options) implements TableOnlyCommand {
public record Options(
@Schema(
description = "include table properties.",
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: "include" to "Include" also this is not the most descriptive.

is this more truthful ? "When True the schema for the table is returned, when false just the table name"

* @param read
* @param cqlDefinition
*/
private record ApiSupport(
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this record here and in ColumnDefinitionSerializer ?

Copy link
Contributor Author

@maheshrajamani maheshrajamani Oct 9, 2024

Choose a reason for hiding this comment

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

I have added a comment in there, this is just a place holder object to generate apiSupport for unsupported columns, This needs to be analyzed for what operation can be supported for unsupported types.

@@ -16,9 +19,15 @@
// implementation = Object.class,
// description = "Represents the table primary key")
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove the commented out lines now ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually these are needed when we go public, why remove them?

default String getApiName() {
return getApiDataType().getApiName();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

why does this list getSupportedTypes() exist seperate to the definitions of the data types we have else where ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no consolidated place to get all supported data types. Error messages needs to be revisited, May be not a good idea to return list of supported types.

@@ -115,4 +128,121 @@ public static TableSchemaObject from(TableMetadata tableMetadata, ObjectMapper o
}
return new TableSchemaObject(tableMetadata, vectorConfig);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

there are a number of things to imprve in the from() function #1521

* @param tableMatcher {@link CollectionTableMatcher}
* @param commandContext {@link CommandContext}
*/
public record ListTablesOperation(
Copy link
Contributor

Choose a reason for hiding this comment

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

pls use a class, cut back on records unless they are basic pojo objects

// below ?
private static final CollectionTableMatcher TABLE_MATCHER = new CollectionTableMatcher();

public ListTablesOperation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why dont we use the GenericOperation and OperationAttempt ?

if (keyspaceMetadata == null) {
return Uni.createFrom()
.failure(
ErrorCodeV1.KEYSPACE_DOES_NOT_EXIST.toApiException(
Copy link
Contributor

Choose a reason for hiding this comment

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

no v1 error code in the table work

/** {@inheritDoc} */
@Override
public Operation resolveKeyspaceCommand(
CommandContext<KeyspaceSchemaObject> ctx, ListTablesCommand command) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be using the OperationAttempt model

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 didn't have a cql command executed in here, so did not use the OperationAttempt model.

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.

Implement listTables command
3 participants