-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat: support string functions [LINQ] #500
Conversation
09b7387
to
817a9f0
Compare
@powersj could you review? |
@bednar could you review this? |
Yes, I can. Can you rebase sources to trigger checks? Regards |
rebase done |
1743608
to
699ce13
Compare
@bednar an chance to get this merged? |
Hi @jogibear9988, I plan to review your PR either today or tomorrow. In the meantime, could you please correct the formatting of your code? You can do this by running ./Scripts/reformat-code.sh in the root of the project. Best Regards |
699ce13
to
971245d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR 👍
There are a few requirements that must be be satisfy before we accept the PR:
- Please update CHANGELOG.md file
and also:
I've now created the classes, but with the name of the C# functions. Is this okay? I could also use the name of Influx, but then also "ToString" should be named "String" |
118a69c
to
4c6f9f2
Compare
4c6f9f2
to
aa19ce1
Compare
Should I change QueryAggregator, to use Lazy initalized Fields for the other parts as well? So only memory is used when for example filters, sortings,... are used? |
aa19ce1
to
fb8aeff
Compare
fb8aeff
to
8dc5afa
Compare
It is ok. Thanks
If you have the time, yes, please make the change. However, if you're unable to do so, you may leave the code as is; it won't block the approval process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we're almost ready to merge
this PR into our master branch. Please satisfy the following requirements for the tests:
[Test] | ||
public void StringFunctionsQuery() | ||
{ | ||
var query = from s in InfluxDBQueryable<Sensor>.Queryable("my-bucket", "my-org", _queryApi) | ||
where s.SensorId.ToLower().Contains("aaa") | ||
select s; | ||
var visitor = BuildQueryVisitor(query); | ||
|
||
const string expected = | ||
"import \"strings\"\nstart_shifted = int(v: time(v: p2))\n\nfrom(bucket: p1) |> range(start: time(v: start_shifted)) |> filter(fn: (r) => strings.containsStr(v: strings.toLower(v: r[\"sensor_id\"]), substr: p3)) |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\") |> drop(columns: [\"_start\", \"_stop\", \"_measurement\"]) |> filter(fn: (r) => strings.containsStr(v: strings.toLower(v: r[\"sensor_id\"]), substr: p3))"; | ||
var qry = visitor.BuildFluxQuery(); | ||
Assert.AreEqual(expected, visitor.BuildFluxQuery()); | ||
} | ||
|
||
[Test] | ||
public void ToStringFunctionQuery() | ||
{ | ||
var query = from s in InfluxDBQueryable<Sensor>.Queryable("my-bucket", "my-org", _queryApi) | ||
where s.Value.ToString() == "3" | ||
select s; | ||
var visitor = BuildQueryVisitor(query); | ||
|
||
const string expected = | ||
"start_shifted = int(v: time(v: p2))\n\nfrom(bucket: p1) |> range(start: time(v: start_shifted)) |> filter(fn: (r) => (string(v: r[\"data\"]) == p3)) |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\") |> drop(columns: [\"_start\", \"_stop\", \"_measurement\"]) |> filter(fn: (r) => (string(v: r[\"data\"]) == p3))"; | ||
var qry = visitor.BuildFluxQuery(); | ||
Assert.AreEqual(expected, visitor.BuildFluxQuery()); | ||
} | ||
|
||
[Test] | ||
public void ReplaceAllFunctionQuery() | ||
{ | ||
var query = from s in InfluxDBQueryable<Sensor>.Queryable("my-bucket", "my-org", _queryApi) | ||
where s.SensorId.ToLower().Replace("a", "b") == "b" | ||
select s; | ||
var visitor = BuildQueryVisitor(query); | ||
|
||
const string expected = | ||
"import \"strings\"\nstart_shifted = int(v: time(v: p2))\n\nfrom(bucket: p1) |> range(start: time(v: start_shifted)) |> filter(fn: (r) => (strings.replaceAll(v: strings.toLower(v: r[\"sensor_id\"]), t: p3, u: p4) == p5)) |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\") |> drop(columns: [\"_start\", \"_stop\", \"_measurement\"]) |> filter(fn: (r) => (strings.replaceAll(v: strings.toLower(v: r[\"sensor_id\"]), t: p3, u: p4) == p5))"; | ||
var qry = visitor.BuildFluxQuery(); | ||
Assert.AreEqual(expected, visitor.BuildFluxQuery()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include tests for all new string functions, and also evaluate the parameters of the Flux query. Here's an example of what we're looking for:
Assert.AreEqual("4", GetLiteral<IntegerLiteral>(ast, 2).Value); |
hopefully i can fix the rest next week |
@jogibear9988 thanks, awesome news 👍 |
@bednar |
This PR has been closed because it has not had recent activity. Please reopen if this PR is still important to you and you want to continue with them. |
Closes #499
Proposed Changes
Support string functions from linq
Checklist
dotnet test
completes successfully