You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there are two or more tables in a query, and those two tables have an identical column name, the column needs to be disambiguated somehow.
Example 1: In most (all?) SQL DBs, one can use an alias, as shown here:
SELECT low.temperature, high.temperature FROM daily_lows low JOIN daily_highs high ON low.day = high.day;
Example 2: In most SQL DBs (or, at least mysql and postgres), one can use the table name directly:
SELECT daily_lows.temperature, daily_highs.temperature FROM daily_lows JOIN daily_highs ON daily_lows.day = daily_highs.day;
However, in q, only Example 1 works. Being able to refer to the filename to disambiguate columns would help those expecting q to behave similar to other SQL engines.
Steps to reproduce
Create a file, daily_lows:
day,temperature
1,10
2,11
3,12
Create a file, daily_highs:
1,20
2,21
3,22
Query the file with aliases to verify the files work: q-text-as-data -d, -H 'SELECT low.temperature, high.temperature FROM daily_lows low JOIN daily_highs high ON low.day = high.day;'
Query the file without aliases: q-text-as-data -d, -H 'SELECT daily_lows.temperature, daily_highs.temperature FROM daily_lows JOIN daily_highs ON daily_lows.day = daily_highs.day;'
Actual results
The second query fails to find the columns:
query error: no such column: daily_lows.temperature
Warning - There seems to be a "no such column" error, and -H (header line) exists. Please make sure that you are using the column names from the header line and not the default (cXX) column names. Another issue might be that the file contains a BOM. Files that are encoded with UTF8 and contain a BOM can be read by specifying `-e utf-9-sig` in the command line. Support for non-UTF8 encoding will be provided in the future.
Expected results
The second query works just like the first:
10,20
11,21
12,22
Notes
This issue may be a duplicate of #87 "Allow access to the original filename in queries" but I wasn't sure since there was no description.
The text was updated successfully, but these errors were encountered:
Description
When there are two or more tables in a query, and those two tables have an identical column name, the column needs to be disambiguated somehow.
Example 1: In most (all?) SQL DBs, one can use an alias, as shown here:
Example 2: In most SQL DBs (or, at least mysql and postgres), one can use the table name directly:
However, in
q
, only Example 1 works. Being able to refer to the filename to disambiguate columns would help those expectingq
to behave similar to other SQL engines.Steps to reproduce
daily_lows
:daily_highs
:q-text-as-data -d, -H 'SELECT low.temperature, high.temperature FROM daily_lows low JOIN daily_highs high ON low.day = high.day;'
q-text-as-data -d, -H 'SELECT daily_lows.temperature, daily_highs.temperature FROM daily_lows JOIN daily_highs ON daily_lows.day = daily_highs.day;'
Actual results
The second query fails to find the columns:
Expected results
The second query works just like the first:
Notes
This issue may be a duplicate of #87 "Allow access to the original filename in queries" but I wasn't sure since there was no description.
The text was updated successfully, but these errors were encountered: