Skip to content

Conversation

@kasakrisz
Copy link
Contributor

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

@kasakrisz kasakrisz marked this pull request as draft October 22, 2025 09:39
@sonarqubecloud
Copy link

Copy link
Member

@zabetak zabetak left a comment

Choose a reason for hiding this comment

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

Changes LTGM, just optional nits.


public void lockDbTable(String tableName) throws MetaException {
if (!ALLOWED_TABLES_TO_LOCK.contains(tableName)) {
throw new MetaException("Error while locking table " + tableName);
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a test case for the exception if its easy/possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

I want a Java comment because I can't deserialize the intention about why we should throw an exception.


try (QueryWrapper queryParams = new QueryWrapper(pm.newQuery("javax.jdo.query.SQL", deleteSql))) {
executeWithArray(queryParams.getInnerQuery(), params.toArray(), deleteSql);
} catch (MetaException e) {
Copy link
Member

Choose a reason for hiding this comment

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

Catching a MetaException and rethrowing it as a MetaException seems redundant and will make the stacktrace harder to follow. Since the method already throws MetaException can we simply remove the catch block.

Copy link
Contributor

@okumin okumin 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 to me! Thank you

if (engine != null) {
deleteSql += " and \"ENGINE\" = '" + engine + "'";
deleteSql += " and \"ENGINE\" = ?";
params.add(engine);
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 add a test case to add a harmful value?

List<Long> partitionIds = getPartitionIdsViaSqlFilter(catName, dbName, tblName, sqlFilter,
input, Collections.emptyList(), -1);
if (!partitionIds.isEmpty()) {
String deleteSql = "delete from " + PART_COL_STATS + " where \"PART_ID\" in ( " + getIdListForIn(partitionIds) + ")";
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 just a pure question: I don't request any change in this pull request. Can we potentially replace getIdListForIn with a placeholder in this class at some point? In my opinion, it is better to avoid string concatenation thoroughly. Otherwise, new issues might easily pass code reviews.


public void lockDbTable(String tableName) throws MetaException {
if (!ALLOWED_TABLES_TO_LOCK.contains(tableName)) {
throw new MetaException("Error while locking table " + tableName);
Copy link
Contributor

Choose a reason for hiding this comment

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

I want a Java comment because I can't deserialize the intention about why we should throw an exception.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants