zhouqingqing / qpmodel

A Relational Optimizer and Executor
MIT License
64 stars 18 forks source link

selecting non existing column returns null instead of error. #231

Closed pkommoju closed 3 years ago

pkommoju commented 3 years ago

select a.a1 from b; b doesn't have a1 and a is not an alias of b so this should raise error, but instead returns "null" as result.

zhouqingqing commented 3 years ago

This is what I get:

''' select a.a1 from b; ERROR[Optimizer]: can't bind column 'a1' to table Unhandled exception. qpmodel.logic.SemanticAnalyzeException: can't bind column 'a1' to table at qpmodel.expr.ColExpr.Bind(BindContext context) in D:\qpmodel\qpmodel\Expr.cs:line 987 at qpmodel.expr.Expr.BindAndNormalize(BindContext context) in D:\qpmodel\qpmodel\Expr.cs:line 762 at qpmodel.logic.SelectStmt.bindSelectionList(BindContext context) in D:\qpmodel\qpmodel\Plan.cs:line 665 at qpmodel.logic.SelectStmt.BindWithContext(BindContext context) in D:\qpmodel\qpmodel\Plan.cs:line 693 at qpmodel.logic.SelectStmt.Bind(BindContext parent) in D:\qpmodel\qpmodel\Plan.cs:line 602 at qpmodel.Program.Main(String[] args) in D:\qpmodel\qpmodel\Program.cs:line 293 '''

It looks right to me.

pkommoju commented 3 years ago

That's is what I expect but how did it return null?

zhouqingqing commented 3 years ago

That's is what I expect but how did it return null?

I think @9DemonFox may confused with this output vs. ExecSQL() API's return result, which returns null upon error.

pkommoju commented 3 years ago

I was in the middle of a debug session, which is why I couldn't verify it and instead opened an issue. I will close it as a "Not A Bug".

pkommoju commented 3 years ago

Not a bug. It returns error correctly.