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
CREATE TABLE t(pk int PRIMARY KEY, col int, g int);
-- each of the following statements throws an error
SELECT col AS col FROM t HAVING AVG(col) > 0;
SELECT pk AS col FROM t HAVING AVG(col) > 0;
SELECT col AS col FROM t GROUP BY g HAVING AVG(col) > 0;
SELECT pk AS col FROM t GROUP BY g HAVING AVG(col) > 0;
The error is of the form unable to find field with index 6 in row of 3 columns.
The alias is necessary. SELECT col FROM t HAVING AVG(col) > 0; succeeds.
It looks like the analyzer creates GetField instances for the expressions that appear in the statement, including both the col alias, and the AVG(col) expression. Every GetField is assigned a column id which is also used as the field index. Thus, these GetFields which correspond to the expressions have column ids (and thus field indexes) which are greater than the total number of fields in the table. When evaluating the HAVING expression, the analyzer treats these ids as field indexes, sees that they're outside the acceptable range, and returns an error.
Of the ~350 remaining sqllogictest failures, this accounts for 73 of them.
The text was updated successfully, but these errors were encountered:
The error is of the form
unable to find field with index 6 in row of 3 columns
.The alias is necessary.
SELECT col FROM t HAVING AVG(col) > 0;
succeeds.It looks like the analyzer creates
GetField
instances for the expressions that appear in the statement, including both thecol
alias, and theAVG(col)
expression. EveryGetField
is assigned a column id which is also used as the field index. Thus, theseGetField
s which correspond to the expressions have column ids (and thus field indexes) which are greater than the total number of fields in the table. When evaluating the HAVING expression, the analyzer treats these ids as field indexes, sees that they're outside the acceptable range, and returns an error.Of the ~350 remaining sqllogictest failures, this accounts for 73 of them.
The text was updated successfully, but these errors were encountered: