-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use 'Contains()' #5
Comments
hi @vijaymandave, would you expect the following sql to be generated? SELECT * FROM queryable_order
WHERE ((OrderTime >= 1630886400) AND (OrderTime <= 1630887401)) AND
Array_Contains(Array[1, 3], ordertype)
EMIT CHANGES; Is this what you would expect to be generated after the last AND clause? Array_Contains(Array[1, 3], ordertype) from C#: orderTypes.Contains(o.OrderType) Thank you for the detailed example. Tomas |
Hello @tomasfabian, Thanks to acknowledge our issue. Thank you, |
hi @vijaymandave I implemented IN operator. Could you try it out please?
var orderTypes = new List<int> { 1, 2, 3 };
Expression<Func<OrderData, bool>> expression = o => orderTypes.Contains(o.OrderType); Enumerable extension: IEnumerable<int> orderTypes = Enumerable.Range(1, 3);
Expression<Func<OrderData, bool>> expression = o => orderTypes.Contains(o.OrderType); For both options the following SQL is generated: OrderType IN (1, 2, 3) |
Thank you @tomasfabian, it works now. Appreciate your efforts. |
Not at all. I released v1.6.0. Enjoy. |
Hi, Hope you are well! For my class I am using GUID's as an id field and when I want to do a contains/IN its adding the GUID's but without the ' around the values. Think this is because in the VisitConstant method in the KsqlVisitor class its failing this check:
because its in a contains scope, so the value doesn't get handled by the CreateKSqlValue().ExtractValue logic and therefore never gets the ' around it. Not sure what the best fix for this would be. Thanks My classes:
The Table:
Then the pull query:
|
Hi @Markauto, |
Hi,
We have created order table and queryable_order in KSQL like below-
CREATE TABLE order (id INT PRIMARY KEY, eventtime BIGINT, ordertype INT , description VARCHAR) WITH (KAFKA_TOPIC='order', VALUE_FORMAT='PROTOBUF', PARTITIONS = 1);
CREATE TABLE queryable_order AS SELECT * FROM order;
We have written C# function as below-
using System;
using Kafka.DotNet.ksqlDB.KSql.Query;
using System.Reactive.Linq;
using Kafka.DotNet.ksqlDB.KSql.Linq.Statements;
using Kafka.DotNet.ksqlDB.KSql.Query.Context;
using Kafka.DotNet.ksqlDB.KSql.Linq;
using Kafka.DotNet.ksqlDB.KSql.Linq.PullQueries;
public static async void GetOrderStreamsAsync()
{
try
{
var url = @"http:\localhost:8088";
await using var context = new KSqlDBContext(new KSqlDBContextOptions(url));
var tablename = "queryable_order";
var orderTypes = new List { 1,3 };
}
public class OrderData: Record
{
public int Id { get; set; }
public long OrderTime { get; set; }
public int OrderType { get; set; }
public string Description { get; set; }
}
After printing QueryString IN Query missing after AND clause -
SELECT * FROM queryable_order
WHERE ((OrderTime >= 1630886400) AND (OrderTime <= 1630886401)) AND EMIT CHANGES;
We are getting below runtime error for Contains-
extraneous input 'CHANGES' expecting ';'
Statement: SELECT * FROM queryable_order
WHERE ((OrderTime >= 1630886400) AND (OrderTime <= 1630887401)) AND EMIT CHANGES;
The text was updated successfully, but these errors were encountered: