Skip to content

Conversation

@pengpeng-lu
Copy link
Contributor

No description provided.

@pengpeng-lu pengpeng-lu added planner Related to the query planner enhancement New feature or request labels Nov 19, 2025
* @return this exception for chaining
*/
@Nonnull
public UnableToPlanException withPlanCacheInfo(@Nullable String planCacheInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class should not have anything in it referring to upper layers. The match candidates are fine and needed.

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 planCacheInfo from UnableToPlanException, log it directly in PlanGenerator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and also removed connectionOptionsInfo and log it directly in PlanGenerator.

*/
@Nonnull
public UnableToPlanException withPlanCacheInfo(@Nullable String planCacheInfo) {
this.planCacheInfo = planCacheInfo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not have this mutable.

matchCandidatesBuilder.append(" (none)");
} else {
for (final var candidate : matchCandidates) {
matchCandidatesBuilder.append(String.format(" - %s%n", candidate.toString()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we fine with just logging the kind of index and the index name here? candidate.toString() in ValueIndexScanMatchCandidate is implemented in a way that would print:
value[someIndexName]

Should we rather just add the MatchCandidates themselves here? In that way the consumer can decide what to do with them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what functions of MatchCandidate shows the complete graph? I added some more info in here, but not sure if that is enough.

} catch (UnableToPlanException e) {
if (logger.isErrorEnabled()) {
final var logBuilder = KeyValueLogMessage.build("Unable to plan query",
"recordMetadata", metaData.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This one does not have a toString() unless I missed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace it with toProto().toString().

planContext.getConstantActionFactory(), planContext.getDbUri(), caseSensitive)
.generateLogicalPlan(ast.getParseTree()));
return maybePlan.optimize(planner, planContext, currentPlanHashMode);
} catch (UnableToPlanException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add a test for this? we should test cases where:

  1. we do not have cache.
  2. we have cache but cold.
  3. we have cache that is warm.

// Attach connection options information to the exception
final var optionsBuilder = new StringBuilder("Connection Options:\n");
for (final var entry : options.entries()) {
optionsBuilder.append(String.format(" %s = %s%n", entry.getKey(), entry.getValue()));
Copy link
Contributor

Choose a reason for hiding this comment

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

If I am not mistaken, some values can be null, is that ok for the StringBuilder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, log string null when it is null.

@@ -0,0 +1,106 @@
/*
* UnableToPlanExceptionTest.java
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests may be useful, but they seem a bit superficial to me, can we add integration tests where we verify the exception's behavior in a real scenario where the planner fails to plan? please see my other comment.

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 this test was actually added to meet TeamScale requirement, added a test around plan cache.

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

Labels

enhancement New feature or request planner Related to the query planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants