<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Cassandra+Translator">Cassandra Translator</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~shawkins">Steven Hawkins</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >  * Create a VDB and deploy into Teiid Server and use either jdbc, odbc, odata etc to query. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{note} <br>Cassandra updates always return an update count of 1 per update regardless of the number of rows affected. <br>{note} <br> <br>{note} <br>Cassandra inserts are functionally upserts, that is if a given row exists it will be updated rather than causing an exception. <br>{note} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. *JCA Resource Adapter* <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="CassandraTranslator-CassandraTranslator"></a><b>Cassandra Translator</b></h1>

<p>The Cassandra Translator, known by the type name&nbsp;<em>cassandra</em>, exposes querying functionality to <a href="/author/display/TEIID/Cassandra+Data+Sources" title="Cassandra Data Sources">Cassandra Data Sources</a>.  The translator translates Teiid push down commands into <a href="http://cassandra.apache.org/doc/cql/CQL.html" class="external-link" rel="nofollow">Cassandra CQL</a>.</p>

<p><b>Properties</b></p>

<p>The Cassandra Translator currently has no import or execution properties.</p>

<h3><a name="CassandraTranslator-Usage"></a><b>Usage</b></h3>

<p>The Cassandra Translator supports INSERT/UPDATE/DELETE/SELECT statements with a restrictive set of capabilities including: count&#40;&#42;&#41;, comparison predicates, IN predicates, and LIMIT.  Only indexed columns are searchable.  Consider a custom extension or create an enhancement request should your usage require additional capabilities.</p>

<p>If you are using Designer Tooling, to create VDB then:</p>
<ul>
        <li>Create/use a Teiid Designer Model project</li>
        <li>Use "Teiid Connection &gt;&gt; Source Model" importer, create a new JBoss Data Source connection profile, specifying the JNDI name for resource adapter configured <a href="/author/display/TEIID/Cassandra+Data+Sources" title="Cassandra Data Sources">data source</a> and use <em>cassandra</em> as translator type. The source model will be created when you finish with this importer.</li>
        <li>Create a VDB and deploy into Teiid Server and use either jdbc, odbc, odata etc to query.</li>
</ul>


<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Cassandra updates always return an update count of 1 per update regardless of the number of rows affected.</td></tr></table></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Cassandra inserts are functionally upserts, that is if a given row exists it will be updated rather than causing an exception.</td></tr></table></div>

<h3><a name="CassandraTranslator-JCAResourceAdapter"></a><b>JCA Resource Adapter</b></h3>

<p>The Teiid specific Cassandra Resource Adapter should be used with this translator.  See <a href="/author/display/TEIID/Cassandra+Data+Sources" title="Cassandra Data Sources">Cassandra Data Sources</a> for connecting to a Cassandra cluster.</p>

<h3><a name="CassandraTranslator-NativeQueries"></a>Native Queries</h3>

<p>Cassandra source procedures may be created using the teiid_rel:native-query extension - see&nbsp;<a href="/author/display/TEIID/Translators#Translators-native">Parameterizable Native Queries</a>. The procedure will invoke the native-query similar to a direct procedure call with the benefits that the query is predetermined and that result column types are known, rather than requiring the use of ARRAYTABLE or similar functionality.</p>

<h4><a name="CassandraTranslator-DirectQueryProcedure"></a><b>Direct Query Procedure</b></h4>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, <a href="/author/display/TEIID/Translators#Translators-OverrideExecutionProperties">override the execution property</a> called <em>SupportsDirectQueryProcedure</em> to true.</td></tr></table></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>By default the name of the procedure that executes the queries directly is called <b>native</b>.  <a href="/author/display/TEIID/Translators#Translators-OverrideExecutionProperties">Override the execution property</a> <em>DirectQueryProcedureName</em> to change it to another name.</td></tr></table></div>

<p>The Cassandra translator provides a procedure to execute any ad-hoc CQL query directly against the source without Teiid parsing or resolving. Since the metadata of this procedure's results are not known to Teiid, they are returned as an object array. <a href="/author/display/TEIID/ARRAYTABLE" title="ARRAYTABLE">ARRAYTABLE</a> can be used construct tabular output for consumption by client applications.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Example CQL Direct Query</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">SELECT X.* 
  FROM cassandra_source.native('SELECT firstname, lastname FROM users WHERE birth_year = $1 AND country = $2 ALLOW FILTERING', 1981, 'US') n, 
       ARRAYTABLE(n.tuple COLUMNS firstname string, lastname string) AS X</pre>
</div></div>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/Cassandra+Translator">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=74285389&revisedVersion=10&originalVersion=9">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Cassandra+Translator?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>