Closed derekmahar closed 3 years ago
You cannot use the same table name in the same scope, so that is the expected behavior. However, it may not be a problem to allow the same table name on both sides of the set operator.
The same table can be merged by adding aliases to the table name.
$ printf "a,b\n1,2\n3,4\n" | csvq "SELECT * FROM STDIN t1 UNION ALL SELECT * FROM STDIN t2"
You can also enclose the queries on both sides of the set operator in parentheses.
$ printf "a,b\n1,2\n3,4\n" | csvq "(SELECT * FROM STDIN) UNION ALL (SELECT * FROM STDIN)"
...Oh? I'm getting a syntax error with this query. Maybe this is a bug.
The version 1.15.1 allows same table names on both sides of set operators.
In a SELECT UNION query, shouldn't csvq allow the use of the same table name in any or all of its component queries? For example, instead of reporting a duplicate table name error, shouldn't the following query calculate the union of the input rows?
Actual result:
Expected result:
Note that this query worked in an earlier version of csvq, but I don't recall exactly which version.