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 UNION ALL in sql #47

Closed
ni-ze opened this issue Sep 22, 2022 · 0 comments
Closed

support UNION ALL in sql #47

ni-ze opened this issue Sep 22, 2022 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@ni-ze
Copy link
Collaborator

ni-ze commented Sep 22, 2022

The UNION ALL statement merges two streaming data. The fields of the two streaming data must be exactly the same, including the field type and field order.

test data:

  1. test_source_union1
a(varchar) b(bigint) c(bigint)
test1 1 10
  1. test_source_union2
a(varchar) b(bigint) c(bigint)
test1 1 10
test2 2 20
  1. test_source_union3
    a(varchar) | b(bigint) | c(bigint)
    -- | -- | --
    test1 | 1 | 10
    test2 | 2 | 20
    test1 | 1 | 10

test sql:

SELECT
    a,
    sum(b) as d,
    sum(c) as e
FROM 
    (SELECT * from test_source_union1
    UNION ALL
    SELECT * from test_source_union2
    UNION ALL
    SELECT * from test_source_union3
    )t
 GROUP BY a;   

Expected result:

a(varchar) d(bigint) e(bigint)
test1 1 10
test2 2 20
test1 2 20
test1 3 30
test2 4 40
test1 4 40
@ni-ze ni-ze added the help wanted Extra attention is needed label Sep 22, 2022
@ni-ze ni-ze closed this as completed Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant