Skip to content

Conversation

@123-komal
Copy link
Contributor

@123-komal 123-komal commented Jun 27, 2025

Description:

This PR is the follow-up for #15986 and here we are temporarily building this module separately as a workaround for a dependency issue that breaks the unified build. Its key changes are listed below:

  • SpannerMetadataStorage: Implemented Full-Text Search functionality for metadata searches in metadata tables.

Testing:

  • Local Testing:Tested these changes using a Distributed docker image.
  • Unit Test: Test cases to test different scenarios. Test cases for MetadataStorage classes are defined in the MetadataStorageTest class.

return performSpannerSearch(request, cursor);
}

private io.cdap.cdap.spi.metadata.SearchResponse doSearch(SearchRequest request) throws IOException {
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 import this SearchResponse class?


LOG.info(sql);
LOG.info(statement.toString());
LOG.info(resultSet.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

log statements should be informative


if (results.isEmpty()) {
nextCursor = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be simplified I think can we use stream?

return createSpannerSearchResponse(request, results, nextCursor);
} catch (SpannerException e) {
throw new IOException("Spanner search failed", e);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the internal function is it okay to let the function throw original exception and the caller should wrap it as needed?

throw new IOException("Spanner search failed", e);
}
}
private MetadataRecord mapSpannerResult(ResultSet resultSet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add space

throw new IOException("Spanner search failed", e);
}
}
private MetadataRecord mapSpannerResult(ResultSet resultSet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

even though its privat function please add the comment about what this function is supposed to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added javadocs

Metadata metadata = parseMetadataFromJson(metadataString);
MetadataEntity entity = toMetadataEntity(documentId);


Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra space

String documentId = resultSet.getString("metadata_id");
Struct row = resultSet.getCurrentRowAsStruct();
LOG.info(row.toString());
String metadataString = row.getJson(9);
Copy link
Contributor

Choose a reason for hiding this comment

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

why 9?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the harcoded part

}
}
private MetadataRecord mapSpannerResult(ResultSet resultSet) {
String documentId = resultSet.getString("metadata_id");
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 have const for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@123-komal 123-komal changed the base branch from develop to execute_mutation_branch-2 July 4, 2025 10:32
@123-komal 123-komal force-pushed the execute_mutation_branch-2 branch from f4e1fa5 to 79d7f0b Compare July 4, 2025 14:25
private DatabaseClient dbClient;
private DatabaseAdminClient adminClient;

// Define the wildcard characters you support for user input
Copy link
Contributor

Choose a reason for hiding this comment

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

rephrase the comment

throw new IOException("NOT IMPLEMENTED");
return request.getCursor() != null && !request.getCursor().isEmpty()
? doScroll(request) : doSearch(request);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

add space

LOG.info("Found {} results.", results.size());

return createSearchResponse(request, results, nextActualCursor);

Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra space

@123-komal 123-komal force-pushed the search_branch branch 3 times, most recently from a4409ff to 7f50de8 Compare July 7, 2025 15:43
@123-komal 123-komal force-pushed the execute_mutation_branch-2 branch 6 times, most recently from f0ff86a to 7f9ee57 Compare July 9, 2025 04:30
@123-komal 123-komal force-pushed the search_branch branch 2 times, most recently from 449aea3 to 30020b0 Compare July 9, 2025 04:45
@123-komal 123-komal force-pushed the execute_mutation_branch-2 branch 2 times, most recently from ef0dd76 to aa6d333 Compare July 10, 2025 02:45
@123-komal 123-komal force-pushed the execute_mutation_branch-2 branch 3 times, most recently from d6884fe to de60c7c Compare July 10, 2025 05:42
Base automatically changed from execute_mutation_branch-2 to develop July 10, 2025 08:40
@123-komal 123-komal force-pushed the search_branch branch 4 times, most recently from f71c5d1 to ca54c13 Compare July 11, 2025 04:13
updated

updated

updated

updated

updated

updated

updated

[CDAP-21172] Implement CRUD Operations for Metadata Tables

updated

updated

updated

updated

updated

updated

updated

formatted

updated

updated

resolved checkstyle warnings

updated

updated

updated

updated

updated

updated

updated

formatted

formatted

updated

updated

updated

formatted

formatted

updated

updated

[CDAP-21172] Implement the Search functionality

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated

updated
private FormattedMetadata(MetadataEntity entity, Metadata metadata) throws IOException {
this.namespace = entity.getValue("namespace");
this.namespace = Optional.ofNullable(entity.getValue("namespace"))
.orElse("default");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is namespace is null, is it ok to use default value default or could it be system as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

namespace default value is default.

Comment on lines 123 to 126
@VisibleForTesting
static final boolean KEEP = true;
@VisibleForTesting
static final boolean DISCARD = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to define const for these as they have single usage in source code. Use the boolean values in place.

For test code also use boolean values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okk

public SearchResponse search(SearchRequest request) throws IOException {
throw new IOException("NOT IMPLEMENTED");
public SearchResponse search(SearchRequest request) {
Cursor cursor = Optional.ofNullable(request.getCursor())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be simplified as:

Cursor cursor = Strings.isNullOrEmpty(request.getCursor()) ? null : Cursor.fromString(request.getCursor());
return doSearch(request, cursor);

OR

Cursor cursor;
if !Strings.isNullOrEmpty(request.getCursor()) {
    cursor = Cursor.fromString(request.getCursor());
}
return doSearch(request, cursor);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

params.forEach((key, value) -> statementBuilder.bind(key).to(value));
Statement statement = statementBuilder.build();

LOG.info("Executing Spanner SQL Template: {}", statement.getSql());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please combine the log statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

combined

@123-komal 123-komal added the build Triggers github actions build label Jul 11, 2025
updated
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Triggers github actions build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants