[ 
https://issues.apache.org/jira/browse/CASSANDRA-12606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15515730#comment-15515730
 ] 

Sylvain Lebresne commented on CASSANDRA-12606:
----------------------------------------------

bq. I'm wondering if textAsBlob is useful in this case. You could just pass 
bound values as buffers using ByteBuffer, for example with 
ByteBufferUtil.bytes().

To be fair though, you can always avoid the use of any CQL functions 
(aggregates aside at least) right now by doing the computation client side 
(which is the equivalent of what you suggest), so it's not true more or less 
useful that in other places.

And at least theoretically, we could support *native* functions without 
requiring daemon initialization (not saying it's easy to do with the current 
code, I haven't checked at all, but it ought to be possible). However, it's 
definitively true that we can't support user-defined ones since the definition 
of those is in a schema table which is a no-go for CQLSSTableWriter.

Overall, we have no choice but to call the lack of UDF in CQLSSTableWriter a 
known design limitation, but we should at the very least document it clearly in 
the javadoc. For native functions, it's worth checking what exactly block us 
for supporting them to see if it couldn't be fixed easily, but if it's too 
involved to fix, I'm fine reporting their support in the short term, but we 
also have to document it.

tl;dr, there is at a minimum some javadoc additions to be done on that ticket 
before closing it.

> CQLSSTableWriter unable to use blob conversion functions
> --------------------------------------------------------
>
>                 Key: CASSANDRA-12606
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12606
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL, Tools
>            Reporter: Mark Reddy
>            Priority: Minor
>
> Attempting to use blob conversion functions e.g. textAsBlob, from 3.0 - 3.7 
> results in:
> {noformat}
> Exception in thread "main" 
> org.apache.cassandra.exceptions.InvalidRequestException: Unknown function 
> textasblob called
>       at 
> org.apache.cassandra.cql3.functions.FunctionCall$Raw.prepare(FunctionCall.java:136)
>       at 
> org.apache.cassandra.cql3.Operation$SetValue.prepare(Operation.java:163)
>       at 
> org.apache.cassandra.cql3.statements.UpdateStatement$ParsedInsert.prepareInternal(UpdateStatement.java:173)
>       at 
> org.apache.cassandra.cql3.statements.ModificationStatement$Parsed.prepare(ModificationStatement.java:785)
>       at 
> org.apache.cassandra.cql3.statements.ModificationStatement$Parsed.prepare(ModificationStatement.java:771)
>       at 
> org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.prepareInsert(CQLSSTableWriter.java:567)
>       at 
> org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.build(CQLSSTableWriter.java:510)
> {noformat}
> The following snippet will reproduce the issue
> {code}
> String table = String.format("%s.%s", "test_ks", "test_table");
> String schema = String.format("CREATE TABLE %s (test_text text, test_blob 
> blob, PRIMARY KEY(test_text));", table);
> String insertStatement = String.format("INSERT INTO %s (test_text, test_blob) 
> VALUES (?, textAsBlob(?))", table);
> File tempDir = Files.createTempDirectory("tempDir").toFile();
> CQLSSTableWriter sstableWriter = CQLSSTableWriter.builder()
>         .forTable(schema)
>         .using(insertStatement)
>         .inDirectory(tempDir)
>         .build();
> {code}
> This is caused in FunctionResolver.get(...) when 
> candidates.addAll(Schema.instance.getFunctions(name.asNativeFunction())); is 
> called, as there is no system keyspace initialised.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to