Column qualified with a quoted table name that contains a dot fails in SELECT and outer join ON
A column reference qualified with a quoted table name that contains a dot, such as
"t.1".w, fails in the select list and in the filter of an outer join ON clause.
The same reference works in WHERE and as an outer join key.
Reproduce (master 641aa5fee5)
CREATE TABLE f0 (a0 INT, b0 INT, v INT);
INSERT INTO f0 VALUES (2, null, 1), (3, 1, 3), (2, 2, 2);
CREATE TABLE 't.1' (a1 INT, b1 INT, w INT);
INSERT INTO 't.1' VALUES (3, 2, 1), (2, 2, 2), (null, 1, 3), (3, 3, 2), (3, 1, 3);
-- fails with an internal error: wtf? "t.1".w
SELECT "t.1".w FROM f0 JOIN 't.1' ON b1 = b0;
-- fails: [48] Invalid column: "t.1".w (also with 't.1'.w)
SELECT * FROM f0 LEFT JOIN 't.1' ON b1 = b0 AND "t.1".w > 1;
-- work
SELECT * FROM f0 JOIN 't.1' ON b1 = b0 WHERE "t.1".w > 1;
SELECT * FROM f0 LEFT JOIN 't.1' ON "t.1".b1 = b0;Expected
All four statements accept "t.1".w as a reference to column w of table t.1.
The select-list case should never surface an internal (wtf?) message.
Notes
JoinRecordMetadata.getColumnIndexQuiet() splits the reference at the last unquoted
dot and looks up the table part as written, quotes included. The table alias it
registered has no quotes. QueryModel.getModelAliasIndex() strips the quotes, which
may explain why the optimiser-side paths (WHERE, join keys) work. I have not traced
the select-list path.
Possibly related: #7478 (a quoted column alias containing dots is truncated at the last dot).
Found while working on #7674.
Source: questdb/questdb