abhishekagarwal87 commented on code in PR #17101:
URL: https://github.com/apache/druid/pull/17101#discussion_r1766423287
##########
sql/src/test/java/org/apache/druid/quidem/DruidQuidemCommandHandler.java:
##########
@@ -83,33 +80,63 @@ abstract static class AbstractPlanCommand extends
AbstractCommand
}
@Override
- public final String describe(Context x)
+ public final String describe(Context context)
{
- return commandName() + " [sql: " + x.previousSqlCommand().sql + "]";
+ return commandName() + " [sql: " + context.previousSqlCommand().sql +
"]";
}
@Override
- public final void execute(Context x, boolean execute)
+ public final void execute(Context context, boolean execute)
{
if (execute) {
try {
- executeExplain(x);
+ executeExplain(context);
}
catch (Exception e) {
throw new Error(e);
}
} else {
- x.echo(content);
+ context.echo(content);
+ }
+ context.echo(lines);
+ }
+
+ protected final <T> List<T> executeExplainCollectHookValues(Context
context, HookKey<T> hook) throws IOException
+ {
+ DruidHookDispatcher dhp = unwrapDruidHookDispatcher(context);
+ List<T> logged = new ArrayList<>();
+ try (Closeable unhook = dhp.withHook(hook, (key, value) -> {
+ logged.add(value);
+ })) {
+ executeExplainQuery(context);
+ }
+ return logged;
+ }
+
+ protected final void executeQuery(Context context)
+ {
+ final SqlCommand sqlCommand = context.previousSqlCommand();
+ executeQuery(context, sqlCommand.sql);
+ }
+
+ protected final void executeExplainQuery(Context context)
+ {
+ boolean isExplainSupported =
DruidConnectionExtras.unwrapOrThrow(context.connection()).isExplainSupported();
+
+ final SqlCommand sqlCommand = context.previousSqlCommand();
+
+ if (isExplainSupported) {
+ executeQuery(context, "explain plan for " + sqlCommand.sql);
+ } else {
+ executeQuery(context, sqlCommand.sql);
Review Comment:
should we run the query at all if explain is not supported?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]