java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum

JIRA | Anqi Fu | 1 year ago
  1. 0

    I try to run the following code for Chicago crimes demo and get a class cast exception in Rapids, cannot cast ValStr to ValNum. It occurs even if I comment out the WeekDay and Season column creation lines. The error comes up when the Python script hits crimes.describe(). What's worse is that after the error, I cannot even re-import the crimes data; I get a parse AIOOBE and have to restart my iPython notebook. crimes_path = h2o.locate("smalldata/chicago/chicagoCrimes10k.csv.zip") crimes = h2o.import_frame(path=crimes_path) crimes.describe() def refine_date_col(data, col, pattern): data[col] = data[col].as_date(pattern) data["Day"] = data[col].day() data["Month"] = data[col].month() + 1 # Since H2O indexes from 0 data["Year"] = data[col].year() + 1900 # Start of epoch is 1900 data["WeekNum"] = data[col].week() data["WeekDay"] = data[col].dayOfWeek() data["HourOfDay"] = data[col].hour() # Create weekend and season cols # Spring = Mar, Apr, May. Summer = Jun, Jul, Aug. Autumn = Sep, Oct. Winter = Nov, Dec, Jan, Feb. # data["Weekend"] = [1 if x in ("Sun", "Sat") else 0 for x in data["WeekDay"]] data["Weekend"] = h2o.ifelse(data["WeekDay"] == "Sun" or data["WeekDay"] == "Sat", 1, 0)[0] data["Season"] = data["Month"].cut([0, 2, 5, 7, 10, 12], ["Winter", "Spring", "Summer", "Autumn", "Winter"]) refine_date_col(crimes, "Date", "%m/%d/%Y %I:%M:%S %p") crimes = crimes.drop("Date") crimes.describe() java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum 06-15 13:56:53.300 172.16.2.16:54321 1974 # Session INFO: Method: POST , URI: /99/Rapids, route: /99/Rapids, parms: {ast=(= !py73f15b62-101e-4936-9401-a2ff66a8192d (+ (year '$04ff17000000ffffffff$nfs://Users/anqi_fu/Documents/workspace/h2o-3/smalldata/chicago/chicagoCrimes10k.csv.zip' ) #1900 ))} at water.rapids.Env.peekDbl(Env.java:194) 06-15 13:56:53.303 172.16.2.16:54321 1974 # Session ERRR: java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum at water.rapids.ASTTimeOp.apply(ASTOp.java:1062) 06-15 13:56:53.304 172.16.2.16:54321 1974 # Session WARN: Caught exception: water.rapids.ValStr cannot be cast to water.rapids.ValNum; Stacktrace: [water.api.RapidsHandler.exec(RapidsHandler.java:132), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:606), water.api.Handler.handle(Handler.java:56), water.api.RequestServer.handle(RequestServer.java:677), water.api.RequestServer.serve(RequestServer.java:614), water.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:438), java.lang.Thread.run(Thread.java:745)] at water.rapids.AST.treeWalk(AST.java:49) at water.rapids.AST.treeWalk(AST.java:43) at water.rapids.AST.treeWalk(AST.java:83) at water.rapids.Exec.exec(Exec.java:68) at water.api.RapidsHandler.exec(RapidsHandler.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at water.api.Handler.handle(Handler.java:56) at water.api.RequestServer.handle(RequestServer.java:677) at water.api.RequestServer.serve(RequestServer.java:614) at water.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:438) at java.lang.Thread.run(Thread.java:745)

    JIRA | 1 year ago | Anqi Fu
    java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum
  2. 0

    I try to run the following code for Chicago crimes demo and get a class cast exception in Rapids, cannot cast ValStr to ValNum. It occurs even if I comment out the WeekDay and Season column creation lines. The error comes up when the Python script hits crimes.describe(). What's worse is that after the error, I cannot even re-import the crimes data; I get a parse AIOOBE and have to restart my iPython notebook. crimes_path = h2o.locate("smalldata/chicago/chicagoCrimes10k.csv.zip") crimes = h2o.import_frame(path=crimes_path) crimes.describe() def refine_date_col(data, col, pattern): data[col] = data[col].as_date(pattern) data["Day"] = data[col].day() data["Month"] = data[col].month() + 1 # Since H2O indexes from 0 data["Year"] = data[col].year() + 1900 # Start of epoch is 1900 data["WeekNum"] = data[col].week() data["WeekDay"] = data[col].dayOfWeek() data["HourOfDay"] = data[col].hour() # Create weekend and season cols # Spring = Mar, Apr, May. Summer = Jun, Jul, Aug. Autumn = Sep, Oct. Winter = Nov, Dec, Jan, Feb. # data["Weekend"] = [1 if x in ("Sun", "Sat") else 0 for x in data["WeekDay"]] data["Weekend"] = h2o.ifelse(data["WeekDay"] == "Sun" or data["WeekDay"] == "Sat", 1, 0)[0] data["Season"] = data["Month"].cut([0, 2, 5, 7, 10, 12], ["Winter", "Spring", "Summer", "Autumn", "Winter"]) refine_date_col(crimes, "Date", "%m/%d/%Y %I:%M:%S %p") crimes = crimes.drop("Date") crimes.describe() java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum 06-15 13:56:53.300 172.16.2.16:54321 1974 # Session INFO: Method: POST , URI: /99/Rapids, route: /99/Rapids, parms: {ast=(= !py73f15b62-101e-4936-9401-a2ff66a8192d (+ (year '$04ff17000000ffffffff$nfs://Users/anqi_fu/Documents/workspace/h2o-3/smalldata/chicago/chicagoCrimes10k.csv.zip' ) #1900 ))} at water.rapids.Env.peekDbl(Env.java:194) 06-15 13:56:53.303 172.16.2.16:54321 1974 # Session ERRR: java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum at water.rapids.ASTTimeOp.apply(ASTOp.java:1062) 06-15 13:56:53.304 172.16.2.16:54321 1974 # Session WARN: Caught exception: water.rapids.ValStr cannot be cast to water.rapids.ValNum; Stacktrace: [water.api.RapidsHandler.exec(RapidsHandler.java:132), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:606), water.api.Handler.handle(Handler.java:56), water.api.RequestServer.handle(RequestServer.java:677), water.api.RequestServer.serve(RequestServer.java:614), water.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:438), java.lang.Thread.run(Thread.java:745)] at water.rapids.AST.treeWalk(AST.java:49) at water.rapids.AST.treeWalk(AST.java:43) at water.rapids.AST.treeWalk(AST.java:83) at water.rapids.Exec.exec(Exec.java:68) at water.api.RapidsHandler.exec(RapidsHandler.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at water.api.Handler.handle(Handler.java:56) at water.api.RequestServer.handle(RequestServer.java:677) at water.api.RequestServer.serve(RequestServer.java:614) at water.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:438) at java.lang.Thread.run(Thread.java:745)

    JIRA | 1 year ago | Anqi Fu
    java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    I think the output of mean should be able to go into a key (cA_35) regardless of what's there already...I shouldn't have to do anything special for mean..i.e. it should act like sum and be able to go into any key.. here you can see I'm just putting mean into a key ca_35 didn't exist already.. I grep to show that kevin@Kevin-Ubuntu3:~/h2o-dev/py2/testdir_single_jvm/sandbox$ grep cA_35 * commands.log:2014-12-06 23:26:28.260990 -- Start http://192.168.0.34:54321/Rapids.json # {'funs': None, 'ast': '(= !cA_35 (mean ([ $cA_2 #0 #0) #0 $FALSE))'}; local-h2o-0.stdout.F5m68S.log:12-06 23:26:28.262 192.168.0.34:54321 1482 # Session INFO: Path: /2/Rapids, route: ^(/v?\d+)?/Rapids, parms: {ast=(= !cA_35 (mean ([ $cA_2 #0 #0) #0 $FALSE))} here's the error in stdout 12-06 23:26:28.262 192.168.0.34:54321 1482 # Session INFO: Path: /2/Rapids, route: ^(/v?\d+)?/Rapids, parms: {ast=(= !cA_35 (mean ([ $cA_2 #0 #0) #0 $FALSE))} 12-06 23:26:28.264 192.168.0.34:54321 1482 # Session ERRR: java.lang.ClassCastException: water.rapids.ValNum cannot be cast to water.rapids.ValFrame in stderr java.lang.ClassCastException: water.rapids.ValNum cannot be cast to water.rapids.ValFrame at water.rapids.Env.pop0Ary(Env.java:144) at water.rapids.ASTNcol.apply(ASTOp.java:474) at water.rapids.AST.treeWalk(AST.java:41) at water.rapids.AST.treeWalk(AST.java:65) at water.rapids.Exec.exec(Exec.java:74) at water.api.RapidsHandler.exec(RapidsHandler.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at water.api.Handler.handle(Handler.java:55) at water.api.RequestServer.handle(RequestServer.java:479) at water.api.RequestServer.serve(RequestServer.java:457) at water.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:432) at java.lang.Thread.run(Thread.java:745)

    JIRA | 2 years ago | Kevin Normoyle
    java.lang.ClassCastException: water.rapids.ValNum cannot be cast to water.rapids.ValFrame

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      water.rapids.ValStr cannot be cast to water.rapids.ValNum

      at water.rapids.ASTTimeOp.apply()
    2. water.rapids
      ASTTimeOp.apply
      1. water.rapids.ASTTimeOp.apply(ASTOp.java:1062)
      1 frame