@@ -110,9 +110,9 @@ class SFStatement
110110 private const string SF_QUERY_RESULT_PATH = "/queries/{0}/result" ;
111111
112112 private const string SF_PARAM_MULTI_STATEMENT_COUNT = "MULTI_STATEMENT_COUNT" ;
113-
113+
114114 private const string SF_PARAM_QUERY_TAG = "QUERY_TAG" ;
115-
115+
116116 private const int SF_QUERY_IN_PROGRESS = 333333 ;
117117
118118 private const int SF_QUERY_IN_PROGRESS_ASYNC = 333334 ;
@@ -124,8 +124,8 @@ class SFStatement
124124 private readonly IRestRequester _restRequester ;
125125
126126 private CancellationTokenSource _timeoutTokenSource ;
127-
128- // Merged cancellation token source for all cancellation signal.
127+
128+ // Merged cancellation token source for all cancellation signal.
129129 // Cancel callback will be registered under token issued by this source.
130130 private CancellationTokenSource _linkedCancellationTokenSource ;
131131
@@ -151,21 +151,21 @@ internal SFStatement(SFSession session)
151151 _restRequester = session . restRequester ;
152152 _queryTag = session . _queryTag ;
153153 }
154-
155- internal SFStatement ( SFSession session , string queryTag )
154+
155+ internal SFStatement ( SFSession session , string queryTag )
156156 {
157157 SfSession = session ;
158158 _restRequester = session . restRequester ;
159- _queryTag = queryTag ?? session . _queryTag ;
159+ _queryTag = queryTag ?? session . _queryTag ;
160160 }
161-
161+
162162 internal string GetBindStage ( ) => _bindStage ;
163163
164164 private void AssignQueryRequestId ( )
165165 {
166166 lock ( _requestIdLock )
167167 {
168-
168+
169169 if ( _requestId != null )
170170 {
171171 logger . Info ( "Another query is running." ) ;
@@ -207,16 +207,16 @@ private SFRestRequest BuildQueryRequest(string sql, Dictionary<string, BindingDT
207207 // remove it from parameter bindings so it won't break
208208 // parameter binding feature
209209 bindings . Remove ( SF_PARAM_MULTI_STATEMENT_COUNT ) ;
210- }
211-
210+ }
211+
212212 if ( _queryTag != null )
213213 {
214214 if ( bodyParameters == null )
215215 {
216216 bodyParameters = new Dictionary < string , string > ( ) ;
217217 }
218218 bodyParameters [ SF_PARAM_QUERY_TAG ] = _queryTag ;
219- }
219+ }
220220
221221 QueryRequest postBody = new QueryRequest ( ) ;
222222 postBody . sqlText = sql ;
@@ -317,7 +317,7 @@ private void SetTimeout(int timeout)
317317 this . _timeoutTokenSource = timeout > 0 ? new CancellationTokenSource ( timeout * 1000 ) :
318318 new CancellationTokenSource ( Timeout . InfiniteTimeSpan ) ;
319319 }
320-
320+
321321 /// <summary>
322322 /// Register cancel callback. Two factors: either external cancellation token passed down from upper
323323 /// layer or timeout reached. Whichever comes first would trigger query cancellation.
@@ -363,7 +363,7 @@ internal async Task<SFBaseResultSet> ExecuteAsync(int timeout, string sql, Dicti
363363 }
364364
365365 registerQueryCancellationCallback ( timeout , cancellationToken ) ;
366-
366+
367367 int arrayBindingThreshold = 0 ;
368368 if ( SfSession . ParameterMap . ContainsKey ( SFSessionParameter . CLIENT_STAGE_ARRAY_BINDING_THRESHOLD ) )
369369 {
@@ -457,10 +457,10 @@ internal SFBaseResultSet Execute(int timeout, string sql, Dictionary<string, Bin
457457 {
458458 throw new NotImplementedException ( "Get and Put are not supported in async execution mode" ) ;
459459 }
460- return ExecuteSqlWithPutGet ( timeout , trimmedSql , bindings , describeOnly ) ;
460+ return ExecuteSqlWithPutGet ( timeout , sql , trimmedSql , bindings , describeOnly ) ;
461461 }
462462
463- return ExecuteSqlOtherThanPutGet ( timeout , trimmedSql , bindings , describeOnly , asyncExec ) ;
463+ return ExecuteSqlOtherThanPutGet ( timeout , sql , bindings , describeOnly , asyncExec ) ;
464464 }
465465 finally
466466 {
@@ -469,7 +469,7 @@ internal SFBaseResultSet Execute(int timeout, string sql, Dictionary<string, Bin
469469 }
470470 }
471471
472- private SFBaseResultSet ExecuteSqlWithPutGet ( int timeout , string sql , Dictionary < string , BindingDTO > bindings , bool describeOnly )
472+ private SFBaseResultSet ExecuteSqlWithPutGet ( int timeout , string sql , string trimmedSql , Dictionary < string , BindingDTO > bindings , bool describeOnly )
473473 {
474474 try
475475 {
@@ -484,7 +484,7 @@ private SFBaseResultSet ExecuteSqlWithPutGet(int timeout, string sql, Dictionary
484484 logger . Debug ( "PUT/GET queryId: " + ( response . data != null ? response . data . queryId : "Unknown" ) ) ;
485485
486486 SFFileTransferAgent fileTransferAgent =
487- new SFFileTransferAgent ( sql , SfSession , response . data , CancellationToken . None ) ;
487+ new SFFileTransferAgent ( trimmedSql , SfSession , response . data , CancellationToken . None ) ;
488488
489489 // Start the file transfer
490490 fileTransferAgent . execute ( ) ;
@@ -507,7 +507,7 @@ private SFBaseResultSet ExecuteSqlWithPutGet(int timeout, string sql, Dictionary
507507 throw new SnowflakeDbException ( ex , SFError . INTERNAL_ERROR ) ;
508508 }
509509 }
510-
510+
511511 private SFBaseResultSet ExecuteSqlOtherThanPutGet ( int timeout , string sql , Dictionary < string , BindingDTO > bindings , bool describeOnly , bool asyncExec )
512512 {
513513 try
@@ -562,7 +562,7 @@ private SFBaseResultSet ExecuteSqlOtherThanPutGet(int timeout, string sql, Dicti
562562 throw ;
563563 }
564564 }
565-
565+
566566 internal async Task < SFBaseResultSet > GetResultWithIdAsync ( string resultId , CancellationToken cancellationToken )
567567 {
568568 var req = BuildResultRequestWithId ( resultId ) ;
@@ -938,7 +938,7 @@ internal async Task<QueryStatus> GetQueryStatusAsync(string queryId, Cancellatio
938938 /// </summary>
939939 /// <param name="originalSql">The original sql query.</param>
940940 /// <returns>The query without the blanks and comments at the beginning.</returns>
941- private string TrimSql ( string originalSql )
941+ internal static string TrimSql ( string originalSql )
942942 {
943943 char [ ] sqlQueryBuf = originalSql . ToCharArray ( ) ;
944944 var builder = new StringBuilder ( ) ;
@@ -1054,7 +1054,7 @@ internal SFBaseResultSet ExecuteTransfer(string sql)
10541054 false ) ;
10551055
10561056 PutGetStageInfo stageInfo = new PutGetStageInfo ( ) ;
1057-
1057+
10581058 SFFileTransferAgent fileTransferAgent =
10591059 new SFFileTransferAgent ( sql , SfSession , response . data , ref _uploadStream , _destFilename , _stagePath , CancellationToken . None ) ;
10601060
0 commit comments