Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-950923 queryid for put/get statement #828

Closed

Conversation

sfc-gh-mhofman
Copy link
Collaborator

Description

Please explain the changes you made here.

Checklist

  • Code compiles correctly
  • Code is formatted according to Coding Conventions
  • Created tests which fail without the change (if possible)
  • All tests passing (dotnet test)
  • Extended the README / documentation, if necessary
  • Provide JIRA issue id (if possible) or GitHub issue id in PR name

@sfc-gh-mhofman sfc-gh-mhofman force-pushed the SNOW-950923-queryid-for-putget-statement branch from 4868359 to 13d1106 Compare December 6, 2023 16:05
Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (62f2206) 83.56% compared to head (c1f9af0) 83.48%.
Report is 6 commits behind head on master.

Files Patch % Lines
...lake.Data/Core/FileTransfer/SFFileTransferAgent.cs 85.71% 3 Missing and 1 partial ⚠️
Snowflake.Data/Core/SFStatement.cs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #828      +/-   ##
==========================================
- Coverage   83.56%   83.48%   -0.08%     
==========================================
  Files          89       89              
  Lines        9155     9197      +42     
  Branches      837      843       +6     
==========================================
+ Hits         7650     7678      +28     
- Misses       1275     1287      +12     
- Partials      230      232       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

{
download();
Logger.Error("Error while transferring file(s): " + e.Message);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it made sense to wrap any exception here like FileNotFound or DirectoryNotFoundException into SnowflakeDbException as in
https://github.com/snowflakedb/snowflake-connector-net/pull/825/files#diff-db3c83b5b538ba4849e37bb0565ec20d836891f35dd60156da30501ea34ec6bfR231-R245
to be able to provide QueryId within exception. However,
it would introduce possibly some changes to the application which might already be catching only those types of exceptions and not SnowflakeDbException or exception in general.
So a change in SFStatement.cs is enough to provide query id in case file transfer error throws anything here.

@@ -356,6 +356,11 @@ internal SFBaseResultSet Execute(int timeout, string sql, Dictionary<string, Bin
bindings,
describeOnly);

logger.Debug("PUT/GET queryId: " + (response.data != null ? response.data.queryId : "Unknown"));

if (response.data != null)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since query id is provided by the above ExecuteHelper upfront (before we start get/put file operation) we reuse it even before fileTransferAgent throws any possible error.
It's a simpler approach then in #825 @sfc-gh-knozderko
cc @sfc-gh-dszmolka

// Checking if query Id is provided on the command level as well
Assert.AreEqual(queryId, ((SnowflakeDbCommand)command).GetQueryId());
// Check file status
Assert.AreEqual(expectedStatus.ToString(),
Copy link
Collaborator

@sfc-gh-knozderko sfc-gh-knozderko Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now all these asserts don't work, because exception is caught and not rethrown

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you refer to the exception from reader.Read how not rethrowing exception would affect asserts which are skipped in case of this exception?
Those asserts take place if there is a successful scenario.
Also all the tests pass right now. If there was an issue we would see some failures

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command.ExecuteReader() does not throw any exception, but reader.Read() return false.
In that case previously the test would fail. Currently the test will pass.
I would prefer to add try/catch only around execute and return the function immediately and not putting these asserts into try/catch block, because it makes some scenarios untested.

@sfc-gh-mhofman sfc-gh-mhofman changed the title Snow 950923 queryid for putget statement SNOW-950923 queryid for put/get statement Dec 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2023
@sfc-gh-mhofman
Copy link
Collaborator Author

Closing as this change does not provide query id on the exception level but only at the statement level.
It is different than what is implemented in the JDBC Driver.
cc @sfc-gh-knozderko @sfc-gh-dszmolka

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants