diff --git a/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala b/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala index d6ed4f08d7056..34e2bdeeadeb8 100644 --- a/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala +++ b/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala @@ -2552,6 +2552,7 @@ class SparkConnectPlanner( // To avoid explicit handling of the result on the client, we build the expected input // of the relation on the server. The client has to simply forward the result. val result = SqlCommandResult.newBuilder() + // Only filled when isCommand val metrics = ExecutePlanResponse.Metrics.newBuilder() if (isCommand) { // Convert the results to Arrow. @@ -2612,7 +2613,8 @@ class SparkConnectPlanner( .setSqlCommandResult(result) .build()) - // Send Metrics + // Send Metrics when isCommand (i.e. show tables) which is eagerly executed & has metrics + // Skip metrics when !isCommand (i.e. select 1) which is not executed & doesn't have metrics if (isCommand) { responseObserver.onNext( ExecutePlanResponse