-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ZEPPELIN-559] Cassandra interpreter v2
### What is this PR for? * Update the **Cassandra** interpreter to V2 to support new **schema commands** to describe **Cassandra** 3.x features: * User Defined Functions * User Defined Aggregates * Materialized Views * Add support for single line comment using **double slashes** (//) * Add **DESCRIBE TYPES** * The Java driver version is bumped to **3.0.0-rc1** * The contextual **HELP menu** is also updated and a _ChangeLog_ section is added. ### What type of PR is it? [Improvement] ### Todos * [x] - Add new PR to update official Cassandra interpreter with new features * [x] - Test steps executed and confirmed working by the community * [x] - Code review by the community (warning, **Scala** inside) ### Is there a relevant Jira issue? **[ZEPPELIN-559]** **[ZEPPELIN-575]** for doc ### How should this be tested? 1. Download and install locally **[Cassandra 3.1.1]** 2. Start **Cassandra** 3. Clone this pull request locally with: 1. _git fetch origin pull/600/head:CassandraInterpreterV2_ 2. _git checkout CassandraInterpreterV2_ 4. Build this version of Zeppelin with _mvn clean package -DskipTests_ 5. Start **Zeppelin** and update the property _cassandra.hosts_ of the **Cassandra** interpreter (set it to _localhost_ or _127.0.0.1_ depending on your configuration) 6. In a paragraph, execute all the **CQL** statements given in this **[CassandraInterpreterV2TestData.cql]** by copy-pasting them 7. Start a new _%cassandra_ paragraph and execute **DESCRIBE FUNCTION test.maxOf;**. You should be able to see: ![image](https://cloud.githubusercontent.com/assets/1532977/12138932/edaf45d4-b45c-11e5-8724-104085d6e30d.png) 8. Start a new _%cassandra_ paragraph and execute **DESCRIBE AGGREGATE test.group_by;**. You should be able to see: ![image](https://cloud.githubusercontent.com/assets/1532977/12138970/2ecd784c-b45d-11e5-9076-a7b674439fa5.png) 9. Start a new _%cassandra_ paragraph and execute **DESCRIBE MATERIALIZED VIEW test.user_by_country;**. You should be able to see: ![image](https://cloud.githubusercontent.com/assets/1532977/12139025/a223a104-b45d-11e5-8331-b97323016fa3.png) 10. Start a new _%cassandra_ paragraph and execute **SELECT id,val1,val2,maxOf(val1,val2) FROM test.test_max;**. You should be able to see: ![image](https://cloud.githubusercontent.com/assets/1532977/12139046/c43febf8-b45d-11e5-9b96-290aff23730e.png) 11. Start a new _%cassandra_ paragraph and execute **SELECT group_by(category,sales_count) FROM test.items;**. You should be able to see: ![image](https://cloud.githubusercontent.com/assets/1532977/12139071/fb06b1e4-b45d-11e5-9077-6ec3275c1319.png) 12. Start a new _%cassandra_ paragraph and execute **SELECT * FROM test.user_by_country WHERE country='FR';**. You should be able to see: ![image](https://cloud.githubusercontent.com/assets/1532977/12139085/1671f3d0-b45e-11e5-9dc2-4bf6bd87e84e.png) ### Questions: * Does the licenses files need update? --> **No** * Is there breaking changes for older versions? --> **No** * Does this needs documentation? --> **Yes** [ZEPPELIN-559]: https://issues.apache.org/jira/browse/ZEPPELIN-559 [ZEPPELIN-575]: https://issues.apache.org/jira/browse/ZEPPELIN-575 [Cassandra 3.1.1]: http://cassandra.apache.org/download/ [CassandraInterpreterV2TestData.cql]: https://gist.githubusercontent.com/doanduyhai/5d88aaf3820be28474d2/raw/e5b5d9c325a17a58c2f27bff454db999fd3a3a66/CassandraInterpreterV2TestData.cql Author: DuyHai DOAN <doanduyhai@gmail.com> Closes #600 from doanduyhai/CassandraInterpreter-V2 and squashes the following commits: 36e3bdb [DuyHai DOAN] Fix random test failure a2d831b [DuyHai DOAN] Refactor after code review 41b8667 [DuyHai DOAN] Tune regular expression for FUNCTION creation pattern 138804c [DuyHai DOAN] Fix CSS style for UDF & MV in menu display 6509da5 [DuyHai DOAN] Fix failing tests 7a5ac39 [DuyHai DOAN] Update RegExp for UDF creation to fix multiple statements match 6ea9e55 [DuyHai DOAN] Update help menu and changelog 6b46076 [DuyHai DOAN] Add Support for UDF, UDA and Materialized Views 058161d [DuyHai DOAN] Upgrade Java driver version to 3.0.0-rc1
- Loading branch information
1 parent
9308ee1
commit 11a45e2
Showing
33 changed files
with
2,122 additions
and
3,121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<%-- | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
--%> | ||
#import(org.apache.zeppelin.cassandra.MetaDataHierarchy._) | ||
<%@ val sameNameAggregateDetails: SameNameAggregateDetails %> | ||
<%@ val withCaption: Boolean%> | ||
<div class="row"> | ||
<div class="col-md-2"/> | ||
<div class="col-md-8 col-offset-md-2"> | ||
#for (aggregate <- sameNameAggregateDetails.aggregates) | ||
<div class="panel panel-default table-responsive table-bordered"> | ||
<table class="table"> | ||
#if(withCaption) | ||
<caption><h4 class="text-success"><i class="glyphicon glyphicon-retweet"/> ${aggregate.name}</h4></caption> | ||
#end | ||
<tbody> | ||
<tr> | ||
<td class="col-md-6"><strong>Keyspace</strong></td> | ||
<td class="col-md-6 text-danger">${aggregate.keyspace}</td> | ||
</tr> | ||
<tr> | ||
<td class="col-md-6"><strong>Arguments</strong></td> | ||
<td class="col-md-6">${aggregate.arguments.toList.mkString(", ")}</td> | ||
</tr> | ||
<tr> | ||
<td class="col-md-6"><strong>State Function</strong></td> | ||
<td class="col-md-6">${aggregate.sFunc}</td> | ||
</tr> | ||
<tr> | ||
<td class="col-md-6"><strong>State Type</strong></td> | ||
<td class="col-md-6">${aggregate.sType}</td> | ||
</tr> | ||
#if(aggregate.finalFunc.isDefined) | ||
<tr> | ||
<td class="col-md-6"><strong>Final Function</strong></td> | ||
<td class="col-md-6">${aggregate.finalFunc.get}</td> | ||
</tr> | ||
#end | ||
#if(aggregate.initCond.isDefined) | ||
<tr> | ||
<td class="col-md-6"><strong>Initial State</strong></td> | ||
<td class="col-md-6">${aggregate.initCond.get}</td> | ||
</tr> | ||
#end | ||
<tr> | ||
<td class="col-md-6"><strong>Return type</strong></td> | ||
<td class="col-md-6">${aggregate.returnType}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<div class="panel-footer"> | ||
<a data-toggle="collapse" data-target="#${aggregate.uniqueId}_asCQL"> | ||
<strong>As CQL statement</strong> | ||
<span class="caret"></span> | ||
</a> | ||
<br/><br/> | ||
<div class="text-success collapse" id="${aggregate.uniqueId}_asCQL"> | ||
<pre class="well">${aggregate.asCQL}</pre> | ||
</div> | ||
</div> | ||
</div> | ||
<hr/> | ||
#end | ||
</div> | ||
<div class="col-md-2"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<%-- | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
--%> | ||
|
||
#import(org.apache.zeppelin.cassandra.MetaDataHierarchy._) | ||
#import(java.util.UUID) | ||
<%@ val allAggregates: Map[(UUID, String), List[AggregateSummary]] %> | ||
|
||
<div class="container"> | ||
|
||
<div class="row"> | ||
<div class="panel-group" role="tablist" aria-multiselectable="true"> | ||
#for (((ksId,ksName), aggregates) <- allAggregates) | ||
<div class="panel panel-default"> | ||
<div class="panel-heading" role="tab"> | ||
<h4 class="panel-title"> | ||
<a role="button" data-toggle="collapse" data-target="#${ksId}" aria-expanded="false"> | ||
<span class="text-danger"><i class="glyphicon glyphicon-folder-open"/> ${ksName}</span> | ||
</a> | ||
</h4> | ||
</div> | ||
<div id="${ksId}" class="panel-collapse collapse" role="tabpanel"> | ||
<div class="panel-body"> | ||
<div class="row"> | ||
<div class="col-md-2"/> | ||
<div class="col-md-8 col-offset-md-2 table-responsive table-bordered"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Aggregate</th> | ||
<th>Return Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
#for (aggregate <- aggregates) | ||
<tr class="text-success"> | ||
<td>${aggregate.name + aggregate.arguments.mkString("(", ", ", ")")}</td> | ||
<td>${aggregate.returnType}</td> | ||
</tr> | ||
#end | ||
|
||
</tbody> | ||
</table> | ||
</div> | ||
<div class="col-md-2"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
#end | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<%-- | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
--%> | ||
|
||
#import(org.apache.zeppelin.cassandra.MetaDataHierarchy._) | ||
#import(java.util.UUID) | ||
<%@ val allFunctions: Map[(UUID, String), List[FunctionSummary]] %> | ||
|
||
<div class="container"> | ||
|
||
<div class="row"> | ||
<div class="panel-group" role="tablist" aria-multiselectable="true"> | ||
#for (((ksId,ksName), functions) <- allFunctions) | ||
<div class="panel panel-default"> | ||
<div class="panel-heading" role="tab"> | ||
<h4 class="panel-title"> | ||
<a role="button" data-toggle="collapse" data-target="#${ksId}" aria-expanded="false"> | ||
<span class="text-danger"><i class="glyphicon glyphicon-folder-open"/> ${ksName}</span> | ||
</a> | ||
</h4> | ||
</div> | ||
<div id="${ksId}" class="panel-collapse collapse" role="tabpanel"> | ||
<div class="panel-body"> | ||
<div class="row"> | ||
<div class="col-md-2"/> | ||
<div class="col-md-8 col-offset-md-2 table-responsive table-bordered"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Function</th> | ||
<th>Return Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
#for (function <- functions) | ||
<tr class="text-success"> | ||
<td>${function.name + function.arguments.mkString("(",", ", ")")}</td> | ||
<td>${function.returnType}</td> | ||
</tr> | ||
#end | ||
|
||
</tbody> | ||
</table> | ||
</div> | ||
<div class="col-md-2"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
#end | ||
</div> | ||
</div> | ||
</div> |
68 changes: 68 additions & 0 deletions
68
cassandra/src/main/resources/scalate/allMaterializedViews.ssp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<%-- | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
--%> | ||
#import(org.apache.zeppelin.cassandra.MetaDataHierarchy._) | ||
#import(java.util.UUID) | ||
<%@ val allMVs: Map[(UUID,String),List[MaterializedViewSummary]] %> | ||
<div class="container"> | ||
|
||
<div class="row"> | ||
<div class="panel-group" role="tablist" aria-multiselectable="true"> | ||
#for (((ksId,ksName), mvs) <- allMVs) | ||
<div class="panel panel-default"> | ||
<div class="panel-heading" role="tab"> | ||
<h4 class="panel-title"> | ||
<a role="button" data-toggle="collapse" data-target="#${ksId}" aria-expanded="false"> | ||
<span class="text-danger"><i class="glyphicon glyphicon-folder-open"/> ${ksName}</span> | ||
</a> | ||
</h4> | ||
</div> | ||
<div id="${ksId}" class="panel-collapse collapse" role="tabpanel"> | ||
<div class="panel-body"> | ||
<div class="row"> | ||
<div class="col-md-2"/> | ||
<div class="col-md-8 col-offset-md-2 table-responsive table-bordered"> | ||
<table class="table"> | ||
<thead> | ||
<tr><th>Materialized View</th></tr> | ||
</thead> | ||
<tbody> | ||
#for (mv <- mvs) | ||
|
||
<tr class="text-primary"> | ||
<td> | ||
${mv.name} | ||
<i class="glyphicon glyphicon-arrow-right"/> | ||
<i class="glyphicon glyphicon-th-list"/> | ||
${mv.baseTable} | ||
</td> | ||
</tr> | ||
#end | ||
|
||
</tbody> | ||
</table> | ||
</div> | ||
<div class="col-md-2"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
#end | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.