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

Unhandled type error when data field exists and data value is null #10

Closed
haxorof opened this issue May 21, 2017 · 3 comments
Closed

Unhandled type error when data field exists and data value is null #10

haxorof opened this issue May 21, 2017 · 3 comments
Labels

Comments

@haxorof
Copy link
Contributor

haxorof commented May 21, 2017

It seems that if a SQL statement executes successfully and return with null the following error is seen in the logs:

Error setting metrics: Unhandled type %!s(<nil>)

This error is not that which is also easily fixed by doing a nil check on dataVal in set.go.

@haxorof haxorof added the bug label May 21, 2017
@wangyanbn
Copy link
Contributor

we can fix the SQL statement, make it returning the proper value instead of null.
e.g. select NVL(FieldMayBeNull,0) as FieldNotNull from SomeTable

@haxorof
Copy link
Contributor Author

haxorof commented May 23, 2017

This is the query I ran when I saw this error in the log:

- transaction_avg:
    driver: mysql
    connection:
        host: mysql
        port: 3306
        user: root
        password: unsecure
        database: test
    sql: >
         select avg(trans_end - trans_start) AS trans_avg from business_trans
            where trans_end is not null and trans_end between adddate(CURRENT_TIMESTAMP, INTERVAL -1 MINUTE) and CURRENT_TIMESTAMP;
    interval: 5s
    data-field: trans_avg

I will have to check if NVL is possible to use when not rows are returned.

Anyway, in the scenario when data field is available and data value is null the error log is not that clear that the query just returned null which is not supported to handle at the time. Introducing a data value check for nil and just print it out that data was null will be a very small change but more understandable for the user of prometheus-sql what to fix. :)

@pschou
Copy link

pschou commented Nov 21, 2020

This may be addressed in #66 with mapping nil to NaN.

haxorof added a commit that referenced this issue Jun 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants