-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Initial support for CassandraSQLContext for %sql queries #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fb27aba
Added support for CassandraSQLContext for %sql queries
bbromhead 4808830
No longer set spark.cassandra props explicitly as this is done alread…
bbromhead f28a956
Merge branch 'master' into cassandraSQLsupport
bbromhead b400ee9
Adding integration tests for Cassandra SQL context
bbromhead 7fef967
Minor style changes
bbromhead 3f39f93
Changed SqarkInterpreter to only use the Hive context when explicitly…
bbromhead 270dc3b
Merge branch 'master' of https://github.com/apache/incubator-zeppelin…
bbromhead 4c8e638
Added CI test for Cassandra and Spark 1.3
bbromhead c453426
Reverted change to default spark context. Now uses HiveContext as per…
bbromhead 056f6dd
turn off hive for Cassandra test
bbromhead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,26 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| CREATE TABLE test ( | ||
| name text, | ||
| age int, | ||
| PRIMARY KEY(name)); | ||
|
|
||
| INSERT INTO test (name, age) values ('moon', 33); | ||
| INSERT INTO test (name, age) values ('jobs', 51); | ||
| INSERT INTO test (name, age) values ('gates', 51); | ||
| INSERT INTO test (name, age) values ('park', 34); |
33 changes: 33 additions & 0 deletions
33
spark/src/main/resources/log4j-embedded-cassandra.properties
This file contains hidden or 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,33 @@ | ||
| # 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. | ||
|
|
||
| # for production, you should probably set the root to INFO | ||
| # and the pattern to %c instead of %l. (%l is slower.) | ||
|
|
||
| # output messages into a rolling log file as well as stdout | ||
| log4j.rootLogger=ERROR,stdout,HColumnFamilyLogger | ||
|
|
||
| # stdout | ||
| log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
| log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
| log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c{3} - %m%n | ||
| log4j.appender.stdout.follow=true | ||
|
|
||
| log4j.appender.HColumnFamilyLogger=org.apache.log4j.ConsoleAppender | ||
| log4j.appender.HColumnFamilyLogger.layout=org.apache.log4j.PatternLayout | ||
| log4j.appender.HColumnFamilyLogger.layout.ConversionPattern=%m%n | ||
| log4j.category.HColumnFamilyLogger=DEBUG | ||
| #log4j.category.org.apache=INFO, stdout |
94 changes: 94 additions & 0 deletions
94
spark/src/test/java/org/apache/zeppelin/spark/CassandraSparkSqlInterpreterTest.java
This file contains hidden or 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,94 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package org.apache.zeppelin.spark; | ||
|
|
||
| import org.apache.zeppelin.display.AngularObjectRegistry; | ||
| import org.apache.zeppelin.display.GUI; | ||
| import org.apache.zeppelin.interpreter.InterpreterContext; | ||
| import org.apache.zeppelin.interpreter.InterpreterContextRunner; | ||
| import org.apache.zeppelin.interpreter.InterpreterGroup; | ||
| import org.apache.zeppelin.interpreter.InterpreterResult; | ||
| import org.apache.zeppelin.interpreter.InterpreterResult.Type; | ||
| import org.cassandraunit.CassandraCQLUnit; | ||
| import org.cassandraunit.dataset.cql.ClassPathCQLDataSet; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.LinkedList; | ||
| import java.util.Properties; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| public class CassandraSparkSqlInterpreterTest { | ||
|
|
||
| private SparkSqlInterpreter sql; | ||
| private SparkInterpreter repl; | ||
| private InterpreterContext context; | ||
| private InterpreterGroup intpGroup; | ||
|
|
||
| @Rule | ||
| public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql","sparkkeyspace")); | ||
|
|
||
|
|
||
| @Before | ||
| public void setUp() throws Exception { | ||
| Properties p = new Properties(); | ||
| p.setProperty("zeppelin.spark.useCassandraContext", "true"); | ||
| p.setProperty("spark.cassandra.connection.host", "127.0.0.1"); | ||
| p.setProperty("spark.cassandra.connection.port", "9142"); | ||
|
|
||
| if (repl == null) { | ||
|
|
||
| if (SparkInterpreterTest.repl == null) { | ||
| repl = new SparkInterpreter(p); | ||
| repl.open(); | ||
| SparkInterpreterTest.repl = repl; | ||
| } else { | ||
| repl = SparkInterpreterTest.repl; | ||
| } | ||
|
|
||
| sql = new SparkSqlInterpreter(p); | ||
|
|
||
| intpGroup = new InterpreterGroup(); | ||
| intpGroup.add(repl); | ||
| intpGroup.add(sql); | ||
| sql.setInterpreterGroup(intpGroup); | ||
| sql.open(); | ||
| } | ||
| context = new InterpreterContext("note", "id", "title", "text", new HashMap<String, Object>(), new GUI(), | ||
| new AngularObjectRegistry(intpGroup.getId(), null), | ||
| new LinkedList<InterpreterContextRunner>()); | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() throws Exception { | ||
| } | ||
|
|
||
| @Test | ||
| public void test() { | ||
| InterpreterResult ret = sql.interpret("select name, age from sparkkeyspace.test where age < 40", context); | ||
| assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); | ||
| assertEquals(Type.TABLE, ret.type()); | ||
| assertEquals("name\tage\nmoon\t33\npark\t34\n", ret.message()); | ||
|
|
||
| assertEquals(InterpreterResult.Code.SUCCESS, sql.interpret("select * FROM sparkkeyspace.test as t1 INNER JOIN sparkkeyspace.test as t2 on t1.name = t2.name", context).code()); | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any good way to keep this value unchanged?
Changing default value might confuse user. what do you think?