private SessionConnection getQuerySessionConnection() {
    Optional<TEndPoint> endPoint =
        availableNodes == null ? Optional.empty() : availableNodes.getQueryEndPoint();
    if (!endPoint.isPresent() || endPointToSessionConnection == null) {
      return defaultSessionConnection;
    }
    SessionConnection connection =
        endPointToSessionConnection.computeIfAbsent(
            endPoint.get(),
            k -> {
              try {
                return constructSessionConnection(this, endPoint.get(), zoneId);
              } catch (IoTDBConnectionException ex) {
                return null;
              }
            });
    return connection == null ? defaultSessionConnection : connection;
  }
execute the query, may redirect query to other node.

@param sql the query statement
@param timeoutInMs time in ms
@return data set
@throws StatementExecutionException statement is not right
@throws IoTDBConnectionException the network is not good
iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java