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

JIRA | Anqi Fu | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  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 | 2 years 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 | 2 years ago | Anqi Fu
    java.lang.ClassCastException: water.rapids.ValStr cannot be cast to water.rapids.ValNum

    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