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

Compound statements with variable number of select statements #1241

Merged
merged 20 commits into from
Nov 9, 2023

Conversation

trueqbit
Copy link
Collaborator

@trueqbit trueqbit commented Oct 25, 2023

This PR extends the operators for compound statements (i.e. union_, union_all, intersect, except)

  • to accept a variable number of single select statements, which is especially useful for UNION ALL,
  • to allow the select statements to return a common type.

Additionally:

  • Simplified code for the calculation of node tuples.
  • Improved unit tests for node tuples.

My motivating use case is to be able to handpick multiple value ranges:

struct Object {
    int64 id;
    int64 difference;   // diff value in days
};

union_all(
    select(cast<int64>(min(&Object::difference))),
    select(count(), where(c(&Object::difference) < 0)),
    select(count(), where(c(&Object::difference) >= 0 and c(&Object::difference) < 7)),
    select(count(), where(c(&Object::difference) >= 7 and c(&Object::difference) < 15)),
    ...
);

@trueqbit trueqbit requested a review from fnc12 October 25, 2023 11:57
dev/column_result.h Show resolved Hide resolved
dev/tuple_helper/tuple_iteration.h Show resolved Hide resolved
tests/prepared_statement_tests/update_all.cpp Show resolved Hide resolved
@fnc12 fnc12 merged commit 79f1117 into fnc12:dev Nov 9, 2023
1 check passed
@trueqbit trueqbit deleted the multi-compound branch November 11, 2023 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants