question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid numeric value

See original GitHub issue

Library Version

.NET Runtime

Xamarin Forms UWP / Android / iOS

Log Output

The following QueryBuilder expression gives a “Invalid numeric valu” (spelling is wrong too) message (note that the Latitude and Longitude properties are double and that the N1QL version of this query runs perfectly on the server):

var srcLat = Expression.Double(41.482343);//zip.Latitude); var srcLong = Expression.Double(-81.794563);//zip.Longitude);

				//AND acos(sin(radians(srcLat)) * sin(RADIANS(Latitude)) + cos(RADIANS(srcLat)) * cos(RADIANS(Latitude)) * cos(RADIANS(srcLong) - RADIANS(Longitude))) * 3955
				var formula = Function.Acos(Function.Sin(Function.Radians(srcLat))
													.Multiply(Function.Sin(Function.Radians(Expression.Property(nameof(Directory.Latitude)))))
													.Add(Function.Cos(Function.Radians(srcLat)))
													.Multiply(Function.Cos(Function.Radians(Expression.Property(nameof(Directory.Latitude)))))
													.Multiply(Function.Cos(Function.Radians(srcLong).Subtract(Function.Radians(Expression.Property(nameof(Directory.Longitude)))))))
				                      .Multiply(Expression.Double(3955));
				where = where.And(formula.LessThanOrEqualTo(Expression.Double(10)));//(int)PostalCodeRadius)));

Output of query.Explain() is: SELECT fl_result(key) FROM kv_default WHERE ((((fl_value(body, ‘Type’) = ‘Directory’ AND fl_value(body, ‘GroupGuid’) = ‘cb87110f-94e1-e511-80e5-002590701742’) AND fl_value(body, ‘CountryGuid’) = ‘2c48717e-f7e5-e511-80e5-002590701742’) AND fl_value(body, ‘BusinessTypeGuid’) = ‘5045717e-f7e5-e511-80e5-002590701742’) AND acos(((sin(radians(41.482343)) * sin(radians(fl_value(body, ‘Latitude’))) + cos(radians(41.482343))) * cos(radians(fl_value(body, ‘Latitude’)))) * cos(radians(-81.794562999999997) - radians(fl_value(body, ‘Longitude’)))) * 3955 <= 10) AND (flags & 1) = 0 0|0|0| SEARCH TABLE kv_default USING INDEX IX_Type_RowId (<expr>=?)

Expected behavior

This should result in a valid query.

Actual behavior

Exception thrown

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
blimkemanncommented, May 1, 2019

Thanks @Sandychuang8 that works perfectly!

0reactions
Sandychuang8commented, May 1, 2019

Hi @blimkemann, Try this one. I modified your expression a bit to get it to work.

var formula = Function.Acos(Function.Sin(Function.Radians(srcLat)) .Multiply(Function.Sin(Function.Radians(Expression.Property(Latitude)))) .Add(Function.Cos(Function.Radians(srcLat)).Multiply(Function.Cos(Function.Radians(Expression.Property(Latitude)))) .Multiply(Function.Cos(Function.Radians(srcLong).Subtract(Function.Radians(Expression.Property(Longitude))))))) .Multiply(Expression.Double(3955));

You will need to move Multiple into Add() otherwise you will add first then multiply…

Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Error "invalid numeric value for data type ...
I got the error solved. The error was that, the numbers had a space at the end and was not matching the data...
Read more >
Changing invalid numeric fields in your data
To change an invalid numeric field in your data (all asterisks shown in the field display) to a specified numeric value, you can...
Read more >
How to fix Invalid numeric data - SAS Communities
Dear Community ,. I'm working on the data to report the category of numeric variable( Weight ). my dataset looks like below: ID...
Read more >
"Error: Invalid Numerical Value" during loader job run in ILM ...
This case usually arises due to the presence of datatype mapping, which maps columns to integer (or DECIMAL) which has non numeric values....
Read more >
Reconciler error failed to parse invalid numeric value '' #3962
Describe the bug hi everyone. i have using fluxcd for gitops. i using Image Update Automations for auto update image. i have issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found