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-14887010 Structured types read for json result format #994

Merged
merged 47 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
77621da
SNOW-14887010 Structured types read for json result format - work in …
sfc-gh-knozderko Jun 7, 2024
8ee0444
improve time tests
sfc-gh-knozderko Jul 17, 2024
b9e1df4
handle integer map keys
sfc-gh-knozderko Jul 17, 2024
0ded12b
little refactor
sfc-gh-knozderko Jul 17, 2024
d204b52
handle binary type
sfc-gh-knozderko Jul 18, 2024
8602ce1
fix not working test
sfc-gh-knozderko Jul 18, 2024
938e4b1
fix tests
sfc-gh-knozderko Jul 18, 2024
289a62e
handle semi structured types in structured types
sfc-gh-knozderko Jul 18, 2024
6d75003
handle map of maps
sfc-gh-knozderko Jul 19, 2024
3f4915f
extract logic duplication
sfc-gh-knozderko Jul 19, 2024
182504f
fix newlines problem in tests
sfc-gh-knozderko Jul 19, 2024
029404d
handle nulls
sfc-gh-knozderko Jul 19, 2024
3e05adf
fix tests for running in different time zones
sfc-gh-knozderko Jul 22, 2024
48d16ff
fixing tests for timezones
sfc-gh-knozderko Jul 22, 2024
df9d67b
fix variable names
sfc-gh-knozderko Jul 22, 2024
7141bd2
debug time conversion
sfc-gh-knozderko Jul 22, 2024
9c06c83
test for null structured types
sfc-gh-knozderko Jul 22, 2024
510d4f5
fix time format
sfc-gh-knozderko Jul 22, 2024
2373faa
handle IList and IMap
sfc-gh-knozderko Jul 22, 2024
5cb6298
time zones support
sfc-gh-knozderko Jul 22, 2024
19abf82
make it compile under framework
sfc-gh-knozderko Jul 23, 2024
8730750
make it compile under framework
sfc-gh-knozderko Jul 23, 2024
b401e5d
tests with timestamp precision
sfc-gh-knozderko Jul 24, 2024
426e1f9
Use annotation to control the way of object creation
sfc-gh-knozderko Jul 25, 2024
12e9a00
handle null on the top level
sfc-gh-knozderko Jul 25, 2024
d348f54
Dedicated error for structured types, fix boolean read
sfc-gh-knozderko Jul 25, 2024
b3049c8
fix tests format
sfc-gh-knozderko Jul 25, 2024
5ed5e21
rename test classes
sfc-gh-knozderko Jul 30, 2024
65c1aa1
changes from review
sfc-gh-knozderko Jul 30, 2024
d40a7a4
improve error handling
sfc-gh-knozderko Jul 30, 2024
460040a
changes from review
sfc-gh-knozderko Jul 30, 2024
ff70271
split structured types integration tests
sfc-gh-knozderko Jul 31, 2024
f6c14c5
Merge branch 'master' into SNOW-1488701_read_structured_types_json
sfc-gh-knozderko Jul 31, 2024
22aee7e
test string with national letters
sfc-gh-knozderko Jul 31, 2024
20e9bda
Disable structured types tests on some environements
sfc-gh-knozderko Jul 31, 2024
3e1abda
enable structured types tests
sfc-gh-knozderko Jul 31, 2024
56c2d39
test enabling structured types
sfc-gh-knozderko Jul 31, 2024
9ce3aad
try to enable structured types
sfc-gh-knozderko Jul 31, 2024
29de53b
try to enable structured types
sfc-gh-knozderko Aug 1, 2024
1ec6d5e
clean tests
sfc-gh-knozderko Aug 1, 2024
32519e3
better error handling
sfc-gh-knozderko Aug 26, 2024
e882fc8
revert unnecessary changes
sfc-gh-knozderko Aug 26, 2024
e32269c
Merge branch 'master' into SNOW-1488701_read_structured_types_json
sfc-gh-knozderko Aug 26, 2024
5ffb4f5
fix test
sfc-gh-knozderko Aug 27, 2024
61bc2f2
Merge branch 'master' into SNOW-1488701_read_structured_types_json
sfc-gh-knozderko Aug 27, 2024
0785d92
Merge branch 'master' into SNOW-1488701_read_structured_types_json
sfc-gh-knozderko Aug 28, 2024
71ec247
Merge branch 'master' into SNOW-1488701_read_structured_types_json
sfc-gh-knozderko Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Snowflake.Data.Tests/Client/Address.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Snowflake.Data.Tests.Client
{
public class Address
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
{
public string city { get; set; }
public string state { get; set; }
public Zip zip { get; set; }

public Address()
{
}

public Address(string city, string state, Zip zip)
{
this.city = city;
this.state = state;
this.zip = zip;
}
}
}
28 changes: 28 additions & 0 deletions Snowflake.Data.Tests/Client/AllNullableTypesClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Snowflake.Data.Tests.Client
{
public class AllNullableTypesClass
{
public string StringValue { get; set; }
public char? CharValue { get; set; }
public byte? ByteValue { get; set; }
public sbyte? SByteValue { get; set; }
public short? ShortValue { get; set; }
public ushort? UShortValue { get; set; }
public int? IntValue { get; set; }
public int? UIntValue { get; set; }
public long? LongValue { get; set; }
public long? ULongValue { get; set; }
public float? FloatValue { get; set; }
public double? DoubleValue { get; set; }
public decimal? DecimalValue { get; set; }
public bool? BooleanValue { get; set; }
public Guid? GuidValue { get; set; }
public DateTime? DateTimeValue { get; set; }
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
public DateTimeOffset? DateTimeOffsetValue { get; set; }
public TimeSpan? TimeSpanValue { get; set; }
public byte[] BinaryValue { get; set; }
public string SemiStructuredValue { get; set; }
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
}
}
28 changes: 28 additions & 0 deletions Snowflake.Data.Tests/Client/AllTypesClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Snowflake.Data.Tests.Client
{
public class AllTypesClass
sfc-gh-mhofman marked this conversation as resolved.
Show resolved Hide resolved
{
public string StringValue { get; set; }
public char CharValue { get; set; }
public byte ByteValue { get; set; }
public sbyte SByteValue { get; set; }
public short ShortValue { get; set; }
public ushort UShortValue { get; set; }
public int IntValue { get; set; }
public int UIntValue { get; set; }
public long LongValue { get; set; }
public long ULongValue { get; set; }
public float FloatValue { get; set; }
public double DoubleValue { get; set; }
public decimal DecimalValue { get; set; }
public bool BooleanValue { get; set; }
public Guid GuidValue { get; set; }
public DateTime DateTimeValue { get; set; }
public DateTimeOffset DateTimeOffsetValue { get; set; }
public TimeSpan TimeSpanValue { get; set; }
public byte[] BinaryValue { get; set; }
public string SemiStructuredValue { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Snowflake.Data.Client;

namespace Snowflake.Data.Tests.Client
{
[SnowflakeObject(ConstructionMethod = SnowflakeObjectConstructionMethod.CONSTRUCTOR)]
sfc-gh-mhofman marked this conversation as resolved.
Show resolved Hide resolved
public class AnnotatedClassForConstructorConstruction
{
public string StringValue { get; set; }
public int? IgnoredValue { get; set; }
public int IntegerValue { get; set; }

public AnnotatedClassForConstructorConstruction()
{
}

public AnnotatedClassForConstructorConstruction(string stringValue, int integerValue)
{
StringValue = stringValue;
IntegerValue = integerValue;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Snowflake.Data.Client;

namespace Snowflake.Data.Tests.Client
{
[SnowflakeObject(ConstructionMethod = SnowflakeObjectConstructionMethod.PROPERTIES_NAMES)]
public class AnnotatedClassForPropertiesNamesConstruction
{
[SnowflakeColumn(Name = "x")]
public string StringValue { get; set; }
public int? IgnoredValue { get; set; }
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
public int IntegerValue { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Snowflake.Data.Client;

namespace Snowflake.Data.Tests.Client
{
[SnowflakeObject(ConstructionMethod = SnowflakeObjectConstructionMethod.PROPERTIES_ORDER)]
public class AnnotatedClassForPropertiesOrderConstruction
{
public string StringValue { get; set; }
[SnowflakeColumn(IgnoreForPropertyOrder = true)]
public int? IgnoredValue { get; set; }
public int IntegerValue { get; set; }
}
}
9 changes: 9 additions & 0 deletions Snowflake.Data.Tests/Client/DateTimeOffsetWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Snowflake.Data.Tests.Client
{
public class DateTimeOffsetWrapper
sfc-gh-mhofman marked this conversation as resolved.
Show resolved Hide resolved
{
public DateTimeOffset Value { get; set; }
}
}
9 changes: 9 additions & 0 deletions Snowflake.Data.Tests/Client/DateTimeWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Snowflake.Data.Tests.Client
{
public class DateTimeWrapper
{
public DateTime Value { get; set; }
}
}
46 changes: 46 additions & 0 deletions Snowflake.Data.Tests/Client/Grades.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.Generic;

namespace Snowflake.Data.Tests.Client
{
public class Grades
{
public string[] Names { get; set; }

public Grades()
{
}

public Grades(string[] names)
{
Names = names;
}
}

public class GradesWithList
{
public List<string> Names { get; set; }

public GradesWithList()
{
}

public GradesWithList(List<string> names)
{
Names = names;
}
}

public class GradesWithMap
{
public Dictionary<string, string> Names { get; set; }

public GradesWithMap()
{
}

public GradesWithMap(Dictionary<string, string> names)
{
Names = names;
}
}
}
34 changes: 34 additions & 0 deletions Snowflake.Data.Tests/Client/Identity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Snowflake.Data.Tests.Client
{
public class Identity
{
public string Name { get; set; }

public Identity()
{
}

public Identity(string name)
{
Name = name;
}

protected bool Equals(Identity other)
{
return Name == other.Name;
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Identity)obj);
}

public override int GetHashCode()
{
return (Name != null ? Name.GetHashCode() : 0);
}
}
}
14 changes: 14 additions & 0 deletions Snowflake.Data.Tests/Client/ObjectArrayMapWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace Snowflake.Data.Tests.Client
{
public class ObjectArrayMapWrapper
{
public Identity ObjectValue { get; set; }
public List<string> ListValue { get; set; }
public string[] ArrayValue { get; set; }
public IList<string> IListValue { get; set; }
public Dictionary<int, int> MapValue { get; set; }
public IDictionary<int, int> IMapValue { get; set; }
}
}
7 changes: 7 additions & 0 deletions Snowflake.Data.Tests/Client/StringWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Snowflake.Data.Tests.Client
{
public class StringWrapper
{
public string Value { get; set; }
}
}
40 changes: 40 additions & 0 deletions Snowflake.Data.Tests/Client/Zip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Snowflake.Data.Tests.Client
{
public class Zip
sfc-gh-mhofman marked this conversation as resolved.
Show resolved Hide resolved
{
public string prefix { get; set; }
public string postfix { get; set; }

public Zip()
{
}

public Zip(string prefix, string postfix)
{
this.prefix = prefix;
this.postfix = postfix;
}

protected bool Equals(Zip other)
{
return prefix == other.prefix && postfix == other.postfix;
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Zip)obj);
}

public override int GetHashCode()
{
#if NETFRAMEWORK
return prefix.GetHashCode() * 177 + postfix.GetHashCode();
#else
return System.HashCode.Combine(prefix, postfix);
#endif
}
}
}
12 changes: 12 additions & 0 deletions Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using NUnit.Framework;
using Snowflake.Data.Client;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Log;
using Snowflake.Data.Tests.Mock;
using Snowflake.Data.Tests.Util;

Expand All @@ -17,6 +18,7 @@ namespace Snowflake.Data.Tests.IntegrationTests
[NonParallelizable]
public class ConnectionMultiplePoolsIT: SFBaseTest
{
private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger<ConnectionPoolManager>();
sfc-gh-mhofman marked this conversation as resolved.
Show resolved Hide resolved
private readonly PoolConfig _previousPoolConfig = new PoolConfig();

[SetUp]
Expand Down Expand Up @@ -337,6 +339,7 @@ public void TestConnectionPoolExpirationWorks()

// act
WaitUntilAllSessionsCreatedOrTimeout(pool);
LogState(pool, "expecting 4 sections to be busy");
var beforeSleepMillis = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
Thread.Sleep(TimeSpan.FromSeconds(ExpirationTimeoutInSeconds));
conn1.Close();
Expand All @@ -345,21 +348,30 @@ public void TestConnectionPoolExpirationWorks()
conn4.Close();

// assert
LogState(pool, "expecting 2 sections to be idle after closing all sessions");
Assert.AreEqual(2, pool.GetCurrentPoolSize()); // 2 idle sessions, but expired because close doesn't remove expired sessions

// act
WaitUntilAllSessionsCreatedOrTimeout(pool);
LogState(pool, "before opening the next connection");
var conn5 = OpenConnection(connectionString);
WaitUntilAllSessionsCreatedOrTimeout(pool);

// assert
LogState(pool, "after opening the next connection");
Assert.AreEqual(2, pool.GetCurrentPoolSize()); // 1 idle session and 1 busy
var sessionStartTimes = pool.GetIdleSessionsStartTimes();
Assert.AreEqual(1, sessionStartTimes.Count);
Assert.That(sessionStartTimes.First(), Is.GreaterThan(beforeSleepMillis));
Assert.That(conn5.SfSession.GetStartTime(), Is.GreaterThan(beforeSleepMillis));
}

private void LogState(SessionPool pool, string context)
{
var state = pool.GetCurrentState();
s_logger.Warn($"{context}: {state}");
}

[Test]
public void TestMinPoolSize()
{
Expand Down
Loading
Loading