Re: Union of multiple datasets

2022-10-24 Thread abhijit
Thanks Jeremy. That works!

On Friday, October 21, 2022 at 10:31:53 PM UTC+5:30 Jeremy Evans wrote:

> On Fri, Oct 21, 2022 at 9:50 AM abhijit  wrote:
>
>> Hi,
>>
>> I have multiple dataset queries. What would be the best way to create a 
>> union in this scenario?
>>
>> I have tried -
>>
>> ds1.union(ds2.union(ds3.union)))
>>
>> as well as
>>
>> ds1.union(ds2).union(ds3)
>>
>> In either case, the resulting SQL looks unnecessarily nested, although 
>> the results are identical.
>>
>> Is there a better way?
>>
>
> You probably want:
>
> ds1.union(ds2, from_self: false).union(ds3, from_self: false)
>
> By default, unions are wrapped in a subselect so that filtering and other 
> changes on the resulting dataset works as expected.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/8ecafce7-613f-4d7a-84f3-16a61376d2edn%40googlegroups.com.


Re: Union of multiple datasets

2022-10-21 Thread Jeremy Evans
On Fri, Oct 21, 2022 at 9:50 AM abhijit  wrote:

> Hi,
>
> I have multiple dataset queries. What would be the best way to create a
> union in this scenario?
>
> I have tried -
>
> ds1.union(ds2.union(ds3.union)))
>
> as well as
>
> ds1.union(ds2).union(ds3)
>
> In either case, the resulting SQL looks unnecessarily nested, although the
> results are identical.
>
> Is there a better way?
>

You probably want:

ds1.union(ds2, from_self: false).union(ds3, from_self: false)

By default, unions are wrapped in a subselect so that filtering and other
changes on the resulting dataset works as expected.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSeyBSNNHoss%3Dg%2BPLHS5YRDEj5tL3q%2B0yVZcMi1zGBXsJQ%40mail.gmail.com.


Union of multiple datasets

2022-10-21 Thread abhijit
Hi,

I have multiple dataset queries. What would be the best way to create a 
union in this scenario?

I have tried -

ds1.union(ds2.union(ds3.union)))

as well as

ds1.union(ds2).union(ds3)

In either case, the resulting SQL looks unnecessarily nested, although the 
results are identical.

Is there a better way?

Thanks,
 - Abhijit.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/c52ad11e-7b87-47db-8f14-e1be7388460dn%40googlegroups.com.