[jira] [Updated] (IGNITE-18196) .NET: Thin 3.0: LINQ: Sum and Count fail with cast exception

2022-11-21 Thread Pavel Tupitsyn (Jira)


 [ 
https://issues.apache.org/jira/browse/IGNITE-18196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pavel Tupitsyn updated IGNITE-18196:

Issue Type: Bug  (was: Improvement)

> .NET: Thin 3.0: LINQ: Sum and Count fail with cast exception
> 
>
> Key: IGNITE-18196
> URL: https://issues.apache.org/jira/browse/IGNITE-18196
> Project: Ignite
>  Issue Type: Bug
>  Components: platforms, thin client
>Reporter: Pavel Tupitsyn
>Assignee: Pavel Tupitsyn
>Priority: Major
>  Labels: .NET, LINQ, ignite-3
> Fix For: 3.0.0-beta2
>
>
> SQL engine returns *long* instead of *int* for COUNT and SUM, which causes an 
> exception during materialization:
> {code}
> System.ArgumentException : Object of type 'System.Int64' cannot be converted 
> to type 'System.Int32'.
>at System.RuntimeType.TryChangeType(Object value, Binder binder, 
> CultureInfo culture, Boolean needsSpecialCast)
>at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo 
> culture, BindingFlags invokeAttr)
>at System.Reflection.MethodBase.CheckArguments(StackAllocedArguments& 
> stackArgs, ReadOnlySpan`1 parameters, Binder binder, BindingFlags invokeAttr, 
> CultureInfo culture, Signature sig)
>at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags 
> invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
>at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
>at 
> Apache.Ignite.Internal.Linq.IgniteQueryExecutor.<>c__DisplayClass9_0`1.b__0(IReadOnlyList`1
>  cols, BinaryTupleReader& reader) in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryExecutor.cs:line
>  146
>at Apache.Ignite.Internal.Sql.ResultSet`1.ReadRow(IReadOnlyList`1 cols, 
> MessagePackReader& reader) in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
>  226
>at 
> Apache.Ignite.Internal.Sql.ResultSet`1.<>c__DisplayClass29_0.d.MoveNext()
>  in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
>  269
>at Apache.Ignite.Internal.Sql.ResultSet`1.EnumerateRows()+MoveNext() in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
>  236
>at 
> Apache.Ignite.Internal.Sql.ResultSet`1.EnumerateRows()+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()
>at 
> Apache.Ignite.Internal.Linq.IgniteQueryExecutor.ExecuteCollection[T](QueryModel
>  queryModel)+MoveNext() in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryExecutor.cs:line
>  85
>at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
>at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
>at Apache.Ignite.Tests.Linq.LinqTests.TestGroupByWithCountAndSum() in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.GroupBy.cs:line
>  57
> {code}
> Reproducer:
> {code}
> var query = PocoByteView.AsQueryable()
> .GroupBy(x => x.Val)
> .Select(x => new { x.Key, Count = (long)x.Count(), Sum = x.Sum(e 
> => e.Key) })
> .OrderBy(x => x.Key);
> var res = query.ToList();
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IGNITE-18196) .NET: Thin 3.0: LINQ: Sum and Count fail with cast exception

2022-11-18 Thread Pavel Tupitsyn (Jira)


 [ 
https://issues.apache.org/jira/browse/IGNITE-18196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pavel Tupitsyn updated IGNITE-18196:

Description: 
SQL engine returns *long* instead of *int* for COUNT and SUM, which causes an 
exception during materialization:

{code}
System.ArgumentException : Object of type 'System.Int64' cannot be converted to 
type 'System.Int32'.
   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo 
culture, Boolean needsSpecialCast)
   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo 
culture, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(StackAllocedArguments& 
stackArgs, ReadOnlySpan`1 parameters, Binder binder, BindingFlags invokeAttr, 
CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, 
Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
   at 
Apache.Ignite.Internal.Linq.IgniteQueryExecutor.<>c__DisplayClass9_0`1.b__0(IReadOnlyList`1
 cols, BinaryTupleReader& reader) in 
/home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryExecutor.cs:line
 146
   at Apache.Ignite.Internal.Sql.ResultSet`1.ReadRow(IReadOnlyList`1 cols, 
MessagePackReader& reader) in 
/home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
 226
   at 
Apache.Ignite.Internal.Sql.ResultSet`1.<>c__DisplayClass29_0.d.MoveNext()
 in 
/home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
 269
   at Apache.Ignite.Internal.Sql.ResultSet`1.EnumerateRows()+MoveNext() in 
/home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
 236
   at 
Apache.Ignite.Internal.Sql.ResultSet`1.EnumerateRows()+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()
   at 
Apache.Ignite.Internal.Linq.IgniteQueryExecutor.ExecuteCollection[T](QueryModel 
queryModel)+MoveNext() in 
/home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryExecutor.cs:line
 85
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Apache.Ignite.Tests.Linq.LinqTests.TestGroupByWithCountAndSum() in 
/home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.GroupBy.cs:line
 57
{code}

Reproducer:
{code}
var query = PocoByteView.AsQueryable()
.GroupBy(x => x.Val)
.Select(x => new { x.Key, Count = (long)x.Count(), Sum = x.Sum(e => 
e.Key) })
.OrderBy(x => x.Key);

var res = query.ToList();
{code}

  was:Support queries with groupings in the LINQ provider.


> .NET: Thin 3.0: LINQ: Sum and Count fail with cast exception
> 
>
> Key: IGNITE-18196
> URL: https://issues.apache.org/jira/browse/IGNITE-18196
> Project: Ignite
>  Issue Type: Improvement
>  Components: platforms, thin client
>Reporter: Pavel Tupitsyn
>Assignee: Pavel Tupitsyn
>Priority: Major
>  Labels: .NET, LINQ, ignite-3
> Fix For: 3.0.0-beta2
>
>
> SQL engine returns *long* instead of *int* for COUNT and SUM, which causes an 
> exception during materialization:
> {code}
> System.ArgumentException : Object of type 'System.Int64' cannot be converted 
> to type 'System.Int32'.
>at System.RuntimeType.TryChangeType(Object value, Binder binder, 
> CultureInfo culture, Boolean needsSpecialCast)
>at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo 
> culture, BindingFlags invokeAttr)
>at System.Reflection.MethodBase.CheckArguments(StackAllocedArguments& 
> stackArgs, ReadOnlySpan`1 parameters, Binder binder, BindingFlags invokeAttr, 
> CultureInfo culture, Signature sig)
>at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags 
> invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
>at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
>at 
> Apache.Ignite.Internal.Linq.IgniteQueryExecutor.<>c__DisplayClass9_0`1.b__0(IReadOnlyList`1
>  cols, BinaryTupleReader& reader) in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryExecutor.cs:line
>  146
>at Apache.Ignite.Internal.Sql.ResultSet`1.ReadRow(IReadOnlyList`1 cols, 
> MessagePackReader& reader) in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
>  226
>at 
> Apache.Ignite.Internal.Sql.ResultSet`1.<>c__DisplayClass29_0.d.MoveNext()
>  in 
> /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs:line
>  269
>at