dbcodeio / public

The Power of Databases, The Convenience of VS Code: All in One Place
10 stars 0 forks source link

Aggregation of numeric value treated as string value in query output #31

Closed devpkr1 closed 4 days ago

devpkr1 commented 6 days ago

Hi mike,

I have encountered with another bug/issue while doing analysis , i was written a query for average salary but when i had executed it . The Avg salary column in output is treated as string instead of numeric this is the big issue because avg of any number is numeric always not a string, it creates problem in chart creation also avg sal column is not displayed in series fields instead it is displayed in category because it is treated as string , i have worked on different plugins, database client none of them treating avg of any number as string.

I ahve attached the screenshot also Screenshot 2024-10-05 202657

Please resolve this problem

Thanks and Regards, Pradeep Kumar

mikeburgh commented 6 days ago

Thanks, will check it...

We use the data type the database driver returns for a query to determine the data type and hence if its string/date/number l... guessing MySQL is return it as a string for the aggregate... no idea why but we can do some sampling to verify and change it..

Does it work if you cast the aggregate function to a decimal/float/int ?

devpkr1 commented 5 days ago

Hi mike, I am sending you a screenshot of query after using cast , it is not treating as numeric even use of cast. I am also sending the screen recording of datagrip with same query without using cast, it is treating avg sal column as numeric.

Screenshot 2024-10-05 210205

https://github.com/user-attachments/assets/e4d7f16f-edcd-4882-8d0f-69ca7a7edbeb

mikeburgh commented 4 days ago

Yeah, was tied into #35, this should be fixed now as well in 1.2.16..

I also have a new type system for the drivers as part of table editing which I will re work into them and should prevent all these manual mappings that need to happen.