Skip to content
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

Support TOP (OFFSET) in GROUP / JSON / PARTITION / FOR operators #1330

Closed
AlexKirkouski opened this issue Nov 11, 2024 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@AlexKirkouski
Copy link
Contributor

AlexKirkouski commented Nov 11, 2024

Example for GROUP (in MyCompany) :

smth = DATA INTEGER (Item);
first = DATA INTEGER (Category);
firstSmth(Category ct) = GROUP SUM smth(Item i) IF level(category(i), ct) ORDER DESC smth(i) TOP first(ct);

EXTEND FORM items
    PROPERTIES (c) first, firstSmth
    PROPERTIES (i) smth
;

Limiting some objects
Example for PARTITION (in MyCompany, using the upper example)

firstSmth(Item i, Category ct) = PARTITION LAST smth(i) IF level(category(i), ct) ORDER DESC smth(i) BY ct TOP first(ct) OFFSET 3;

EXTEND FORM items
    PROPERTIES firstSmth(i, c)
    
    OBJECTS ti = Item
    PROPERTIES name(ti), firstSmth(ti, c), smth(ti)
    FILTERS level(category(ti), c), firstSmth(ti, c)
;

Batching
Example for FOR (in MyCompany)

FOR iterate(INTEGER j, 0, [GROUP SUM 1 IF Item i IS Item]() / 50)  DO 
    NEWSESSION NEWSQL NEWTHREAD {
        sleep(15000);
        APPLY FOR Item i IS Item ORDER i TOP 50 OFFSET j * 50 DO
            smth(i) <- smth(i) + 1;
    }

Paging (for example in API)
Example for JSON (in myCompany)

getItems(STRING nameFilter, INTEGER page, INTEGER pageSize) {
    exportJSON() <- JSON FROM name(Item i) WHERE name(i) LIKE '%'+nameFilter+'%' ORDER name(i) TOP pageSize OFFSET (page - 1) * pageSize;    
}

Query: http://127.0.0.1:7651/exec/getItems?nameFilter=A&page=2&pageSize=50

@AlexKirkouski AlexKirkouski added the enhancement New feature or request label Nov 11, 2024
@AlexKirkouski AlexKirkouski self-assigned this Nov 11, 2024
@AlexKirkouski AlexKirkouski changed the title Support TOP (OFFSET) in GROUP / JSON operators Support TOP (OFFSET) in GROUP / JSON / PARTITION / FOR operators Dec 2, 2024
ichavchavadze added a commit that referenced this issue Dec 4, 2024
 #1330)

Support TOP (OFFSET) in GROUP / JSON / PARTITION / FOR operators (closes #1330)
@github-project-automation github-project-automation bot moved this from New to Done in lsfusion Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant