Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Cassandra scripted data set Preview results does not show results
charansgt
<p>
Find more posts tagged with
Comments
JFreeman
<p>There is a chance the rows are being loaded with empty string values which would give the appearance of the rows missing.</p>
<p> </p>
<p>When you are adding the row in the fetch method of the data set, put a character like a pipe "|" before and after the value you are adding. Then you should be able to verify if it is adding an blank string or not displaying the values at all.</p>
charansgt
<blockquote class="ipsBlockquote" data-author="JFreeman" data-cid="137360" data-time="1435087323">
<div>
<p>There is a chance the rows are being loaded with empty string values which would give the appearance of the rows missing.</p>
<p> </p>
<p>When you are adding the row in the fetch method of the data set, put a character like a pipe "|" before and after the value you are adding. Then you should be able to verify if it is adding an blank string or not displaying the values at all.</p>
</div>
</blockquote>
<p>Hi Freeman,</p>
<p> </p>
<p>I've tried what you suggested. There's no change in Preview results. It's still showing up empty columns. Do i need to do any conversion stuff to view them? And is there any alternate way that i can connect to cassandra instance? Suggest me</p>
<p> </p>
<p>Thanks,</p>
<p>Charan</p>
Clement Wong
<p>Charan,</p>
<p> </p>
<p>What version of BIRT are you using?</p>
<p>Are you using a scripted data source?</p>
<p>What version of Cassandra do you have?</p>
<p> </p>
<p>As an alternative, have you tried using the <a data-ipb='nomediaparse' href='
https://code.google.com/a/apache-extras.org/p/cassandra-jdbc/'>Cassandra
JDBC</a>? It's much easier. I'm able to successfully connect and query using CQL against a Cassandra 2.07 VM. When using this JDBC, make sure you include all the <a data-ipb='nomediaparse' href='
https://drive.google.com/file/d/0B7fwX0DqcWSTb0NlOVFXOTJvcGc/view?usp=sharing'>dependencies
</a>too. All these files should be placed in your eclipse\plugins\org.eclipse.birt.report.data.oda.jdbc_x.y.z.v20xxx\drivers directory, and a restart of your Designer is needed.</p>
<p> </p>
<p>A sample Cassandra JDBC URL for org.apache.cassandra.cql.jdbc.CassandraDriver would be as follows:</p>
<pre class="_prettyXprint _lang-nocode">
jdbc:cassandra://CassandraVM:9160/demo
</pre>
charansgt
<p>Hi Wong,</p>
<p> </p>
<p>Thanks for the detailed reply. </p>
<p> </p>
<p>I am using birt 4.* with the scripted data source and using Datastax cassandra 2.1.5</p>
<p> </p>
<p>I connected using the jdbc as you mentioned and got it working with some driver changes.We are using UDT(user defined types) in our schema. Now the problem is with the user defined types. When i do select * or if i want to select a UDT, it throws a null pointer exception. It seems like it is not able to recognize and show it in the output columns. Can you please suggest so that i can move further.</p>
<p> </p>
<p>Thanks,</p>
<p>Charan</p>
Clement Wong
<p>If using that JDBC, then it appears with the SELECT *, the User Defined Types (UDTs), released in Cassandra 2.1, are not supported via that particular driver at this time (see <a data-ipb='nomediaparse' href='
https://code.google.com/a/apache-extras.org/p/cassandra-jdbc/issues/detail?id=98'>this
tracking issue</a>).</p>
<p> </p>
<p>However, you can address the UDT by it's qualified name. For example using <a data-ipb='nomediaparse' href='
http://docs.datastax.com/en/cql/3.1/cql/cql_using/cqlUseUDT.html'>DataStax's
example </a>(modified):</p>
<pre class="_prettyXprint">
CREATE TYPE mykeyspace.fullname (
firstname text,
lastname text
)
CREATE TABLE mykeyspace.users (
id uuid PRIMARY KEY,
name frozen <fullname>,
);
INSERT INTO mykeyspace.users (id, name) VALUES (62c36092-82a1-3a00-93d1-46196ee77204, {firstname: 'Marie-Claude', lastname: 'Josset'});</pre>
<p>With the JDBC, you can query with CQL using the UDT name.column name:</p>
<pre class="_prettyXprint">
SELECT id, name.firstname, name.lastname FROM mykeyspace.users
</pre>
<p>Also as alternative, it's quite possible to use a scripted data source, and use map the UDTs described <a data-ipb='nomediaparse' href='
http://docs.datastax.com/en/developer/java-driver/2.1/java-driver/reference/mappingUdts.html'>here</a>.</p>
;
charansgt
<p>Hi Wong,</p>
<p> </p>
<p>I see that there are no further updates on the driver. And i have a list of UDT's. </p>
<p> </p>
<p>Coming to the scripted data source, as i mentioned in the very first post in this topic, I am able to see the no of records in the result set, but not the results. Attached is the screenshot for your reference. No exceptions as per my observation in the logs. I tried converting the value from the rows to String etc. If this works, then i can go ahead.</p>
<p> </p>
<p>-charan</p>
Clement Wong
<p>Please attach your design corresponding from the first post for further analysis.</p>
<p> </p>
<p>Regards,</p>
<p>Clement</p>
charansgt
<p>Hi,</p>
<p> </p>
<p>Right now, am trying with the simple dataset, i.e, users tablw which consists of 4 fields like id, fname, lname and city. </p>
<p> </p>
<p>The script is as follows:</p>
<p> </p>
<p>Open:</p>
<pre class="_prettyXprint _lang-js">
importPackage(Packages.java.util);
importPackage(Packages.me.prettyprint.cassandra.serializers);
importPackage(Packages.me.prettyprint.cassandra.service);
importPackage(Packages.me.prettyprint.hector.api);
importPackage(Packages.me.prettyprint.hector.api.beans);
importPackage(Packages.me.prettyprint.hector.api.factory);
importPackage(Packages.me.prettyprint.hector.api.query);
importPackage(Packages.me.prettyprint.cassandra.model);
var cluster = HFactory.getOrCreateCluster("Test Cluster",new CassandraHostConfigurator("***********:9160"));
var keyspace = HFactory.createKeyspace("test_keyspace", cluster);
var cqlQuery = new CqlQuery(keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
cqlQuery.setQuery("select * from test_keyspace.users");
var resultCQL = cqlQuery.execute();
rowsIterator = resultCQL.get().iterator();
</pre>
<p>and fetch:</p>
<pre class="_prettyXprint _lang-js">
if (rowsIterator.hasNext()) {
var myrow = rowsIterator.next();
var cols = myrow.getColumnSlice().getColumns();
for( ii=0; ii < cols.size(); ii++ ){
row[cols.get(ii).getName()] = cols.get(ii).getValue();
}
return true;
}else{
return false;
}
</pre>
<p>I thought, the problem might be with the value conversion and changed it to the corresponding data type and checked it. Its still the same. it shows the same, i.e, the no.of records without the records. The supporting drivers which i am using are the latest.</p>
<p> </p>
<p>Let me know, if anymore information needed.</p>
<p> </p>
<p>-charan</p>
Clement Wong
<p>It appears that <a data-ipb='nomediaparse' href='
https://github.com/hector-client/hector'>Hector</a>
; does not support UDTs because UDTs were released with Cassandra 2.1, and Hector uses an older API (<a data-ipb='nomediaparse' href='
http://stackoverflow.com/questions/18598745/differences-betweeen-hector-cassandra-and-jdbc'>reference</a>).</p>
;
<p> </p>
<p>When using UDTs in Java, we'll need to use mapping per this <a data-ipb='nomediaparse' href='
http://docs.datastax.com/en/developer/java-driver/2.1/java-driver/reference/mappingUdts.html'>DataStax
article</a>.</p>