FLUX Left join template

Hey Team,

I’m not clear on the ‘as’ parameter of the join.left function in FLUX, I’m trying to gain a level of clarity on the flux syntax that is similar to SQL. For instance:

Query 1:select a*, b* from A left join B on A.id = B.id
Query 1 Purpose: Join table A with table B using the id column in table A and the id column in table B. Then select all columns from table A and all columns from Table B.

Query 2: select A.var1, A.var2, A.var3, B.var1, B.var2, B.var3 from a left join b on A.id = B.id
Query 2 Purpose: Join table A with table B using the id column in table A and the id column in table B. Then select columns var1, var2 and v3 from table A and columns var1, var2 and v3 from table B.

My attempt to translate this into FLUX:

Query 1 flux version:
join.left(
left: A,
right: B,
on: (l, r) => l.id == r.id,
as: (l, r) => ({???}),)

Query 2 flux version:
join.left(
left: A,
right: B,
on: (l, r) => l.id == r.id,
as: (l, r) => ({
user_entry_col_name_1: l.col1,
user_entry_col_name_2: l.col2,
user_entry_col_name_3: l.col3,
user_entry_col_name_4: r.col1,
user_entry_col_name_5: r.col2,
user_entry_col_name_6: r.col3}),
)

Could you please advise on the flux equivalent on Query 1 and whether the Query 2 flux version template is correct?

@scott , @Anaisdg , @grant1 tagging for attention :pray:

Hello @ajetsharwin,
I’m not sure I really understand your question.
Query 2 looks correct though. Are you not getting what you expect?

Hey Anaias,

Sure, so my questions are as follows:

Question 1: How to left join two tables and keep all columns from both the tables in FLUX? In the SQL version it’s simply select a*, b* from A left join B on A.id = B.id. How do we do the same in FLUX?

Question 2: For Query two, I have seen you use with in the as parameter of the join.left function. For instance here in 27793.
I’m want to make sure I have strict understanding of the syntax here, why is there with in some code and in others it’s not?