Fork me on GitHub
Romit Gandhi07:01:09

Hello all, I'm using as Apache Cassandra client in Clojure I want to run copy command (copy data from csv to table) but I'm getting an error.

(alia/execute @session (str "COPY " table " FROM '" file-name "' WITH DELIMITER=',' AND HEADER=TRUE;"))
I'm doing this but I'm getting an error that query qxecution failed but if I run same command in cqlsh then it is working perfectly. I also checked if file is exist or not using this
(println (.exists ( file-name)))
And it returns true. Getting this error #error { :cause line 1:0 no viable alternative at input 'COPY' ([COPY]...) :via [{:type clojure.lang.ExceptionInfo :message Query execution failed :data {:type :qbits.alia/execute, :query [:simple  COPY cities FROM 'resources/temp/0284e950-d479-47ed-8282-168e1fce563d.csv' WITH DELIMITER=',' AND HEADER=TRUE;], :statement #object[com.datastax.oss.driver.internal.core.cql.DefaultSimpleStatement 0x5a5e3a04 com.datastax.oss.driver.internal.core.cql.DefaultSimpleStatement@9135c8ac], :values nil} :at [qbits.alia.error$ex__GT_ex_info invokeStatic error.clj 50]} {:type com.datastax.oss.driver.api.core.servererrors.SyntaxError :message line 1:0 no viable alternative at input 'COPY' ([COPY]...) :at [com.datastax.oss.driver.api.core.servererrors.SyntaxError copy 48]}] :trace [[com.datastax.oss.driver.api.core.servererrors.SyntaxError copy 48] [com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures getUninterruptibly 149] [com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor process 53] [com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor process 30] [com.datastax.oss.driver.internal.core.session.DefaultSession execute 230] [com.datastax.oss.driver.api.core.cql.SyncCqlSession execute 54] [qbits.alia$execute invokeStatic alia.clj 324] [qbits.alia$execute invoke alia.clj 251] [qbits.alia$execute invokeStatic alia.clj 332] [qbits.alia$execute invoke alia.clj 251] [back_end.db.core$bulk_insert_using_csv invokeStatic core.clj 22] [back_end.db.core$bulk_insert_using_csv invoke core.clj 18] [back_end.db.cassandra$insert_bulk_data_using_csv invokeStatic cassandra.clj 6] [back_end.db.cassandra$insert_bulk_data_using_csv invoke cassandra.clj 4] [back_end.handlers.cassandra$upload_csv_file invokeStatic cassandra.clj 36] [back_end.handlers.cassandra$upload_csv_file invoke cassandra.clj 27] [reitit.ring.middleware.multipart$compile$fn__12725$fn__12727$fn__12728 invoke multipart.clj 46] [muuntaja.middleware$wrap_format_request$fn__12621 invoke middleware.clj 114] [reitit.ring.coercion$fn__9455$fn__9457$fn__9458 invoke coercion.cljc 80] [muuntaja.middleware$wrap_format_response$fn__12625 invoke middleware.clj 132] [muuntaja.middleware$wrap_format_negotiate$fn__12618 invoke middleware.clj 96] [ring.middleware.params$wrap_params$fn__6862 invoke params.clj 67] [reitit.ring$ring_handler$fn__9120 invoke ring.cljc 329] [clojure.lang.AFn applyToHelper 154] [clojure.lang.AFn applyTo 144] [clojure.lang.AFunction$1 doInvoke 31] [clojure.lang.RestFn invoke 408] [clojure.lang.Var invoke 384] [ring.middleware.reload$wrap_reload$fn__5380 invoke reload.clj 39] [selmer.middleware$wrap_error_page$fn__5395 invoke middleware.clj 18] [prone.middleware$wrap_exceptions$fn__5637 invoke middleware.clj 169] [ring.middleware.flash$wrap_flash$fn__5680 invoke flash.clj 39] [ring.adapter.undertow.middleware.session$wrap_undertow_session$fn__6238 invoke session.clj 77] [ring.middleware.keyword_params$wrap_keyword_params$fn__6482 invoke keyword_params.clj 53] [ring.middleware.nested_params$wrap_nested_params$fn__6540 invoke nested_params.clj 89] [ring.middleware.multipart_params$wrap_multipart_params$fn__6838 invoke multipart_params.clj 171] [ring.middleware.params$wrap_params$fn__6862 invoke params.clj 67] [ring.middleware.cookies$wrap_cookies$fn__6011 invoke cookies.clj 214] [ring.middleware.absolute_redirects$wrap_absolute_redirects$fn__7050 invoke absolute_redirects.clj 47] [ring.middleware.resource$wrap_resource_prefer_resources$fn__6898 invoke resource.clj 25] [ring.middleware.content_type$wrap_content_type$fn__6998 invoke content_type.clj 34] [ring.middleware.default_charset$wrap_default_charset$fn__7022 invoke default_charset.clj 31] [ring.middleware.not_modified$wrap_not_modified$fn__6964 invoke not_modified.clj 61] [ring.middleware.x_headers$wrap_x_header$fn__6422 invoke x_headers.clj 22] [ring.middleware.x_headers$wrap_x_header$fn__6422 invoke x_headers.clj 22] [ring.middleware.x_headers$wrap_x_header$fn__6422 invoke x_headers.clj 22] [ring.adapter.undertow$undertow_handler$fn$reify__17593 handleRequest undertow.clj 40] [io.undertow.server.session.SessionAttachmentHandler handleRequest 68] [io.undertow.server.Connectors executeRootHandler 387] [io.undertow.server.HttpServerExchange$1 run 852] [org.jboss.threads.ContextClassLoaderSavingRunnable run 35] [org.jboss.threads.EnhancedQueueExecutor safeRun 2019] [org.jboss.threads.EnhancedQueueExecutor$ThreadBody doRunTask 1558] [org.jboss.threads.EnhancedQueueExecutor$ThreadBody run 1449] [org.xnio.XnioWorker$WorkerThreadFactory$1$1 run 1280] [java.lang.Thread run 829]]} So, please can anyone help me regarding this?


I unfortunately know nothing about this but the first thing you should add is the error details like a stacktrace 🙂.

Romit Gandhi09:01:38

I have edited the message and pasted the stack trace

Antonio Bibiano12:01:19

Could be that this COPY command is specific to the util you used to test it? I remember that something similar used to happen with psql and postgresql

Antonio Bibiano12:01:31

Where you had this command to read a local csv and dump it into a table but you could not run a query to do the same thing using a driver

Antonio Bibiano12:01:53

looking at the docs that seems to be the case COPY only appears under cqlsh commands

Daniel Craig16:01:09

you might need to escape the single quotes that are part of your query


I think you might run into CQL injection if you write CQL like that

Romit Gandhi04:01:19

No there will not be cql injection as this is internal code and user will only able to upload CSV file and I'm not using same file name. I'm generating Uuid and save file as that name.


Hello all, am using to query from a postgres db. When I fetch a record from a table, in the result set, column name is represented as :table_name/column_name. Is there a way to get them as :column_name ?


Thank you. I added a map with :builder-fn and it works as I wanted.


No problemo, you're most welcome 🙂


while you are making that choice, try to think about if it makes sense to use the namespaced keys. I personally find them pretty powerful

INNER JOIN b ON b.a_id =


this would come out as {:a/name … :b/name …}


@U3JH98J4R This would have been my follow up question 🙂 Am used to working with namespace/keys and was wondering what are the benefits, or is it only a preference. The example you mentioned, with the join, I normally give a name to the tables in such cases and then I have something to identify the columns from each joined tables. So I do not find that example as an advantage for me 🙂 But are there any other benefits to use namespace/keys ?


Yes, for example, the immediate benefit is if one has joins with similar column names in tables


with namespaced keys, each key will be unique, i.e., :foo/id :bar/id


That by itself, pays off so so much.


I would suggest having a look here:


and a few paragraphs down, i.e.,


The unqualified options may be slightly faster than their qualified equivalents but make no attempt to keep column names unique if your SQL joins across multiple tables.


I understand that you may alias each returned column, to keep the names unique, but that feels like more effort to maintain consistency.


Thanks again for the explanations @U11EL3P9U


There's also #sql that is there for other sql related matters 🙂

👍 1

I’m trying to start my server from the repl with (start) but getting:

user=> (start)
Execution error (ConnectException) at (
Connection refused (Connection refused)
What is happening?


The port is 3000, and according to lsof -i:3000 there’s nothing running there


I would look at the rest of the stacktrace


my guess is something like connecting to a database is failing


@hiredman There's no other stacktrace


what you shared is the print out of basically the start of a stacktrace


This is the whole stacktrace


the exception object that was thrown will have the rest of it


your repl may not show the whole thing when it catches an error


but in the repl the latest exception thrown will be bound to *e


so typing *e in the repl should cause the exception object, including the entire stacktrace, to be printed


user=> (/ 1 0)
Execution error (ArithmeticException) at user/eval1 (REPL:1).
Divide by zero
user=> *e
#error {
 :cause "Divide by zero"
 [{:type java.lang.ArithmeticException
   :message "Divide by zero"
   :at [clojure.lang.Numbers divide "" 188]}]
 [[clojure.lang.Numbers divide "" 188]
  [clojure.lang.Numbers divide "" 3901]
  [user$eval1 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval1 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "" 7181]
  [clojure.lang.Compiler eval "" 7136]
  [clojure.core$eval invokeStatic "core.clj" 3202]
  [clojure.core$eval invoke "core.clj" 3198]
  [clojure.main$repl$read_eval_print__9112$fn__9115 invoke "main.clj" 437]
  [clojure.main$repl$read_eval_print__9112 invoke "main.clj" 437]
  [clojure.main$repl$fn__9121 invoke "main.clj" 458]
  [clojure.main$repl invokeStatic "main.clj" 458]
  [clojure.main$repl_opt invokeStatic "main.clj" 522]
  [clojure.main$main invokeStatic "main.clj" 667]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn invoke "" 397]
  [clojure.lang.AFn applyToHelper "" 152]
  [clojure.lang.RestFn applyTo "" 132]
  [clojure.lang.Var applyTo "" 705]
  [clojure.main main "" 40]]}

Alex Miller (Clojure team)18:01:34

pst = print stack trace and is designed for the purpose of a person reading a stack trace (not printing a data object)

👁️ 2
Alex Miller (Clojure team)18:01:30

*e will also only include the root cause stack, whereas pst includes stack of all exceptions in the chain

😯 1

a clojure atom?


you're actually running into some undefined behavior here


starts-with? needs to be passed a String or CharSequence


you happen to be passing an atom, which is not any of those


and it happens to be giving you an answer, but the answer is garbage


which is sugar for (deref atom)


atoms are reftypes / boxes. deref gets what's in the box

Muhammad Hamza Chippa20:01:25

I am using js/Date. to generate date from the object but it is not generating the date object in the desired timezone I want to generate the date in EST timezone "1818-08-12T05:06:00Z". Is there any method to generate the date object in the desired timezone I did not find such thing in the documentation ?


You are seeing how inst tagged literals print, and they always print normalized it utc, regardless of the time zone of the object

Muhammad Hamza Chippa20:01:35

I want to reatin the time 5:06 in gmt+2 timezone is there any way to do it ?


The way the object is printed doesn't effect the object