question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible feature: Add support for conditional joins over ConstantExpression

See original GitHub issue

Currently, there is no way how to do conditional join.

I can use trick with multi-column (tuples):

let query = 
    select {
        for l in table<MultiJoinLeft> do
        leftJoin r in table<MultiJoinRight> on ((123, l.Key2) = (r.Key1, r.Key2)) 
        selectAll
    }

…but this fails with NotImplementedException, because of ConstantExpression.

Need to investigate how difficult this could be to add…

cc: @JordanMarr : Any thoughts on this? 🤔

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
JordanMarrcommented, Jun 15, 2022

I think the tuple on syntax would map to LeftJoinOnMany which would probably be the easiest approach that would avoid having to change the InnerJoin and LeftJoin DUs.

But if I am understanding you correctly, implementing the “ideal syntax” example would involve changing to something like this:

type Join =
    | InnerJoin of table:string * onClause:Where
    | LeftJoin of table:string * onClause:Where
    | InnerJoinOnMany of table:string * List<string * string>
    | LeftJoinOnMany of table:string * List<string * string>

Which seems like that might be a good way to go. In fact that might even eliminate the need for InnerJoinOnMany and LeftJoinOnMany, which could actually be a nice consolidation:

type Join =
    | InnerJoin of table:string * onClause:Where
    | LeftJoin of table:string * onClause:Where
1reaction
JordanMarrcommented, Jun 16, 2022

That’s exactly what I did for the builder/expressions part. I will start a draft PR with what I have done so far.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible to implement a conditional join clause
Is it possible to implement a conditional join clause in Entity Framework 6? Specifically, INNER JOIN ON (boolean condition1) OR (boolean ...
Read more >
A different way of merging in Power BI
In this video I show you how to do a conditional join in Power Query. Instead of using the merge feature from the...
Read more >
Query syntax | BigQuery
The join operator and join condition specify how to combine and discard rows from the two from_item s to form a single source....
Read more >
Conditional Join
I think the following will help: Join both of the tables thru' Append Fields and insert a Filter where you use custom filters...
Read more >
SQL Conditional Join: A Comprehensive Guide
SQL conditional joins are a powerful technique for combining data from multiple tables based on specific conditions, allowing users to create more dynamic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found