Stack Overflow Asked on December 9, 2021
When i try to compile, it says: Ambiguous method overloading for method overloading for methode java.math.BigDecimal#
and it also says:
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:…
def sql = ("Select d.*
from (select d.*,
lead( (case when length <> 'N/A' then length else length_to_fault end)::float) over (partition by port_nbr, pair order by port, pair, d.add_date) as lengthh
from diags d
) d")
def lastRow = [id:-1, port_nbr:-1, pair:'', lengthh:-1.0]
dst_db1.eachRow( sql ) { row ->
if ( row.port_nbr == lastRow.port_nbr && row.pair == lastRow.pair ) {
BigDecimal lengthChange =
new BigDecimal( row.lengthh ) - new BigDecimal( lastRow.lengthh )
if ( lengthChange > 30.0 ) {
print "Port ${row.port_nbr}, ${row.pair} length change: $lengthChange"
println "tbetween row ID ${lastRow.id} and ${row.id}"
}
lastRow = row
} else {
println "Key changed"
lastRow = row
}
}
can anyone try to fix this error?
EDIT- New full error:
Caught: java.lang.NumberFormatException: Character n is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
java.lang.NumberFormatException: Character n is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
at java.base/jdk.internal.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at Main$_main_closure1.doCall(main.groovy:18)
at jdk.internal.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at Main.main(main.groovy:14)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
It looks like your row.length
field is not of type String,as the code expects. You need to convert it to a String, or another type that the BigDecimal constructor can handle, e.g. like this:
BigDecimal lengthChange =
new BigDecimal( "${row.lengthh}" ) - new BigDecimal( "${lastRow.lengthh}" )
If it's still an issue then identify the problem type with:
println row.lengthh.class.name
Answered by Terry Ebdon on December 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP