Skip to content

Commit

Permalink
SNOW-14887010 Structured types read for json result format (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko authored Sep 3, 2024
1 parent f178614 commit a0bbeb0
Show file tree
Hide file tree
Showing 45 changed files with 3,092 additions and 109 deletions.
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
{
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/AllNullableUnstructuredTypesClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Snowflake.Data.Tests.Client
{
public class AllNullableUnstructuredTypesClass
{
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; }
}
}
28 changes: 28 additions & 0 deletions Snowflake.Data.Tests/Client/AllUnstructuredTypesClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Snowflake.Data.Tests.Client
{
public class AllUnstructuredTypesClass
{
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)]
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; }
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
{
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
{
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
}
}
}
Loading

0 comments on commit a0bbeb0

Please sign in to comment.