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-1735958: Snowflake TIME column is returned as .Net DateTime and not .Net TimeOnly #1040

Closed
LeivErik opened this issue Oct 14, 2024 · 3 comments
Assignees
Labels
question Issue is a usage/other question rather than a bug status-triage_done Initial triage done, will be further handled by the driver team

Comments

@LeivErik
Copy link

So I have a table

create TESTTABLE1 (
	GUID VARCHAR(50) NOT NULL,	
	DATE_ONLY DATE,
	TIME_ONLY TIME(9),
	primary key (GUID)
);

I am reading from this table returning a DataReader:

using  var conn = new SnowflakeDbConnection(connectionString);
await conn.OpenAsync(cancellationToken);
using var cmd = con.CreateCommand();   
cmd.CommandText = "select GUID, DATE_ONLY, TIME_ONLY from TESTTABLE1
using var dataReader = await cmd.ExecuteReaderAsync(cancellationToken);

The datareader returns the TIME_ONLY column as DateTime.

I would expect it as .net TimeOnly.

So if I insert read data to a new table, insert fails w/e.g. error:
Error: Time '1970-01-01T01:59:11.4040000+01:00' is not recognized SqlState: 22007, VendorCode: 100108, QueryId: 01b7ae5b-0000-bcba-0000-811900033022

Additional Information:

  • Snowflake.Data 4.1.0 package
  • .Net 8
  • Win.10
@LeivErik LeivErik added the bug label Oct 14, 2024
@github-actions github-actions bot changed the title Snowflake TIME column is returned as .Net DateTime and not .Net TimeOnly SNOW-1735958: Snowflake TIME column is returned as .Net DateTime and not .Net TimeOnly Oct 14, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Oct 14, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Oct 14, 2024
@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Oct 14, 2024

hi, and thanks for raising this. This is sorta expected, please see the documentation about TIME Snowflake-type returned as System.DateTime.

editing this comment to add some details. So after getting the TimeSpan datatype as mentioned in above documentation, you can access its .Hours, .Minutes, and .Seconds properties if said details are needed.

Let us know if it helps, but for now this seems to be working as expected and documented.

@sfc-gh-dszmolka sfc-gh-dszmolka added question Issue is a usage/other question rather than a bug and removed bug labels Oct 14, 2024
@sfc-gh-dstempniak
Copy link
Collaborator

TimeOnly was introduced in .NET 6. It is not available in .NET Framework or .NET Standard 2.0.

@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage labels Oct 14, 2024
@sfc-gh-dszmolka
Copy link
Contributor

i'm going to close this as it's the expected and documented behaviour, but if you require further help please do comment and i can reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue is a usage/other question rather than a bug status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants