Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some aggregate functions doesn't support NULL-constant in 3-d dialect [CORE1619] #2040

Closed
firebird-automations opened this issue Nov 26, 2007 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Kuznetsov Eugene (eugene)

Is related to QA537

For any 3-dialect base

select avg(Null) from rdb$relations
select sum(Null) from rdb$relations

return

Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements.
Dynamic SQL Error.
expression evaluation not supported

while it works fine for 1-dialect base

Best regards, Eugene

Commits: 5b0b907

====== Test Details ======

Checked: avg(null),sum(null);
New statistical functions in 3.0:
var_samp(null),var_pop(null)
,stddev_samp(null),stddev_pop(null)
,covar_samp(null, null),covar_pop(null, null)
,corr(null, null)

@firebird-automations
Copy link
Collaborator Author

Commented by: Claudio Valderrama C. (robocop)

This is really funny case:
SQL> select avg(null) from rdb$relations;
Statement failed, SQLCODE = -902
Dynamic SQL Error
-expression evaluation not supported
SQL> select sum(null) from rdb$relations;
Statement failed, SQLCODE = -902
Dynamic SQL Error
-expression evaluation not supported

You don't need to have a dialect 1 db. You only need to change the connection dialect to be 1:
SQL> set sql dialect 1;
WARNING: Client SQL dialect has been set to 1 when connecting to Database SQL dialect 3 database.
SQL> select sum(null) from rdb$relations;

                SUM

=======================
<null>

SQL> select avg(null) from rdb$relations;

                AVG

=======================
<null>

and it works. Inconsistent for the average user.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 13512 ] => Firebird [ 14076 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

While reviewing this ticket, I have one doubt. We describe the NULL literal as CHAR(1). Some arithmetical expressions change the datatype to something more appropriate, e.g. NULL + NULL = NULL as INT. MIN/MAX accept string inputs so MIN(NULL) = NULL as CHAR(1). But what AVG/SUM should return in this case? In usual conditions, they cannot return string data, so returning CHAR(1) looks a bit weird. Should the result be INT? Or maybe DOUBLE PRECISION?

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA537 [ QA537 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

Test Details: Checked: avg(null),sum(null);
New statistical functions in 3.0:
var_samp(null),var_pop(null)
,stddev_samp(null),stddev_pop(null)
,covar_samp(null, null),covar_pop(null, null)
,corr(null, null)

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment