Fork me on GitHub
#datalevin
<
2022-04-17
>
vlad_poh02:04:20

I'm trying to go through the exercises on http://www.learndatalogtoday.org/chapter/5 Using the babashka datalevin pod When i try the following

(def q19 '[:find ?actor
             :where
             [?dg :person/name "Danny Glover"]
             [?dg :person/born ?d1]
             [?e :movie/cast ?a]
             [?a :person/name ?actor]
             [?a :person/born ?d2]
             [(!= ?dg ?a)]
             [(> ?d1 ?d2)]])

(d/q q19 db)
I get the following error
#error {
 :cause "java.util.Date cannot be cast to java.lang.Number"
 :data {:type "class java.lang.ClassCastException"}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "java.util.Date cannot be cast to java.lang.Number"
   :data {:type "class java.lang.ClassCastException"}
   :at [babashka.pods.impl$processor invokeStatic "impl.clj" 201]}]
 :trace
 [[babashka.pods.impl$processor invokeStatic "impl.clj" 201]
  [babashka.pods.sci$load_pod$fn__30764 invoke "sci.clj" 72]
  [sci.impl.vars$binding_conveyor_fn$fn__398 invoke "vars.cljc" 154]
  [clojure.core$binding_conveyor_fn$fn__5788 invoke "core.clj" 2035]
  [clojure.lang.AFn call "AFn.java" 18]
  [java.util.concurrent.FutureTask run "FutureTask.java" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
  [java.lang.Thread run "Thread.java" 829]
  [com.oracle.svm.core.thread.JavaThreads threadStartRoutine "JavaThreads.java" 596]
  [com.oracle.svm.core.posix.thread.PosixJavaThreads pthreadStartRoutine "PosixJavaThreads.java" 192]]}
Is this a babashka error or datalevin error? The query works on learndatalogtoday

Huahai02:04:48

Dates are not numbers, so you cannot compare them like that. Use .before or .after interop

vlad_poh02:04:46

That worked! I tried ( < (.getDate ?d1) (.getDate ?d2)) but that didn't work.

Huahai03:04:05

.getDate returns day of the month, it is not what you want.

👍 1