From 24574aa95a857953f15c3c1a51eb319ec09d835f Mon Sep 17 00:00:00 2001 From: Dariusz Stempniak Date: Mon, 9 Oct 2023 10:23:34 +0200 Subject: [PATCH] SNOW-893834 fix --- Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs | 4 ++-- Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs | 4 ++-- Snowflake.Data/Core/ArrowResultChunk.cs | 2 +- Snowflake.Data/Core/ArrowResultSet.cs | 2 +- Snowflake.Data/Core/SFDataConverter.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs b/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs index 8d27a00aa..aa63452ed 100644 --- a/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs +++ b/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs @@ -30,8 +30,8 @@ protected override async Task SendAsync(HttpRequestMessage CancellationToken externalCancellationToken, string sid = "") { - // Override the http timeout and set to 1ms to force all http request to timeout and retry - message.Properties[BaseRestRequest.HTTP_REQUEST_TIMEOUT_KEY] = TimeSpan.FromMilliseconds(1); + // Override the http timeout and set to 0ms to force all http request to timeout and retry + message.Properties[BaseRestRequest.HTTP_REQUEST_TIMEOUT_KEY] = TimeSpan.FromMilliseconds(0); return await (base.SendAsync(message, restTimeout, externalCancellationToken).ConfigureAwait(false)); } } diff --git a/Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs b/Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs index 63c655e7a..0bbfd3b54 100755 --- a/Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs +++ b/Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs @@ -525,7 +525,7 @@ public static RecordBatch PrepareRecordBatch(SFDataType sfType, long scale, obje column = new StructArray(structField, arr.Length, new IArrowArray[] { new Int64Array.Builder() - .AppendRange(arr.Select(dt => (dt.Ticks - DateTime.UnixEpoch.Ticks) / (long)10000000)) + .AppendRange(arr.Select(dt => (dt.Ticks - SFDataConverter.UnixEpoch.Ticks) / (long)10000000)) .Build(), new Int32Array.Builder() .AppendRange(arr.Select(dt => (int)(100 * (dt.Ticks % 10000000)))) @@ -546,7 +546,7 @@ public static RecordBatch PrepareRecordBatch(SFDataType sfType, long scale, obje private static long ConvertTicksToInt64(long ticks, long scale) { - long ticksFromEpoch = ticks - DateTimeOffset.UnixEpoch.Ticks; + long ticksFromEpoch = ticks - SFDataConverter.UnixEpoch.Ticks; if (scale <= 7) return ticksFromEpoch / (long)Math.Pow(10, 7 - scale); else diff --git a/Snowflake.Data/Core/ArrowResultChunk.cs b/Snowflake.Data/Core/ArrowResultChunk.cs index 04b0ba3ba..c743aabb2 100755 --- a/Snowflake.Data/Core/ArrowResultChunk.cs +++ b/Snowflake.Data/Core/ArrowResultChunk.cs @@ -13,7 +13,7 @@ internal class ArrowResultChunk : BaseResultChunk { internal override ResultFormat ResultFormat => ResultFormat.ARROW; - private static readonly DateTimeOffset s_epochDate = DateTimeOffset.UnixEpoch; + private static readonly DateTimeOffset s_epochDate = SFDataConverter.UnixEpoch; private static readonly long[] s_powersOf10 = { 1, diff --git a/Snowflake.Data/Core/ArrowResultSet.cs b/Snowflake.Data/Core/ArrowResultSet.cs index bd0288141..7ccf5d767 100755 --- a/Snowflake.Data/Core/ArrowResultSet.cs +++ b/Snowflake.Data/Core/ArrowResultSet.cs @@ -234,7 +234,7 @@ internal override TimeSpan GetTimeSpan(int ordinal) return (TimeSpan)value; var type = sfResultSetMetaData.GetColumnTypeByIndex(ordinal); if (type == SFDataType.TIME && value is DateTime ret) - return TimeSpan.FromTicks(ret.Ticks - DateTime.UnixEpoch.Ticks); + return TimeSpan.FromTicks(ret.Ticks - SFDataConverter.UnixEpoch.Ticks); throw new SnowflakeDbException(SFError.INVALID_DATA_CONVERSION, value, type, typeof(TimeSpan)); } diff --git a/Snowflake.Data/Core/SFDataConverter.cs b/Snowflake.Data/Core/SFDataConverter.cs index a01429567..d957a0239 100755 --- a/Snowflake.Data/Core/SFDataConverter.cs +++ b/Snowflake.Data/Core/SFDataConverter.cs @@ -18,7 +18,7 @@ public enum SFDataType static class SFDataConverter { - private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Unspecified); + internal static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Unspecified); internal static object ConvertToCSharpVal(UTF8Buffer srcVal, SFDataType srcType, Type destType) {