Skip to content

Conversation

@majian1998
Copy link
Contributor

Related PR: #13625, #14483

Some follow-up code optimizations. Thanks to @kamcheungting-db for the suggestions.

@github-actions github-actions bot added the spark label Nov 4, 2025
@manuzhang manuzhang requested a review from huaxingao November 4, 2025 04:07
Comment on lines 73 to 76
LOG.warn(
"Field '{}' not found in class {}. Trying superclass.",
SQL_PARSER_FIELD,
clazz.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

LOG lines for test ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think no need to log in tests.

Copy link
Contributor Author

@majian1998 majian1998 Nov 4, 2025

Choose a reason for hiding this comment

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

@kamcheungting-db: add log to help RCA if something goes wrong

Added logs based on suggestion, just in case.
If you feel they're unnecessary in the test class, we can remove them.

}

private static ParserInterface getNextDelegateParser(ParserInterface parser) {
Logger logger = LoggerFactory.getLogger(ExtendedParser.class);
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 not declare this as private static final member of the interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interface fields cannot be private in Java.
Can the code be written like this?

public interface ExtendedParser extends ParserInterface {
  Logger LOG = LoggerFactory.getLogger(ExtendedParser.class);

Comment on lines 102 to 103
logger.warn(
"Failed to scan delegate parser in {}: {}", parser.getClass().getName(), e.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.warn(
"Failed to scan delegate parser in {}: {}", parser.getClass().getName(), e.toString());
logger.warn("Failed to scan delegate parser in {}", parser.getClass().getName(), e);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

import org.junit.jupiter.api.Test;

public class TestExtendedParser {

Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored.

clazz = clazz.getSuperclass();
}
} catch (Exception e) {
// ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove this comment now. This comment was there to suppress "Empty 'catch' block" warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
} catch (Exception e) {
// ignore
LOG.warn("Failed to scan delegate parser in {}: {}", parser.getClass().getName(), e);
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to append : {} for e, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

without '{}' will print the exception stacktrace, which actually makes sense here.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants