Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion qpmodel/DataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ public JoinQueryRef(List<TableRef> tables, List<string> joinops, List<Expr> cons
{
case "join": type = JoinType.Inner; break;
case "leftjoin": case "leftouterjoin": type = JoinType.Left; break;
case "crossjoin":
case "crossjoin": type = JoinType.Inner; break;
case "naturaljoin": type = JoinType.Inner; break;
case "naturalleftjoin":
case "naturalleftouterjoin": type = JoinType.Left; break;
Comment on lines +610 to +612

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NATURAL JOIN is being mapped to an inner/left join type, but no code adds the required equality predicates on same-named columns. With the current Plan-building changes that allow a null join constraint, NATURAL JOIN will behave like a CROSS JOIN whenever there are common column names, producing incorrect results. Either implement natural-join predicate generation during binding/planning, or reject NATURAL JOIN with a NotImplemented/SemanticAnalyzeException until supported.

Suggested change
case "naturaljoin": type = JoinType.Inner; break;
case "naturalleftjoin":
case "naturalleftouterjoin": type = JoinType.Left; break;
case "naturaljoin":
case "naturalleftjoin":
case "naturalleftouterjoin":
throw new SemanticAnalyzeException("NATURAL JOIN is not implemented");

Copilot uses AI. Check for mistakes.
case "rightjoin":
case "rightouterjoin":
case "fulljoin":
Expand Down
2 changes: 2 additions & 0 deletions qpmodel/Expr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,8 @@ public static ConstExpr MakeConst(Value val, ColumnType type, string outputName
ConstExpr ret;
if (type is CharType || type is VarCharType || type is DateTimeType)
ret = new ConstExpr($"'{val}'", type);
else if (type is IntType && val != null)
ret = new ConstExpr($"{Convert.ToInt32(val)}", type);
else
ret = new ConstExpr($"{val}", type);
ret.outputName_ = outputName;
Expand Down
Loading
Loading