docs: public Object executeHelper(String sql,
                                String mediaType,
                                Map<String, ParameterBindingDTO> bindValues,
                                boolean describeOnly,
                                boolean internal)
    throws SnowflakeSQLException, SFException
    {
      ScheduledExecutorService executor = null;
  
      try
      {
        synchronized (this)
        {
          if (isClosed)
          {
            throw new SFException(ErrorCode.STATEMENT_CLOSED);
          }
  
          // initialize a sequence id if not closed or not for aborting
          if (canceling.get())
          {
            // nothing to do if canceled
            throw new SFException(ErrorCode.QUERY_CANCELED);
          }
  
          if (this.requestId != null)
          {
            throw new SnowflakeSQLException(SqlState.FEATURE_NOT_SUPPORTED,
                                            ErrorCode.STATEMENT_ALREADY_RUNNING_QUERY.getMessageCode());
          }
  
          this.requestId = UUID.randomUUID().toString();
          this.sequenceId = session.getAndIncrementSequenceId();
  
          this.sqlText = sql;
        }
  
        EventUtil.triggerStateTransition(BasicEvent.QueryState.QUERY_STARTED,
                                         String.format(QueryState.QUERY_STARTED.getArgString(), requestId));
  
        // if there are a large number of bind values, we should upload them to stage
        // instead of passing them in the payload (if enabled)
        int numBinds = BindUploader.arrayBindValueCount(bindValues);
        String bindStagePath = null;
        if (0 < session.getArrayBindStageThreshold()
            && session.getArrayBindStageThreshold() <= numBinds
            && !describeOnly
            && !hasUnsupportedStageBind
            && BindUploader.isArrayBind(bindValues))
        {
          try (BindUploader uploader = BindUploader.newInstance(session, requestId))
          {
            uploader.upload(bindValues);
            bindStagePath = uploader.getStagePath();
          }
          catch (BindException ex)
          {
            logger.debug("Exception encountered trying to upload binds to stage. Attaching binds in payload instead. ", ex);
            TelemetryData errorLog = TelemetryUtil.buildJobData(this.requestId, ex.type.field, 1);
            this.session.getTelemetryClient().tryAddLogToBatch(errorLog);
            IncidentUtil.generateIncidentV2WithException(
                session,
                new SFException(ErrorCode.NON_FATAL_ERROR,
                                IncidentUtil.oneLiner("Failed to upload binds " +
                                                      "to stage:", ex)),
                null,
                requestId);
          }
        }
  
        StmtUtil.StmtInput stmtInput = new StmtUtil.StmtInput();
        stmtInput.setSql(sql)
            .setMediaType(mediaType)
            .setInternal(internal)
            .setDescribeOnly(describeOnly)
            .setServerUrl(session.getServerUrl())
            .setRequestId(requestId)
            .setSequenceId(sequenceId)
            .setParametersMap(statementParametersMap)
            .setSessionToken(session.getSessionToken())
            .setNetworkTimeoutInMillis(session.getNetworkTimeoutInMilli())
            .setInjectSocketTimeout(session.getInjectSocketTimeout())
            .setInjectClientPause(session.getInjectClientPause())
            .setCanceling(canceling)
            .setRetry(false)
            .setDescribedJobId(describeJobUUID)
            .setCombineDescribe(session.getEnableCombineDescribe())
            .setQuerySubmissionTime(System.currentTimeMillis())
            .setServiceName(session.getServiceName());
  
        if (bindStagePath != null)
        {
          stmtInput.setBindValues(null)
              .setBindStage(bindStagePath);
          // use the new SQL format for this query so dates/timestamps are parsed correctly
          setUseNewSqlFormat(true);
        }
        else
        {
          stmtInput.setBindValues(bindValues)
              .setBindStage(null);
        }
  
        if (canceling.get())
        {
          logger.debug("Query cancelled");
  
          throw new SFException(ErrorCode.QUERY_CANCELED);
        }
  
        // if timeout is set, start a thread to cancel the request after timeout
        // reached.
        if (this.queryTimeout > 0)
        {
          executor = Executors.newScheduledThreadPool(1);
          setTimeBomb(executor);
        }
  
        StmtUtil.StmtOutput stmtOutput = null;
        boolean sessionRenewed;
  
        do
        {
          sessionRenewed = false;
          try
          {
            stmtOutput = StmtUtil.execute(stmtInput);
            break;
          }
          catch (SnowflakeSQLException ex)
          {
            if (ex.getErrorCode() == Constants.SESSION_EXPIRED_GS_CODE)
            {
              try
              {
                // renew the session
                session.renewSession(stmtInput.sessionToken);
              }
              catch (SnowflakeReauthenticationRequest ex0)
              {
                if (session.isExternalbrowserAuthenticator())
                {
                  reauthenticate();
                }
                else
                {
                  throw ex0;
                }
              }
              // SNOW-18822: reset session token for the statement
              stmtInput.setSessionToken(session.getSessionToken());
              stmtInput.setRetry(true);
  
              sessionRenewed = true;
  
              logger.debug("Session got renewed, will retry");
            }
            else
            {
              throw ex;
            }
          }
        }
        while (sessionRenewed && !canceling.get());
  
        // Debugging/Testing for incidents
        if (System.getProperty("snowflake.enable_incident_test1") != null &&
            System.getProperty("snowflake.enable_incident_test1").equals("true"))
        {
          throw (SFException) IncidentUtil.generateIncidentV2WithException(
              session,
              new SFException(ErrorCode.STATEMENT_CLOSED),
              null,
              this.requestId);
        }
  
        synchronized (this)
        {
          /*
           * done with the remote execution of the query. set sequenceId to -1
           * and request id to null so that we don't try to abort it upon canceling.
           */
          this.sequenceId = -1;
          this.requestId = null;
        }
  
        if (canceling.get())
        {
          // If we are here, this is the context for the initial query that
          // is being canceled. Raise an exception anyway here even if
          // the server fails to abort it.
          throw new SFException(ErrorCode.QUERY_CANCELED);
        }
  
        logger.debug("Returning from executeHelper");
  
        if (stmtOutput != null)
        {
          return stmtOutput.getResult();
        }
        throw new SFException(ErrorCode.INTERNAL_ERROR);
      }
      catch (SFException | SnowflakeSQLException ex)
      {
        isClosed = true;
        throw ex;
      }
      finally
      {
        if (executor != null)
        {
          executor.shutdownNow();
        }
        // if this query enabled the new SQL format, re-disable it now
        setUseNewSqlFormat(false);
      }
    }