EvgSkv / logica

Logica is a logic programming language that compiles to SQL. It runs on Google BigQuery, PostgreSQL and SQLite.

Home Page:https://logica.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to express array_agg(x order by t)?

jiamo opened this issue · comments

commented

In such query

GroupEvents1(user_pseudo_id, events? List= custom_event_name) distinct :-
    Events(user_pseudo_id:, custom_event_name:, event_timestamp:);

I want to get events with order by event_timestamp still find no answer in document?

It will be the same situation in Functional aggregation:

GroupEvents2(user_pseudo_id) List=  custom_event_name  :-
    Events(user_pseudo_id:, custom_event_name:, event_timestamp:);

This is done with Array aggregate operator. I've updated tutorial to mention it.

In your Functional example it would be like so:

GroupEvents2(user_pseudo_id) Array= event_timestamp -> custom_event_name :-
    Events(user_pseudo_id:, custom_event_name:, event_timestamp:);

Let me know if you have further questions.

commented

Thanks.