tomasfabian / ksqlDB.RestApi.Client-DotNet

ksqlDb.RestApi.Client is a C# LINQ-enabled client API for issuing and consuming ksqlDB push and pull queries and executing statements.
MIT License
93 stars 24 forks source link

How to perform EXPLODE on a generic array? #54

Closed vnkkarpenko closed 5 months ago

vnkkarpenko commented 5 months ago

Hi, I have a question how to group the Id and DetailId fields to get the final price and quantity values without subscribing so that the data aggregation is done only on ksqldb?

Thank you!

my models:


public class SalesAggregatedModel
{
    public string Version { get; set; }
    public SalesHeadModel Head { get; set; }
    public List<SalesDetailsModel> Details { get; set; }
}

public class SalesHeadModel
{
    [Key]
    public int Id { get; set; }
    public string StreamType { get; set; }
}

public class SalesDetailsModel
{
    public int DetailId { get; set; }
    public double Quantity { get; set; }
    public double Price { get; set; }
    public string Date { get; set; }
}
tomasfabian commented 5 months ago

Hello @vnkkarpenko, are you asking for an integration of the Explode table function in ksqlDb.RestApi.Client?

vnkkarpenko commented 5 months ago

Hello @vnkkarpenko, are you asking for an integration of the Explode table function in ksqlDb.RestApi.Client?

Hello @tomasfabian, It will probably take a long time to integrate, maybe there is an analogue of this function or another solution to get a similar result for my models?

tomasfabian commented 5 months ago

This dynamic approach could function as a temporary workaround until I incorporate type-safe support for the Explode function: https://github.com/tomasfabian/ksqlDB.RestApi.Client-DotNet/blob/main/docs/functions.md#dynamic---calling-not-supported-ksqldb-functions

vnkkarpenko commented 5 months ago

Thank you!

tomasfabian commented 5 months ago

Hello @vnkkarpenko, you can use the Explode table function with ksqlDb.RestApi.Client v3.5.0 in the following manner.

using ksqlDB.RestApi.Client.KSql.Query.Functions;

Select(l => new { Result = l.Details.Explode() })
vnkkarpenko commented 5 months ago

Hello @tomasfabian, Thank you very much!