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
{{ message }}
Repository navigation
In a join, an unqualified column that is NULL in the first source takes the value of the second source #2873
In a join, an unqualified column that is NULL in the first source takes its value from the second source. WHERE x IS NULL stops finding the row, and x + 0 reads the other table's value.
varA=[{id: 1,x: null},{id: 2,x: 20}];varB=[{id: 1,x: 100},{id: 2,x: 200}];alasql('SELECT t0.id FROM ? t0 JOIN ? t1 ON t0.id = t1.id WHERE x IS NULL',[A,B]);// [] (4.20.0: [{id: 1}])alasql('SELECT t0.id, x + 0 AS v FROM ? t0 JOIN ? t1 ON t0.id = t1.id',[A,B]);// [{id: 1, v: 100}, {id: 2, v: 20}] (4.20.0: v is missing for id 1)
Expected: the first query gives [{id: 1}], and v is NULL for id 1.
Since #2579 (in 4.21.0). An unqualified column that is not in defcols compiles to p['t0']?.['x'] ?? p['t1']?.['x'] (Column.toJS and Column.fromAnySource in src/expression/expression.js, and its use in src/select/columns.js), so a NULL falls through to the next source. It affects WHERE, ON, ORDER BY, GROUP BY and computed columns. The fix: go to the next source only when the row has no such property ('x' in p['t0']), not when the value is NULL, and add a test with NULL in the first source (test E of #2579 has no NULL).
Activity
Read an unqualified join column from the first source that has it to c…
Fix result for unqualified column that is NULL to close AlaSQL#2873 (A…