Repository: zeppelin Updated Branches: refs/heads/master 19e8ed989 -> 68b9b00fc
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/cassandra/src/test/resources/scalate/Help.html ---------------------------------------------------------------------- diff --git a/cassandra/src/test/resources/scalate/Help.html b/cassandra/src/test/resources/scalate/Help.html index 1c82c66..d784fe3 100644 --- a/cassandra/src/test/resources/scalate/Help.html +++ b/cassandra/src/test/resources/scalate/Help.html @@ -1 +1 @@ -<br/><br/><nav class="navbar navbar-default"><ul class="nav navbar-nav"><li role="presentation" class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="text-info"><i class="glyphicon glyphicon-book"/> <strong>Please select ...</strong></span><span class="text-info caret"></span><ul class="dropdown-menu"><li class="dropdown-header"><span class="text-info">Topics</span></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Basic Commands</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Schema Discovery</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Query Parameters</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i clas s="glyphicon glyphicon-bookmark"/> Prepared Statements</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Dynamic Forms</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Interpreter Configuration</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Shared States</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Change Log</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Contacts & Bugs</span></a></li></ul></a></li><li><a><span class="text-info"><strong>CASSANDRA INTERPRETER DOCUMENTATION</strong></span></a></li></ul><ul class="nav navbar-nav na vbar-right"><li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="text-info"><strong>About ...</strong></span><span class="caret"></span></a><ul class="dropdown-menu"><li><a role="button"><span class="text-info">Version <strong>2.0</strong></span></a></li><li><a role="button"><span class="text-info">Java Driver Version <strong>3.0.0-rc1</strong></span></a></li><li><a role="button"><span class="text-info">Author <strong>@doanduyhai</strong></span></a></li></ul></li><li><a href="#"></a></li></nav><br/><br/><div class="container"><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Basic Commands</strong></span></a></h4></div><div class="panel-collapse collapse in" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><h3> I CQL Statements</h3><p>This interpreter is compatible with any CQL statement supported by Cassandra. Ex:<br/><br/><div class="row"><div class="col-md-6 col-md-offset-3"><pre>INSERT INTO users(login,name) VALUES('jdoe','John DOE');SELECT * FROM users WHERE login='jdoe';</pre></div></div><br/>Each statement should be separated by a <strong>semi-colon</strong> (;).<br/><strong>Multi-line</strong> statements as well as multiple statements on the <strong>same line</strong>are also supported as long as they are separated by a semi-colon. Ex:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>USE spark_demo;SELECT * FROM albums_by_country LIMIT 1; SELECT * FROM countries LIMIT 1;SELECT *FROM artistsWHERE login='jlennon';</pre></div></div><br/><strong>Batch</strong> statements are supported and can span multiple lines, as well as<strong>DDL</strong>(CREATE/ALTER/DROP) statements:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>BEGIN BATCHINSERT INTO u sers(login,name) VALUES('jdoe','John DOE');INSERT INTO users_preferences(login,account_type) VALUES('jdoe','BASIC');APPLY BATCH;CREATE TABLE IF NOT EXISTS test(key int PRIMARY KEY,value text);</pre></div></div><br/>CQL statements are <strong>case-insensitive</strong> (except for column names and values).This means that the following statements are equivalent and valid:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>INSERT INTO users(login,name) VALUES('jdoe','John DOE');Insert into users(login,name) vAlues('hsue','Helen SUE');</pre></div></div><br/>The complete list of all CQL statements and versions can be found below:<br/><br/><div class="row"><div class="col-md-6 col-md-offset-3"><table class="table table-bordered"><thead><tr><th>Cassandra version</th><th>Documentation</th></tr></thead><tbody><tr><td><strong>2.2</strong></td><td><a href="http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html" target="_blank">http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.ht ml</a></td></tr><tr><td><strong>2.1 & 2.0</strong></td><td><a href="http://docs.datastax.com/en/cql/3.1/cql/cql_intro_c.html" target="_blank">http://docs.datastax.com/en/cql/3.1/cql/cql_intro_c.html</a></td></tr><tr><td><strong>1.2</strong></td><td><a href="http://docs.datastax.com/en/cql/3.0/cql/aboutCQL.html" target="_blank">http://docs.datastax.com/en/cql/3.0/cql/aboutCQL.html</a></td></tr></tbody></table></div></div></p><h3>II Comments</h3><p>It is possible to add comments between statements. Single line comments start with the<strong>hash</strong> sign (#) or <strong>double slashes</strong> (//). Multi-line comments are enclosed between<strong>/**</strong> and <strong>**/</strong>. Ex:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>#Single line comment style 1INSERT INTO users(login,name) VALUES('jdoe','John DOE');//Single line comment style 2/**Multi linecomments**/Insert into users(login,name) vAlues('hsue','Helen SUE');</pre></di v></div><br/></p><h3>III Syntax Validation</h3><p>The interpreters is shipped with a <em>built-in syntax validator</em>. This validator onlychecks for <strong>basic syntax errors</strong>. All CQL-related syntax validation is delegateddirectly to <strong>Cassandra</strong><br/><br/>Most of the time, syntax errors are due to missing semi-colons between statements or typo errors.</p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Schema Discovery</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><h3>I Commands For Discovery</h3><p>To make schema discovery easier and more interactive, the following commands are supported:<br/><br/><table class="table table-bordered"><thead><tr><th>Command</th><th>Descrip tion</th></tr></thead><tbody><tr><td><strong>DESCRIBE CLUSTER;</strong></td><td>Show the current cluster name and its partitioner</td></tr><tr><td><strong>DESCRIBE KEYSPACES;</strong></td><td>List all existing keyspaces in the cluster and their configuration(replication factor, durable write ...)</td></tr><tr><td><strong>DESCRIBE TABLES;</strong></td><td>List all existing keyspaces in the cluster and for each, all the tables name</td></tr><tr><td><strong>DESCRIBE TYPES;</strong></td><td>List all existing keyspaces in the cluster and for each, all the types name</td></tr><tr><td><strong>DESCRIBE FUNCTIONS;</strong></td><td>List all existing keyspaces in the cluster and for each, all the functions name and arguments</td></tr><tr><td><strong>DESCRIBE AGGREGATES;</strong></td><td>List all existing keyspaces in the cluster and for each, all the aggregates name and arguments</td></tr><tr><td><strong>DESCRIBE MATERIALIZED VIEWS;</strong></td><td>List all existing keyspaces in the cluster a nd for each, all the materialized view name</td></tr><tr><td><strong>DESCRIBE KEYSPACE <keyspace name>;</strong></td><td>Describe the given keyspace configuration and all its table details (name, columns, ...)</td></tr><tr><td><strong>DESCRIBE TABLE <em>(<keyspace name>).</em><table name>;</strong></td><td>Describe the given table. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no table is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE TYPE <em>(<keyspace name>).</em><type name>;</strong></td><td>Describe the given type(UDT). If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no type is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE FUNCTION <em>(<keyspace name>).< /em><function name>;</strong></td><td>Describe the given function. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no function is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE AGGREGATE <em>(<keyspace name>).</em><aggregate name>;</strong></td><td>Describe the given aggregate. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no aggregate is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE MATERIALIZED VIEW <em>(<keyspace name>).</em><view name>;</strong></td><td>Describe the given materialized view. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no materialized view is found, an error message is raised</td></tr></tbody></table><br/><div class="alert alert-danger" role="alert">Please note that each <strong>DESCRIBE</strong> command should be ended by <strong>a semi-colon</strong>.</div></p><h3>II Schema Display</h3><p>The schema objects (cluster, keyspace, table, type, view, function & aggregate) are displayed in a tabular format. There is a <strong>drop-down</strong> menu on the top left corner to expand objects details. On the top right menu is shown the Icon legend.</p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Query Parameters</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><p>Sometimes you want to be able to pass runtime query pa rameters to your statements.Those parameters are <strong>not</strong> part of the CQL specs and are specific to the interpreter.Below is the list of all parameters:<br/><br/><table class="table table-bordered"><caption><h4>Query Parameters</h4></caption><thead><tr><th>Parameter</th><th>Syntax</th><th>Description</th></tr></thead><tbody><tr><td>Consistency Level</td><td><strong>@consistency=<em>value</em></strong></td><td>Apply the given consistency level to all queries in the paragraph</td></tr><tr><td>Serial Consistency Level</td><td><strong>@serialConsistency=<em>value</em></strong></td><td>Apply the given serial consistency level to all queries in the paragraph</td></tr><tr><td>Timestamp</td><td><strong>@timestamp=<em>long value</em></strong></td><td>Apply the given timestamp to all queries in the paragraph.<br/>Please note that timestamp value passed directly in CQL statement will override this value</td></tr><tr><td>Retry Policy</td><td><strong>@retryPolicy=<em>value</em></stro ng></td><td>Apply the given retry policy to all queries in the paragraph</td></tr><tr><td>Fetch Size</td><td><strong>@fetchSize=<em>int value</em></strong></td><td>Apply the given fetch size to all queries in the paragraph</td></tr></tbody></table><br/>Some parameters only accept restricted values:<br/><br/><table class="table table-bordered"><caption><h4>Allowed Values</h4></caption><thead><tr><th>Parameter</th><th>Possible Values</th></tr></thead><tbody><tr><td>Consistency Level</td><td><strong>ALL, ANY, ONE, TWO, THREE, QUORUM, LOCAL_ONE, LOCAL_QUORUM, EACH_QUORUM</strong></td></tr><tr><td>Serial Consistency Level</td><td><strong>SERIAL, LOCAL_SERIAL</strong></td></tr><tr><td>Timestamp</td><td>Any long value</td></tr><tr><td>Retry Policy</td><td><strong>DEFAULT, DOWNGRADING_CONSISTENCY, FALLTHROUGH, LOGGING_DEFAULT,LOGGING_DOWNGRADING, LOGGING_FALLTHROUGH</strong></td></tr><tr><td>Fetch Size</td><td>Any integer value</td></tr></tbody></table><br/><div class="alert alert-danger" r ole="alert">Please note that you <strong>should not add semi-colon (;)</strong> at the end of each parameter statement</div>Some example:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>CREATE TABLE IF NOT EXISTS spark_demo.ts(key int PRIMARY KEY,value text);TRUNCATE spark_demo.ts;# Timestamp in the past@timestamp=10# Force timestamp directly in the first insertINSERT INTO spark_demo.ts(key,value) VALUES(1,'first insert') USING TIMESTAMP 100;# Select some data to make the clock turnSELECT * FROM spark_demo.albums LIMIT 100;# Now insert using the timestamp parameter set at the beginning(10)INSERT INTO spark_demo.ts(key,value) VALUES(1,'second insert');# Check for the result. You should see 'first insert'SELECT value FROM spark_demo.ts WHERE key=1;</pre></div></div><br/>Some remarks about query parameters:<br/><br/><div class="alert alert-info" role="alert"><ul><li><strong>many</strong> query parameters can be set in the same paragraph</li><li>if the <strong>same< /strong> query parameter is set many time with different values,the interpreter only take into account the first value</li><li>each query parameter applies to <strong>all</strong> CQL statement in the same paragraph,unless you override the option using plain CQL text (like forcing timestamp with the USING clause)</li><li>the order of each query parameter with regard to CQL statement does not matter</li></ul></div></p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Prepared Statements</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><h3>I Syntax</h3><br/><p>For performance reason, it is better to <strong>prepare statements</strong> before-hand and reusethem later by providing bound values. This interp reter provides 3 commands to handle prepared andbound statements:<br/><br/><ol><li><strong>@prepare</strong></li><li><strong>@bind</strong></li><li><strong>@remove_prepared</strong></li></ol><br/>Example:<br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>@prepare[statement_name]=...@bind[statement_name]=âtextâ, 1223, â2015-07-30 12:00:01â, null, true, [âlist_item1â, âlist_item2â]@bind[statement_name_with_no_bound_value]@remove_prepare[statement_name]</pre></div></div><br/><h3>II @prepare</h3><br/><p>You can use the syntax "<strong>@prepare[statement_name]=SELECT ...</strong>" to create a prepared statement.The <em>statement_name</em> is mandatory because the interpreter prepares the given statement with theJava driver and saves the generated prepared statement in an internal map, using the provided<em>statement_name</em> as search key.<br/><br/><div class="alert alert-info">Please note that this internal prepared statement map is shared with <strong>al l notebooks</strong>and <strong>all paragraphs</strong> because there is only one instance of the interpreter for Cassandra</div><br/><div class="alert alert-warning">If the interpreter encounters many @prepare for the <strong>same statement_name</strong> (key),only the <strong>first</strong> statement will be taken into account.</div><br/>Example:<br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>@prepare[select]=SELECT * FROM spark_demo.albums LIMIT ?@prepare[select]=SELECT * FROM spark_demo.artists LIMIT ?</pre></div></div><br/>For the above example, the prepared statement is <strong>"SELECT * FROM spark_demo.albums LIMIT ?"</strong>.<em>"SELECT * FROM spark_demo.artists LIMIT ?"</em> is ignored because an entry already exists in theprepared statements map with the key <strong>select</strong>.<br/><br/>In the context of Zeppelin, a notebook can be scheduled to be executed at regular interval,thus it is necessary to avoid re-preparing many time the same statement (c onsidered an anti-pattern).</p><h3>III @bind</h3><br/><p>Once the statement is prepared (possibly in a separated notebook/paragraph). You can bind values to it:<br/><br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>@bind[select_first]=10</pre></div></div><br/>Bound values are not mandatory for the <strong>@bind</strong> statement.However if you provide bound values, they need to comply to some syntax:<ul><li>String values should be enclosed between simple quotes ( â )</li><li>Date values should be enclosed between simple quotes ( â ) and respect the formats:<ol><li>yyyy-MM-dd HH:MM:ss</li><li>yyyy-MM-dd HH:MM:ss.SSS</li></ol></li><li><strong>null</strong> is parsed as-is</li><li><strong>boolean</strong> (true|false) are parsed as-is </li><li>collection values must follow the<a href="http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_collections_c.html" target="_blank">standard CQL syntax</a>:<ul><li>list: [âlist_item1â, âlist_item2â, ...]</li><li>set: {âset_item1â, âset_item2â, â¦}</li><li>map: {âkey1â: âval1â, âkey2â: âval2â, â¦}</li></ul></li><li>tuple values should be enclosed between parenthesis(see <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_reference/tupleType.html" target="_blank">tuple CQL syntax</a>):(âtextâ, 123, true)</li><li>udt values should be enclosed between brackets(see <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_using/cqlUseUDT.html" target="_blank">udt CQL syntax</a>):{stree_name: âBeverly Hillsâ, number: 104, zip_code: 90020, state: âCaliforniaâ, â¦}</li></ul><br/><div class="alert alert-info">It is possible to use the <strong>@bind</strong> statement inside a batch: <br/><pre>BEGIN BATCH@bind[insert_user]='jdoe','John DOE'UPDATE users SET age = 27 WHERE login='hsue';APPLY BATCH;</pre></div><br/></p><h3>IV @remove_prepare</h3><br/><p>To avoid for a prepared statement to stay forever in the prepared statement map, you can use the <strong>@remove_prepare [statement_name]</strong> syntaxto remove it. Removing a non-existing prepared statement yields no error.</p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Dynamic Forms</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><p>Instead of hard-coding your CQL queries, it is possible to use the mustache syntax (<strong>{{ }}</strong>)to inject simple value or multiple choices forms.<br/><br/>The syntax for simple parameter is: <strong>{{input_Label=default value}}</strong>.The default value is mandatory because the first time the paragraph is executed,we launch the CQL query before rendering the form so at least one value should be provided.<br/><br/>The syntax for multiple choices parameter is: <strong>{{ input_Label=value1 | value2 | ⦠| valueN }}</strong>.By default the first choice is used for CQL query the first time the paragraph is executed.<br/><br/>Example:<br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>#Secondary index on performer styleSELECT name, country, performerFROM spark_demo.performersWHERE name='{{performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}}'AND styles CONTAINS '{{style=Rock}}';</pre></div></div><br/>In the above example, the first CQL query will be executed for <em>performer='Sheryl Crow'</em>AND <em>style='Rock'</em>. For subsequent queries, you can change the value directly using the form.Please note that we enclosed the {{ }} block between simple quotes (') because Cassandra expects a String here.We could have also use the <strong>{{style='Rock'}}</strong> syntax but this time, the valuedisplayed on the form is <em>'Rock'</em> and not <em>Rock</em>.<br/><br/><div class="alert alert-info">It is also possible to use dynamic forms for <str ong>prepared statements</strong>: <br/><strong>@bind[select]=='{{performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}}', '{{style=Rock}}'</strong></div></pre></p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Interpreter Configuration</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body">The <strong>Cassandra</strong> interpreter comes with some some configuration values for the Java driver:<table class="table table-bordered"><caption><h4>Interpreter Configuration</h4></caption><thead><tr><th>Parameter</th><th>Default Value</th></tr></thead><tbody><tr><td>cassandra.cluster</td><td><strong>Test Cluster</strong></td></tr><tr><td>cassandra.compression.protocol</td><td><strong>NONE</strong>, possible values: LZ4, SNAPPY</td></tr><tr><td>cassandra.credentials.password </td><td><strong>none</strong></td></tr><tr><td>cassandra.credentials.username</td><td><strong>none</strong></td></tr><tr><td>cassandra.hosts</td><td><strong>localhost</strong></td></tr><tr><td>cassandra.interpreter.parallelism</td><td><strong>10</strong></td></tr><tr><td>cassandra.keyspace</td><td><strong>system</strong></td></tr><tr><td>cassandra.load.balancing.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr><tr><td>cassandra.max.schema.agreement.wait.second</td><td><strong>10</strong></td></tr><tr><td>cassandra.native.port</td><td><strong>9042</strong></td></tr><tr><td>cassandra.pooling.core.connection.per.host.local</td><td><strong>Protocol V2 and below: 2, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.core.connection.per.host.remote</td><td><strong>Protocol V2 and below: 1, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.heartbeat.interval.seconds</td><td><strong>30</strong></td></tr><tr><td>cassandra.pooling.idle.timeout. seconds</td><td><strong>Test Cluster</strong></td></tr><tr><td>cassandra.pooling.max.connection.per.host.local</td><td><strong>Protocol V2 and below: 8, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.max.connection.per.host.remote</td><td><strong>Protocol V2 and below: 2, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.max.request.per.connection.local</td><td><strong>Protocol V2 and below: 128, V3 and above: 1024</strong></td></tr><tr><td>cassandra.pooling.max.request.per.connection.remote</td><td><strong>Protocol V2 and below: 128, V3 and above: 256</strong></td></tr><tr><td>cassandra.pooling.new.connection.threshold.local</td><td><strong>Protocol V2 and below: 100, V3 and above: 800</strong></td></tr><tr><td>cassandra.pooling.new.connection.threshold.remote</td><td><strong>Protocol V2 and below: 100, V3 and above: 200</strong></td></tr><tr><td>cassandra.pooling.pool.timeout.millisecs</td><td><strong>5000</strong></td></tr><tr><td>cassandra.protocol.version </td><td><strong>3</strong></td></tr><tr><td>cassandra.query.default.consistency</td><td><strong>ONE</strong></td></tr><tr><td>cassandra.query.default.fetchSize</td><td><strong>5000</strong></td></tr><tr><td>cassandra.query.default.serial.consistency</td><td><strong>SERIAL</strong></td></tr><tr><td>cassandra.reconnection.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr><tr><td>cassandra.retry.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr><tr><td>cassandra.socket.connection.timeout.millisecs</td><td><strong>500</strong></td></tr><tr><td>cassandra.socket.read.timeout.millisecs</td><td><strong>12000</strong></td></tr><tr><td>cassandra.socket.tcp.no_delay</td><td><strong>true</strong></td></tr><tr><td>cassandra.speculative.execution.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr></tbody></table></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="pan el-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Shared states</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body">It is possible to execute many paragraphs in parallel. However, at the back-end side, weâre still using synchronous queries. <em>Asynchronous execution</em> is only possible when it is possible to return a <strong>Future</strong> value in the <strong>InterpreterResult</strong>. It may be an interesting proposal for the <strong>Zeppelin</strong> project.<br/>Another caveat is that the same <strong>com.datastax.driver.core.Session</strong> object is used for <strong>all</strong> notebooks and paragraphs. Consequently, if you use the <em>USE keyspace name;</em> statement to log into a keyspace, it will change the keyspace for <strong>all current users</strong> of the Cassandra interpreter because we only create 1 <strong>com.datastax.driver.core.Session</strong > object per instance of <strong>Cassandra</strong> interpreter.<br/>The same > remark does apply to the <strong>prepared statement hash map</strong>, it is > shared by <strong>all users</strong> using the same instance of > <strong>Cassandra</strong> interpreter.<br/>Until <strong>Zeppelin</strong> > offers a real multi-users separation, there is a work-around to segregate > user environment and states: <em>create different Cassandra interpreter > instances</em><br/><ol><li>First go to the <strong>Interpreter</strong> menu > and click on the <strong>Create</strong> button</li><li>In the interpreter > creation form, put <strong>cass-instance2</strong> as <strong>Name</strong> > and select the <strong>cassandra</strong> in the interpreter drop-down > list</li><li>Click on <strong>Save</strong> to create the new interpreter > instance. Now you should be able to see it in the interpreter > list</li><li>Go back to your notebook and click on the <strong>Gear</strong> > icon to configure interpreter bindings. You should be able to see and select the <strong>cass-instance2</strong> interpreter instance in the available interpreter list instead of the standard <strong>cassandra</strong> instance</li></ol></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Change Log</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><strong>2.0</strong> :<br/><ul><li>Update help menu and add changelog</li><li>Add Support for User Defined Functions, User Defined Aggregates and Materialized Views</li><li>Upgrade Java driver version to <strong>3.0.0-rc1</strong></li></ul><strong>1.0</strong> :<br/><ul><li>Initial version</li></ul></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded ="false"><span class="text-info"><strong>Contact & Bugs</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body">If you encounter a bug for this interpreter, please create a <a href="https://issues.apache.org/jira/browse/ZEPPELIN-382?jql=project%20%3D%20ZEPPELIN" target="_blank"><strong>JIRA</strong></a> ticket and ping me on Twitter at <a href="https://twitter.com/doanduyhai" target="_blank"><strong>@doanduyhai</strong></a></div></div></div></div> \ No newline at end of file +<br/><br/><nav class="navbar navbar-default"><ul class="nav navbar-nav"><li role="presentation" class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="text-info"><i class="glyphicon glyphicon-book"/> <strong>Please select ...</strong></span><span class="text-info caret"></span><ul class="dropdown-menu"><li class="dropdown-header"><span class="text-info">Topics</span></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Basic Commands</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Schema Discovery</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Query Parameters</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i clas s="glyphicon glyphicon-bookmark"/> Prepared Statements</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Dynamic Forms</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Interpreter Configuration</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Shared States</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Change Log</span></a></li><li><a role="button" data-toggle="collapse" ><span class="text-info"><i class="glyphicon glyphicon-bookmark"/> Contacts & Bugs</span></a></li></ul></a></li><li><a><span class="text-info"><strong>CASSANDRA INTERPRETER DOCUMENTATION</strong></span></a></li></ul><ul class="nav navbar-nav na vbar-right"><li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="text-info"><strong>About ...</strong></span><span class="caret"></span></a><ul class="dropdown-menu"><li><a role="button"><span class="text-info">Version <strong>3.0</strong></span></a></li><li><a role="button"><span class="text-info">Java Driver Version <strong>3.0.1</strong></span></a></li><li><a role="button"><span class="text-info">Author <strong>@doanduyhai</strong></span></a></li></ul></li><li><a href="#"></a></li></nav><br/><br/><div class="container"><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Basic Commands</strong></span></a></h4></div><div class="panel-collapse collapse in" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><h3>I CQ L Statements</h3><p>This interpreter is compatible with any CQL statement supported by Cassandra. Ex:<br/><br/><div class="row"><div class="col-md-6 col-md-offset-3"><pre>INSERT INTO users(login,name) VALUES('jdoe','John DOE');SELECT * FROM users WHERE login='jdoe';</pre></div></div><br/>Each statement should be separated by a <strong>semi-colon</strong> (;).<br/><strong>Multi-line</strong> statements as well as multiple statements on the <strong>same line</strong>are also supported as long as they are separated by a semi-colon. Ex:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>USE spark_demo;SELECT * FROM albums_by_country LIMIT 1; SELECT * FROM countries LIMIT 1;SELECT *FROM artistsWHERE login='jlennon';</pre></div></div><br/><strong>Batch</strong> statements are supported and can span multiple lines, as well as<strong>DDL</strong>(CREATE/ALTER/DROP) statements:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>BEGIN BATCHINSERT INTO users (login,name) VALUES('jdoe','John DOE');INSERT INTO users_preferences(login,account_type) VALUES('jdoe','BASIC');APPLY BATCH;CREATE TABLE IF NOT EXISTS test(key int PRIMARY KEY,value text);</pre></div></div><br/>CQL statements are <strong>case-insensitive</strong> (except for column names and values).This means that the following statements are equivalent and valid:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>INSERT INTO users(login,name) VALUES('jdoe','John DOE');Insert into users(login,name) vAlues('hsue','Helen SUE');</pre></div></div><br/>The complete list of all CQL statements and versions can be found below:<br/><br/><div class="row"><div class="col-md-6 col-md-offset-3"><table class="table table-bordered"><thead><tr><th>Cassandra version</th><th>Documentation</th></tr></thead><tbody><tr><td><strong>3.x</strong></td><td><a href="http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html" target="_blank">http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html</ a></td></tr><tr><td><strong>2.2</strong></td><td><a href="http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html" target="_blank">http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html</a></td></tr><tr><td><strong>2.1 & 2.0</strong></td><td><a href="http://docs.datastax.com/en/cql/3.1/cql/cql_intro_c.html" target="_blank">http://docs.datastax.com/en/cql/3.1/cql/cql_intro_c.html</a></td></tr><tr><td><strong>1.2</strong></td><td><a href="http://docs.datastax.com/en/cql/3.0/cql/aboutCQL.html" target="_blank">http://docs.datastax.com/en/cql/3.0/cql/aboutCQL.html</a></td></tr></tbody></table></div></div></p><h3>II Comments</h3><p>It is possible to add comments between statements. Single line comments start with the<strong>hash</strong> sign (#) or <strong>double slashes</strong> (//). Multi-line comments are enclosed between<strong>/**</strong> and <strong>**/</strong>. Ex:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>#Single line comment sty le 1INSERT INTO users(login,name) VALUES('jdoe','John DOE');//Single line comment style 2/**Multi linecomments**/Insert into users(login,name) vAlues('hsue','Helen SUE');</pre></div></div><br/></p><h3>III Syntax Validation</h3><p>The interpreters is shipped with a <em>built-in syntax validator</em>. This validator onlychecks for <strong>basic syntax errors</strong>. All CQL-related syntax validation is delegateddirectly to <strong>Cassandra</strong><br/><br/>Most of the time, syntax errors are due to missing semi-colons between statements or typo errors.</p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Schema Discovery</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><h3>I Commands For Discovery</h 3><p>To make schema discovery easier and more interactive, the following commands are supported:<br/><br/><table class="table table-bordered"><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td><strong>DESCRIBE CLUSTER;</strong></td><td>Show the current cluster name and its partitioner</td></tr><tr><td><strong>DESCRIBE KEYSPACES;</strong></td><td>List all existing keyspaces in the cluster and their configuration(replication factor, durable write ...)</td></tr><tr><td><strong>DESCRIBE TABLES;</strong></td><td>List all existing keyspaces in the cluster and for each, all the tables name</td></tr><tr><td><strong>DESCRIBE TYPES;</strong></td><td>List all existing keyspaces in the cluster and for each, all the types name</td></tr><tr><td><strong>DESCRIBE FUNCTIONS;</strong></td><td>List all existing keyspaces in the cluster and for each, all the functions name and arguments</td></tr><tr><td><strong>DESCRIBE AGGREGATES;</strong></td><td>List all existing keyspaces in the cluster and for each, all the aggregates name and arguments</td></tr><tr><td><strong>DESCRIBE MATERIALIZED VIEWS;</strong></td><td>List all existing keyspaces in the cluster and for each, all the materialized view name</td></tr><tr><td><strong>DESCRIBE KEYSPACE <keyspace name>;</strong></td><td>Describe the given keyspace configuration and all its table details (name, columns, ...)</td></tr><tr><td><strong>DESCRIBE TABLE <em>(<keyspace name>).</em><table name>;</strong></td><td>Describe the given table. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no table is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE TYPE <em>(<keyspace name>).</em><type name>;</strong></td><td>Describe the given type(UDT). If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logge d in keyspace,the default <em>system</em> keyspace is used. If no type is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE FUNCTION <em>(<keyspace name>).</em><function name>;</strong></td><td>Describe the given function. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no function is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE AGGREGATE <em>(<keyspace name>).</em><aggregate name>;</strong></td><td>Describe the given aggregate. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no aggregate is found, an error message is raised</td></tr><tr><td><strong>DESCRIBE MATERIALIZED VIEW <em>(<keyspace name>).</em><view name>;</strong></td><td>Describe the given materialized view. If the keyspace is not provided, the current<strong>logged in</strong> keyspace is used. If there is no logged in keyspace,the default <em>system</em> keyspace is used. If no materialized view is found, an error message is raised</td></tr></tbody></table><br/><div class="alert alert-danger" role="alert">Please note that each <strong>DESCRIBE</strong> command should be ended by <strong>a semi-colon</strong>.</div></p><h3>II Schema Display</h3><p>The schema objects (cluster, keyspace, table, type, view, function & aggregate) are displayed in a tabular format. There is a <strong>drop-down</strong> menu on the top left corner to expand objects details. On the top right menu is shown the Icon legend.</p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Query Parameters</strong></span></a></h4></div><div class= "panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><p>Sometimes you want to be able to pass runtime query parameters to your statements.Those parameters are <strong>not</strong> part of the CQL specs and are specific to the interpreter.Below is the list of all parameters:<br/><br/><table class="table table-bordered"><caption><h4>Query Parameters</h4></caption><thead><tr><th>Parameter</th><th>Syntax</th><th>Description</th></tr></thead><tbody><tr><td>Consistency Level</td><td><strong>@consistency=<em>value</em></strong></td><td>Apply the given consistency level to all queries in the paragraph</td></tr><tr><td>Serial Consistency Level</td><td><strong>@serialConsistency=<em>value</em></strong></td><td>Apply the given serial consistency level to all queries in the paragraph</td></tr><tr><td>Timestamp</td><td><strong>@timestamp=<em>long value</em></strong></td><td>Apply the given timestamp to all queries in the parag raph.<br/>Please note that timestamp value passed directly in CQL statement will override this value</td></tr><tr><td>Retry Policy</td><td><strong>@retryPolicy=<em>value</em></strong></td><td>Apply the given retry policy to all queries in the paragraph</td></tr><tr><td>Fetch Size</td><td><strong>@fetchSize=<em>int value</em></strong></td><td>Apply the given fetch size to all queries in the paragraph</td></tr><tr><td>Request Timeout</td><td><strong>@requestTimeOut=<em>int value</em></strong></td><td>Apply the given request timeout <strong>in millisecs</strong> to all queries in the paragraph</td></tr></tbody></table><br/>Some parameters only accept restricted values:<br/><br/><table class="table table-bordered"><caption><h4>Allowed Values</h4></caption><thead><tr><th>Parameter</th><th>Possible Values</th></tr></thead><tbody><tr><td>Consistency Level</td><td><strong>ALL, ANY, ONE, TWO, THREE, QUORUM, LOCAL_ONE, LOCAL_QUORUM, EACH_QUORUM</strong></td></tr><tr><td>Serial Consistency Lev el</td><td><strong>SERIAL, LOCAL_SERIAL</strong></td></tr><tr><td>Timestamp</td><td>Any long value</td></tr><tr><td>Retry Policy</td><td><strong>DEFAULT, DOWNGRADING_CONSISTENCY, FALLTHROUGH, LOGGING_DEFAULT,LOGGING_DOWNGRADING, LOGGING_FALLTHROUGH</strong></td></tr><tr><td>Fetch Size</td><td>Any integer value</td></tr><tr><td>Request Timeout</td><td>Any integer value</td></tr></tbody></table><br/><div class="alert alert-danger" role="alert">Please note that you <strong>should not add semi-colon (;)</strong> at the end of each parameter statement</div>Some example:<br/><br/><div class="row"><div class="col-md-8 col-md-offset-2"><pre>CREATE TABLE IF NOT EXISTS spark_demo.ts(key int PRIMARY KEY,value text);TRUNCATE spark_demo.ts;// Timestamp in the past@timestamp=10// Force timestamp directly in the first insertINSERT INTO spark_demo.ts(key,value) VALUES(1,'first insert') USING TIMESTAMP 100;// Select some data to make the clock turnSELECT * FROM spark_demo.albums LIMIT 100;// Now ins ert using the timestamp parameter set at the beginning(10)INSERT INTO spark_demo.ts(key,value) VALUES(1,'second insert');// Check for the result. You should see 'first insert'SELECT value FROM spark_demo.ts WHERE key=1;</pre></div></div><br/>Some remarks about query parameters:<br/><br/><div class="alert alert-info" role="alert"><ul><li><strong>many</strong> query parameters can be set in the same paragraph</li><li>if the <strong>same</strong> query parameter is set many time with different values,the interpreter only take into account the first value</li><li>each query parameter applies to <strong>all</strong> CQL statement in the same paragraph,unless you override the option using plain CQL text (like forcing timestamp with the USING clause)</li><li>the order of each query parameter with regard to CQL statement does not matter</li></ul></div></p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="but ton" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Prepared Statements</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><h3>I Syntax</h3><br/><p>For performance reason, it is better to <strong>prepare statements</strong> before-hand and reusethem later by providing bound values. This interpreter provides 3 commands to handle prepared andbound statements:<br/><br/><ol><li><strong>@prepare</strong></li><li><strong>@bind</strong></li><li><strong>@remove_prepared</strong></li></ol><br/>Example:<br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>@prepare[statement-name]=...@bind[statement-name]=âtextâ, 1223, â2015-07-30 12:00:01â, null, true, [âlist_item1â, âlist_item2â]@bind[statement-name-with-no-bound-value]@remove_prepare[statement-name]</pre></div></div><br/><h3>II @prepare</h3><br/><p>You can use the syntax "<strong>@prepare[statement-name]=SELECT ...</strong>" to create a prepared statement.The <em>statement-name</em> is mandatory because the interpreter prepares the given statement with theJava driver and saves the generated prepared statement in an internal map, using the provided<em>statement-name</em> as search key.<br/><br/><div class="alert alert-info">Please note that this internal prepared statement map is shared with <strong>all notebooks</strong>and <strong>all paragraphs</strong> because there is only one instance of the interpreter for Cassandra</div><br/><div class="alert alert-warning">If the interpreter encounters many @prepare for the <strong>same statement-name</strong> (key),only the <strong>first</strong> statement will be taken into account.</div><br/>Example:<br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>@prepare[select]=SELECT * FROM spark_demo.albums LIMIT ?@prepare[select]=SELECT * FROM spark_demo.artists LIMIT ?</pre></div></div><br/>For th e above example, the prepared statement is <strong>"SELECT * FROM spark_demo.albums LIMIT ?"</strong>.<strong>"SELECT * FROM spark_demo.artists LIMIT ?"</strong> is ignored because an entry already exists in theprepared statements map with the key <strong>select</strong>.<br/><br/>In the context of Zeppelin, a notebook can be scheduled to be executed at regular interval,thus it is necessary to avoid re-preparing many time the same statement (considered an anti-pattern).</p><h3>III @bind</h3><br/><p>Once the statement is prepared (possibly in a separated notebook/paragraph). You can bind values to it:<br/><br/><div class="row"><div class="col-md-10 col-md-offset-1"><pre>@bind[select_first]=10</pre></div></div><br/>Bound values are not mandatory for the <strong>@bind</strong> statement.However if you provide bound values, they need to comply to some syntax:<ul><li>String values should be enclosed between simple quotes ( â )</li><li>Date values should be enclosed between simple quote s ( â ) and respect the formats:<ol><li>yyyy-MM-dd HH:MM:ss</li><li>yyyy-MM-dd HH:MM:ss.SSS</li></ol></li><li><strong>null</strong> is parsed as-is</li><li><strong>boolean</strong> (true|false) are parsed as-is </li><li>collection values must follow the<a href="http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_collections_c.html" target="_blank">standard CQL syntax</a>:<ul><li>list: [âlist_item1â, âlist_item2â, ...]</li><li>set: {âset_item1â, âset_item2â, â¦}</li><li>map: {âkey1â: âval1â, âkey2â: âval2â, â¦}</li></ul></li><li>tuple values should be enclosed between parenthesis(see <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_reference/tupleType.html" target="_blank">tuple CQL syntax</a>):(âtextâ, 123, true)</li><li>udt values should be enclosed between brackets(see <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_using/cqlUseUDT.html" target="_blank">udt CQL syntax</a>):{stree_name: âBeverly Hillsâ, number: 104, zip_code: 90020, state: âCaliforniaâ, â¦}</li></ul><br/><div class="alert alert-info">It is possible to use the <strong>@bind</strong> statement inside a batch: <br/><pre>BEGIN BATCH@bind[insert_user]='jdoe','John DOE'UPDATE users SET age = 27 WHERE login='hsue';APPLY BATCH;</pre></div><br/></p><h3>IV @remove_prepare</h3><br/><p>To avoid for a prepared statement to stay forever in the prepared statement map, you can use the <strong>@remove_prepare[statement-name]</strong> syntaxto remove it. Removing a non-existing prepared statement yields no error.</p></div></div></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Dynamic Forms</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><div class="panel panel-default"><div class="panel-body"><p>Instead of hard-coding your CQL queries , it is possible to use <strong><a href="http://zeppelin.apache.org/docs/0.6.0-SNAPSHOT/manual/dynamicform.html" target="_blank">Zeppelin dynamic form</a></strong> syntax to inject simple value or multiple choices forms.The legacy mustache syntax ( <strong>{{ }}</strong> ) to bind input text and select form is still supported but is deprecated and will be removed in future releases.<br/><br/><h6> -- Legacy syntax -- </h6>The syntax for simple parameter is: <strong>{{input_Label=default value}}</strong>.The default value is mandatory because the first time the paragraph is executed,we launch the CQL query before rendering the form so at least one value should be provided.<br/><br/>The syntax for multiple choices parameter is: <strong>{{input_Label=value1 | value2 | ⦠| valueN }}</strong>.By default the first choice is used for CQL query the first time the paragraph is executed.<h6> -- End legacy syntax -- </h6><br/><br/>Example:<br/><div class="row"><div class="col-md-10 col-md-of fset-1"><pre>#Secondary index on performer styleSELECT name, country, performerFROM spark_demo.performersWHERE name='${performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}'AND styles CONTAINS '${style=Rock}';</pre></div></div><br/>In the above example, the first CQL query will be executed for <em>performer='Sheryl Crow'</em>AND <em>style='Rock'</em>. For subsequent queries, you can change the value directly using the form.Please note that we enclosed the {{ }} block between simple quotes (') because Cassandra expects a String here.We could have also use the <strong>${style='Rock'}</strong> syntax but this time, the valuedisplayed on the form is <em>'Rock'</em> and not <em>Rock</em>.<br/><br/><div class="alert alert-info">It is also possible to use dynamic forms for <strong>prepared statements</strong>: <br/><strong>@bind[select]=='${performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}', '${style=Rock}'</strong></div></pre></p></div></div></div></div></div><div class="panel panel-default"> <div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Interpreter Configuration</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body">The <strong>Cassandra</strong> interpreter comes with some some configuration values for the Java driver:<table class="table table-bordered"><caption><h4>Interpreter Configuration</h4></caption><thead><tr><th>Parameter</th><th>Default Value</th></tr></thead><tbody><tr><td>cassandra.cluster</td><td><strong>Test Cluster</strong></td></tr><tr><td>cassandra.compression.protocol</td><td><strong>NONE</strong>, possible values: LZ4, SNAPPY</td></tr><tr><td>cassandra.credentials.password</td><td><strong>none</strong></td></tr><tr><td>cassandra.credentials.username</td><td><strong>none</strong></td></tr><tr><td>cassandra.hosts</td><td><strong>localhost</strong></td></tr><tr><td>cassandra.interpreter.parall elism</td><td><strong>10</strong></td></tr><tr><td>cassandra.keyspace</td><td><strong>system</strong></td></tr><tr><td>cassandra.load.balancing.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr><tr><td>cassandra.max.schema.agreement.wait.second</td><td><strong>10</strong></td></tr><tr><td>cassandra.native.port</td><td><strong>9042</strong></td></tr><tr><td>cassandra.pooling.core.connection.per.host.local</td><td><strong>Protocol V2 and below: 2, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.core.connection.per.host.remote</td><td><strong>Protocol V2 and below: 1, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.heartbeat.interval.seconds</td><td><strong>30</strong></td></tr><tr><td>cassandra.pooling.idle.timeout.seconds</td><td><strong>Test Cluster</strong></td></tr><tr><td>cassandra.pooling.max.connection.per.host.local</td><td><strong>Protocol V2 and below: 8, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.max.conne ction.per.host.remote</td><td><strong>Protocol V2 and below: 2, V3 and above: 1</strong></td></tr><tr><td>cassandra.pooling.max.request.per.connection.local</td><td><strong>Protocol V2 and below: 128, V3 and above: 1024</strong></td></tr><tr><td>cassandra.pooling.max.request.per.connection.remote</td><td><strong>Protocol V2 and below: 128, V3 and above: 256</strong></td></tr><tr><td>cassandra.pooling.new.connection.threshold.local</td><td><strong>Protocol V2 and below: 100, V3 and above: 800</strong></td></tr><tr><td>cassandra.pooling.new.connection.threshold.remote</td><td><strong>Protocol V2 and below: 100, V3 and above: 200</strong></td></tr><tr><td>cassandra.pooling.pool.timeout.millisecs</td><td><strong>5000</strong></td></tr><tr><td>cassandra.protocol.version</td><td><strong>4</strong></td></tr><tr><td>cassandra.query.default.consistency</td><td><strong>ONE</strong></td></tr><tr><td>cassandra.query.default.fetchSize</td><td><strong>5000</strong></td></tr><tr><td>cassandra.quer y.default.serial.consistency</td><td><strong>SERIAL</strong></td></tr><tr><td>cassandra.reconnection.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr><tr><td>cassandra.retry.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr><tr><td>cassandra.socket.connection.timeout.millisecs</td><td><strong>500</strong></td></tr><tr><td>cassandra.socket.read.timeout.millisecs</td><td><strong>12000</strong></td></tr><tr><td>cassandra.socket.tcp.no_delay</td><td><strong>true</strong></td></tr><tr><td>cassandra.speculative.execution.policy</td><td><strong>DEFAULT</strong>, or a FQCN of a custom class</td></tr></tbody></table></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Shared states</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-b ody">It is possible to execute many paragraphs in parallel. However, at the back-end side, weâre still using synchronous queries. <em>Asynchronous execution</em> is only possible when it is possible to return a <strong>Future</strong> value in the <strong>InterpreterResult</strong>. It may be an interesting proposal for the <strong>Zeppelin</strong> project.<br/><br/>Recently, <strong>Zeppelin</strong> allows you to choose the level of isolation for your interpreters (see<strong><a href="http://zeppelin.apache.org/docs/0.6.0-SNAPSHOT/manual/interpreters.html" target="_blank">Interpreter Binding Mode</a></strong> ).<br/><br/>Long story short, you have 3 available bindings:<ul><li><strong>shared</strong> : <em>same JVM</em> and <em>same Interpreter instance</em> for all notes</li><li><strong>scoped</strong> : <em>same JVM</em> but <em>different Interpreter instances</em>, one for each note</li><li><strong>isolated</strong> : <em>different JVM</em> running a <em>single Interpreter in stance</em>, one JVM for each note</li></ul><br/>Using the <strong>shared</strong> binding, the same <code>com.datastax.driver.core.Session</code> object is used for all notes and paragraphs.Consequently, if you use the <strong>USE keyspace name;</strong> statement to log into a keyspace,it will change the keyspace for all current users of the Cassandra interpreter because we only create 1<code>com.datastax.driver.core.Session</code> object per instance of Cassandra interpreter.<br/><br/>The same remark does apply to the <strong>prepared statement hash map</strong>, it is shared by all users using the same instance of Cassandra interpreter.<br/><br/>When using <strong>scoped</strong> binding, in the <em>same JVM</em><strong>Zeppelin</strong> will create multiple instances of the Cassandra interpreter,thus multiple <code>com.datastax.driver.core.Session</code> objects.<strong>Beware of resource and memory usage using this binding !</strong><br/><br/>The <strong>isolated</strong> mode is the most extreme and will create as many JVM/<code>com.datastax.driver.core.Session</code> object as there are distinct notes.</div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Change Log</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body"><strong>3.0</strong> :<br/><ul><li>Update documentation</li><li>Update interactive documentation</li><li>Add support for binary protocol <strong>V4</strong></li><li>Implement new <code>@requestTimeOut</code> runtime option</li><li>Upgrade Java driver version to <strong>3.0.1</strong></li><li>Allow interpreter to add dynamic forms programmatically when using FormType.SIMPLE</li><li>Allow dynamic form using default Zeppelin syntax</li><li>Fixing typo on FallThroughPolicy</li><li>Look for data in AngularObjectRegistry before creatin g dynamic form</li><li>Add missing support for <code>ALTER</code> statements</li></ul><strong>2.0</strong> :<br/><ul><li>Update help menu and add changelog</li><li>Add Support for User Defined Functions, User Defined Aggregates and Materialized Views</li><li>Upgrade Java driver version to <strong>3.0.0-rc1</strong></li></ul><strong>1.0</strong> :<br/><ul><li>Initial version</li></ul></div></div></div><div class="panel panel-default"><div class="panel-heading" role="tab"><h4 class="panel-title"><a role="button" data-toggle="collapse" aria-expanded="false"><span class="text-info"><strong>Contact & Bugs</strong></span></a></h4></div><div class="panel-collapse collapse" role="tabpanel"><div class="panel-body">If you encounter a bug for this interpreter, please create a <a href="https://issues.apache.org/jira/browse/ZEPPELIN-382?jql=project%20%3D%20ZEPPELIN" target="_blank"><strong>JIRA</strong></a> ticket and ping me on Twitter at <a href="https://twitter.com/doanduyhai" target="_blank"><strong>@doanduyhai</strong></a></div></div></div></div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/cassandra/src/test/scala/org/apache/zeppelin/cassandra/ParagraphParserTest.scala ---------------------------------------------------------------------- diff --git a/cassandra/src/test/scala/org/apache/zeppelin/cassandra/ParagraphParserTest.scala b/cassandra/src/test/scala/org/apache/zeppelin/cassandra/ParagraphParserTest.scala index 520f7a6..4c5c929 100644 --- a/cassandra/src/test/scala/org/apache/zeppelin/cassandra/ParagraphParserTest.scala +++ b/cassandra/src/test/scala/org/apache/zeppelin/cassandra/ParagraphParserTest.scala @@ -182,6 +182,12 @@ class ParagraphParserTest extends FlatSpec parsed should matchPattern { case parser.Success(FetchSize(100), _) =>} } + "Parser" should "parse request timeout" in { + val query:String ="@requestTimeOut=100" + val parsed = parser.parseAll(parser.requestTimeOut, query) + parsed should matchPattern { case parser.Success(RequestTimeOut(100), _) =>} + } + "Parser" should "fails parsing invalid fetch size" in { val query:String =""" @fetchSize=TEST""".stripMargin val ex = intercept[InterpreterException] { @@ -944,4 +950,15 @@ class ParagraphParserTest extends FlatSpec case parser.Success(List(SimpleStm(query)), _) => } } + + "Parser" should "parse ALTER KEYSPACE" in { + val query = "ALTER KEYSPACE toto WITH replication = " + + "{'class': 'SimpleStrategy', 'replication_factor': 1};" + + val parsed = parser.parseAll(parser.queries, query) + + parsed should matchPattern { + case parser.Success(List(SimpleStm(query)), _) => + } + } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/docs/assets/themes/zeppelin/img/docs-img/cassandra-InterpreterName.png ---------------------------------------------------------------------- diff --git a/docs/assets/themes/zeppelin/img/docs-img/cassandra-InterpreterName.png b/docs/assets/themes/zeppelin/img/docs-img/cassandra-InterpreterName.png deleted file mode 100644 index 821b004..0000000 Binary files a/docs/assets/themes/zeppelin/img/docs-img/cassandra-InterpreterName.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInList.png ---------------------------------------------------------------------- diff --git a/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInList.png b/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInList.png deleted file mode 100644 index b287f41..0000000 Binary files a/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInList.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInstance.png ---------------------------------------------------------------------- diff --git a/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInstance.png b/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInstance.png deleted file mode 100644 index 36f6c3e..0000000 Binary files a/docs/assets/themes/zeppelin/img/docs-img/cassandra-NewInterpreterInstance.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/docs/interpreter/cassandra.md ---------------------------------------------------------------------- diff --git a/docs/interpreter/cassandra.md b/docs/interpreter/cassandra.md index 7a0837b..2091666 100644 --- a/docs/interpreter/cassandra.md +++ b/docs/interpreter/cassandra.md @@ -100,6 +100,7 @@ Each statement should be separated by a semi-colon ( **;** ) except the special 6. @timestamp 7. @retryPolicy 8. @fetchSize +9. @requestTimeOut Multi-line statements as well as multiple statements on the same line are also supported as long as they are separated by a semi-colon. Ex: @@ -146,6 +147,15 @@ The complete list of all CQL statements and versions can be found below: <th>Documentation Link</th> </tr> <tr> + <td><strong>3.x</strong></td> + <td> + <a target="_blank" + href="http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html"> + http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html + </a> + </td> + </tr> + <tr> <td><strong>2.2</strong></td> <td> <a target="_blank" @@ -333,6 +343,11 @@ Below is the list of all parameters: <td><strong>@fetchSize=<em>integer value</em></strong></td> <td>Apply the given fetch size to all queries in the paragraph</td> </tr> + <tr> + <td nowrap>Request Time Out</td> + <td><strong>@requestTimeOut=<em>integer value</em></strong></td> + <td>Apply the given request timeout <strong>in millisecs</strong> to all queries in the paragraph</td> + </tr> </table> </center> @@ -379,19 +394,19 @@ CREATE TABLE IF NOT EXISTS spark_demo.ts( ); TRUNCATE spark_demo.ts; -# Timestamp in the past +// Timestamp in the past @timestamp=10 -# Force timestamp directly in the first insert +// Force timestamp directly in the first insert INSERT INTO spark_demo.ts(key,value) VALUES(1,'first insert') USING TIMESTAMP 100; -# Select some data to make the clock turn +// Select some data to make the clock turn SELECT * FROM spark_demo.albums LIMIT 100; -# Now insert using the timestamp parameter set at the beginning(10) +// Now insert using the timestamp parameter set at the beginning(10) INSERT INTO spark_demo.ts(key,value) VALUES(1,'second insert'); -# Check for the result. You should see 'first insert' +// Check for the result. You should see 'first insert' SELECT value FROM spark_demo.ts WHERE key=1; ``` @@ -415,25 +430,25 @@ This interpreter provides 3 commands to handle prepared and bound statements: Example: ``` -@prepare[statement_name]=... +@prepare[statement-name]=... -@bind[statement_name]=âtextâ, 1223, â2015-07-30 12:00:01â, null, true, [âlist_item1â, âlist_item2â] +@bind[statement-name]=âtextâ, 1223, â2015-07-30 12:00:01â, null, true, [âlist_item1â, âlist_item2â] -@bind[statement_name_with_no_bound_value] +@bind[statement-name-with-no-bound-value] -@remove_prepare[statement_name] +@remove_prepare[statement-name] ``` #### @prepare -You can use the syntax _"@prepare[statement_name]=SELECT ..."_ to create a prepared statement. -The _statement_name_ is **mandatory** because the interpreter prepares the given statement with the Java driver and -saves the generated prepared statement in an **internal hash map**, using the provided _statement_name_ as search key. +You can use the syntax _"@prepare[statement-name]=SELECT..."_ to create a prepared statement. +The _statement-name_ is **mandatory** because the interpreter prepares the given statement with the Java driver and +saves the generated prepared statement in an **internal hash map**, using the provided _statement-name_ as search key. > Please note that this internal prepared statement map is shared with **all > notebooks** and **all paragraphs** because there is only one instance of the interpreter for Cassandra -> If the interpreter encounters **many** @prepare for the **same _statement_name_ (key)**, only the **first** statement will be taken into account. +> If the interpreter encounters **many** @prepare for the **same _statement-name_ (key)**, only the **first** statement will be taken into account. Example: @@ -443,8 +458,8 @@ Example: @prepare[select]=SELECT * FROM spark_demo.artists LIMIT ? ``` -For the above example, the prepared statement is _SELECT * FROM spark_demo.albums LIMIT ?_. -_SELECT * FROM spark_demo.artists LIMIT ?_ is ignored because an entry already exists in the prepared statements map with the key select. +For the above example, the prepared statement is `SELECT * FROM spark_demo.albums LIMIT ?`. +`SELECT * FROM spark_demo.artists LIMIT ? is ignored because an entry already exists in the prepared statements map with the key select. In the context of **Zeppelin**, a notebook can be scheduled to be executed at regular interval, thus it is necessary to **avoid re-preparing many time the same statement (considered an anti-pattern)**. @@ -483,18 +498,22 @@ Bound values are not mandatory for the **@bind** statement. However if you provi #### @remove_prepare To avoid for a prepared statement to stay forever in the prepared statement map, you can use the -**@remove_prepare[statement_name]** syntax to remove it. +**@remove_prepare[statement-name]** syntax to remove it. Removing a non-existing prepared statement yields no error. ## Using Dynamic Forms -Instead of hard-coding your CQL queries, it is possible to use the mustache syntax ( **\{\{ \}\}** ) to inject simple value or multiple choices forms. +Instead of hard-coding your CQL queries, it is possible to use **[Zeppelin dynamic form]** syntax to inject simple value or multiple choices forms. + +The legacy mustache syntax ( **\{\{ \}\}** ) to bind input text and select form is still supported but is deprecated and will be removed in future releases. -The syntax for simple parameter is: **\{\{input_Label=default value\}\}**. The default value is mandatory because the first time the paragraph is executed, -we launch the CQL query before rendering the form so at least one value should be provided. +> **Legacy** +> The syntax for simple parameter is: **\{\{input_Label=default value\}\}**. The default value is mandatory because the first time the paragraph is executed, +> we launch the CQL query before rendering the form so at least one value should be provided. +> +> The syntax for multiple choices parameter is: **\{\{input_Label=value1 | value2 | ⦠| valueN \}\}**. By default the first choice is used for CQL query +> the first time the paragraph is executed. -The syntax for multiple choices parameter is: **\{\{input_Label=value1 | value2 | ⦠| valueN \}\}**. By default the first choice is used for CQL query -the first time the paragraph is executed. Example: @@ -502,22 +521,22 @@ Example: #Secondary index on performer style SELECT name, country, performer FROM spark_demo.performers - WHERE name='{{performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}}' - AND styles CONTAINS '{{style=Rock}}'; + WHERE name='${performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}' + AND styles CONTAINS '${style=Rock}'; {% endraw %} In the above example, the first CQL query will be executed for _performer='Sheryl Crow' AND style='Rock'_. For subsequent queries, you can change the value directly using the form. -> Please note that we enclosed the **\{\{ \}\}** block between simple quotes ( **'** ) because Cassandra expects a String here. -> We could have also use the **\{\{style='Rock'\}\}** syntax but this time, the value displayed on the form is **_'Rock'_** and not **_Rock_**. +> Please note that we enclosed the **$\{ \}** block between simple quotes ( **'** ) because Cassandra expects a String here. +> We could have also use the **$\{style='Rock'\}** syntax but this time, the value displayed on the form is **_'Rock'_** and not **_Rock_**. It is also possible to use dynamic forms for **prepared statements**: {% raw %} - @bind[select]=='{{performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}}', '{{style=Rock}}' + @bind[select]=='${performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}', '${style=Rock}' {% endraw %} @@ -527,39 +546,26 @@ It is possible to execute many paragraphs in parallel. However, at the back-end _Asynchronous execution_ is only possible when it is possible to return a `Future` value in the `InterpreterResult`. It may be an interesting proposal for the **Zeppelin** project. -Another caveat is that the same `com.datastax.driver.core.Session` object is used for **all** notebooks and paragraphs. +Recently, **Zeppelin** allows you to choose the level of isolation for your interpreters (see **[Interpreter Binding Mode]** ). + +Long story short, you have 3 available bindings: + + - **shared** : _same JVM_ and _same Interpreter instance_ for all notes + - **scoped** : _same JVM_ but _different Interpreter instances_, one for each note + - **isolated**: _different JVM_ running a _single Interpreter instance_, one JVM for each note + +Using the **shared** binding, the same `com.datastax.driver.core.Session` object is used for **all** notes and paragraphs. Consequently, if you use the **USE _keyspace name_;** statement to log into a keyspace, it will change the keyspace for **all current users** of the **Cassandra** interpreter because we only create 1 `com.datastax.driver.core.Session` object per instance of **Cassandra** interpreter. The same remark does apply to the **prepared statement hash map**, it is shared by **all users** using the same instance of **Cassandra** interpreter. -Until **Zeppelin** offers a real multi-users separation, there is a work-around to segregate user environment and states: -_create different **Cassandra** interpreter instances_ +When using **scoped** binding, in the _same JVM_ **Zeppelin** will create multiple instances of the Cassandra interpreter, thus +multiple `com.datastax.driver.core.Session` objects. **Beware of resource and memory usage using this binding !** -For this, first go to the **Interpreter** menu and click on the **Create** button -<center> -  -</center> +The **isolated** mode is the most extreme and will create as many JVM/`com.datastax.driver.core.Session` object as there are distinct notes. -In the interpreter creation form, put **cass-instance2** as **Name** and select the **cassandra** -in the interpreter drop-down list -<center> -  -</center> - - Click on **Save** to create the new interpreter instance. Now you should be able to see it in the interpreter list. -<center> -  -</center> - -Go back to your notebook and click on the **Gear** icon to configure interpreter bindings. -You should be able to see and select the **cass-instance2** interpreter instance in the available -interpreter list instead of the standard **cassandra** instance. - -<center> -  -</center> ## Interpreter Configuration @@ -694,7 +700,7 @@ Below are the configuration parameters and their default value. <tr> <td>cassandra.protocol.version</td> <td>Cassandra binary protocol version</td> - <td>3</td> + <td>4</td> </tr> <tr> <td>cassandra.query.default.consistency</td> @@ -771,12 +777,28 @@ Below are the configuration parameters and their default value. ## Change Log +**3.0** _(Zeppelin {{ site.ZEPPELIN_VERSION }})_ : + +* Update documentation +* Update interactive documentation +* Add support for binary protocol **V4** +* Implement new `@requestTimeOut` runtime option +* Upgrade Java driver version to **3.0.1** +* Allow interpreter to add dynamic forms programmatically when using FormType.SIMPLE +* Allow dynamic form using default Zeppelin syntax +* Fixing typo on FallThroughPolicy +* Look for data in AngularObjectRegistry before creating dynamic form +* Add missing support for `ALTER` statements + + **2.0** _(Zeppelin {{ site.ZEPPELIN_VERSION }})_ : + * Update help menu and add changelog * Add Support for **User Defined Functions**, **User Defined Aggregates** and **Materialized Views** * Upgrade Java driver version to **3.0.0-rc1** **1.0** _(Zeppelin 0.5.5-incubating)_ : + * Initial version ## Bugs & Contacts @@ -789,5 +811,7 @@ Below are the configuration parameters and their default value. [standard CQL syntax]: http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_collections_c.html [Tuple CQL syntax]: http://docs.datastax.com/en/cql/3.1/cql/cql_reference/tupleType.html [UDT CQL syntax]: http://docs.datastax.com/en/cql/3.1/cql/cql_using/cqlUseUDT.html +[Zeppelin dynamic form]: http://zeppelin.apache.org/docs/0.6.0-SNAPSHOT/manual/dynamicform.html +[Interpreter Binding Mode]: http://zeppelin.apache.org/docs/0.6.0-SNAPSHOT/manual/interpreters.html [JIRA]: https://issues.apache.org/jira/browse/ZEPPELIN-382?jql=project%20%3D%20ZEPPELIN [@doanduyhai]: https://twitter.com/doanduyhai http://git-wip-us.apache.org/repos/asf/zeppelin/blob/68b9b00f/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java index 1829162..39ddf52 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java @@ -23,6 +23,7 @@ import org.apache.thrift.TException; import org.apache.zeppelin.display.AngularObject; import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.display.GUI; +import org.apache.zeppelin.display.Input; import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.InterpreterResult.Type; import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterContext; @@ -262,7 +263,8 @@ public class RemoteInterpreter extends Interpreter { boolean broken = false; try { - GUI settings = context.getGui(); + + final GUI currentGUI = context.getGui(); RemoteInterpreterResult remoteResult = client.interpret( noteId, className, st, convert(context)); @@ -272,11 +274,20 @@ public class RemoteInterpreter extends Interpreter { context.getConfig().clear(); context.getConfig().putAll(remoteConfig); + if (form == FormType.NATIVE) { GUI remoteGui = gson.fromJson(remoteResult.getGui(), GUI.class); - context.getGui().clear(); - context.getGui().setParams(remoteGui.getParams()); - context.getGui().setForms(remoteGui.getForms()); + currentGUI.clear(); + currentGUI.setParams(remoteGui.getParams()); + currentGUI.setForms(remoteGui.getForms()); + } else if (form == FormType.SIMPLE) { + final Map<String, Input> currentForms = currentGUI.getForms(); + final Map<String, Object> currentParams = currentGUI.getParams(); + final GUI remoteGUI = gson.fromJson(remoteResult.getGui(), GUI.class); + final Map<String, Input> remoteForms = remoteGUI.getForms(); + final Map<String, Object> remoteParams = remoteGUI.getParams(); + currentForms.putAll(remoteForms); + currentParams.putAll(remoteParams); } InterpreterResult result = convert(remoteResult);
