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

sql union operator #1096

Merged
merged 3 commits into from
May 3, 2022
Merged

sql union operator #1096

merged 3 commits into from
May 3, 2022

Conversation

jeroiraz
Copy link
Contributor

@jeroiraz jeroiraz commented Jan 13, 2022

This PR introduces support for UNION operator.

All subqueries must select the same number of columns, with the same types. While names can differ, the final return will assign the naming as in the first subquery.

SELECT * FROM mytable WHERE id < 10 UNION SELECT * FROM mytable WHERE id > 10

SELECT MAX(age) FROM mytable1 UNION ALL SELECT MIN(age) FROM mytable2

@jeroiraz jeroiraz force-pushed the sql_union branch 2 times, most recently from 9a16b10 to f1aca3c Compare January 13, 2022 20:32
@coveralls
Copy link
Collaborator

coveralls commented Jan 13, 2022

Coverage Status

Coverage decreased (-0.2%) to 89.416% when pulling 4b0a68b on sql_union into 5e053f8 on master.

@sonarcloud
Copy link

sonarcloud bot commented Jan 17, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

86.4% 86.4% Coverage
0.0% 0.0% Duplication

@tomekkolo tomekkolo added this to the v1.3 milestone Apr 17, 2022
@byo
Copy link
Contributor

byo commented Apr 21, 2022

@jeroiraz please rebase on current master

@jeroiraz jeroiraz mentioned this pull request Apr 27, 2022
@byo byo changed the base branch from master to sql_temporal_queries May 3, 2022 08:35
Copy link
Contributor

@byo byo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only some minor comments added

embedded/sql/parser_test.go Show resolved Hide resolved
embedded/sql/union_row_reader.go Outdated Show resolved Hide resolved
@@ -107,7 +107,7 @@ func TestTransaction_Rollback(t *testing.T) {

res, err := tx1.SQLQuery(context.TODO(), "SELECT * FROM table1", nil)
require.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ErrorIs here?

@@ -75,7 +75,7 @@ func TestConn_BeginTx(t *testing.T) {
_, err = db.Exec(fmt.Sprintf("INSERT INTO %s (id, amount, total, title, content, isPresent) VALUES (1, 1000, 6000, 'title 1', x'%s', true)", table, blobContent))
require.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ErrorIs here?

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

test(embedded/sql): unit testing union stmt parsing

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

chore(embedded/sql): positional-based union operator

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

chore(embedded/sql): include contextual information in error

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

chore(embedded/sql): improve error message when specifying older value in an auto_incremental column

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

chore(embedded/sql): use first subquery selectors in all union subqueries

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

test(pkg/stdlib): update unit testing based on more descriptive error messages

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

test(pkg/stdlib): update unit testing based on more descriptive error messages

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

test(pkg/stdlib): update unit testing based on more descriptive error messages

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>
Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>
Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>
@sonarcloud
Copy link

sonarcloud bot commented May 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

92.8% 92.8% Coverage
0.0% 0.0% Duplication

@jeroiraz jeroiraz merged commit a85ed34 into sql_temporal_queries May 3, 2022
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.

4 participants