Skip to content

Commit

Permalink
SNOW-893834 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dstempniak committed Oct 9, 2023
1 parent e71de8c commit 24574aa
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected override async Task<HttpResponseMessage> 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));
}
}
Expand Down
4 changes: 2 additions & 2 deletions Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data/Core/ArrowResultChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data/Core/ArrowResultSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data/Core/SFDataConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 24574aa

Please sign in to comment.