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
[CARBONDATA-2752][CARBONSTORE] Carbon provide Zeppelin support #2522
Changes from 2 commits
16c6983
1380125
db9d07f
ab7f713
04a5690
21a9a1c
3df49ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import org.apache.carbondata.store.api.exception.StoreException; | ||
|
||
import org.apache.spark.sql.AnalysisException; | ||
import org.apache.spark.sql.Dataset; | ||
import org.apache.spark.sql.Row; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
|
@@ -42,20 +43,24 @@ public class SqlHorizonController { | |
public ResponseEntity<SqlResponse> sql(@RequestBody SqlRequest request) throws StoreException { | ||
RequestValidator.validateSql(request); | ||
List<Row> rows; | ||
Dataset<Row> sqlDataFrame = null; | ||
try { | ||
rows = SparkSqlWrapper.sql(SqlHorizon.getSession(), request.getSqlStatement()) | ||
sqlDataFrame = SparkSqlWrapper.sql(SqlHorizon.getSession(), | ||
request.getSqlStatement()); | ||
rows = sqlDataFrame | ||
.collectAsList(); | ||
} catch (AnalysisException e) { | ||
throw new StoreException(e.getSimpleMessage()); | ||
} catch (Exception e) { | ||
throw new StoreException(e.getMessage()); | ||
} | ||
Object[][] result = new Object[rows.size()][]; | ||
Object[][] result = new Object[rows.size()+1][]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add space before and after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
result[0] = sqlDataFrame.schema().fieldNames(); | ||
for (int i = 0; i < rows.size(); i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replaced with stream construct |
||
Row row = rows.get(i); | ||
result[i] = new Object[row.size()]; | ||
result[i+1] = new Object[row.size()]; | ||
for (int j = 0; j < row.size(); j++) { | ||
result[i][j] = row.get(j); | ||
result[i+1][j] = row.get(j); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't use System.arraycopy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Please follow below steps to integrate with zeppelin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this README written for carbon specificly? |
||
1. mvn package -Pzeppelin | ||
This will generate carbondata-zeppelin-*.tar.gz under target folder | ||
2. Extract the tar content to ZEPPELIN_INSTALL_HOME/interpreter | ||
3. Add org.apache.carbonndata.zeppelin.CarbonInterpreter to list of interpreters mentioned by zeppelin.interpreters @ ZEPPELIN_INSTALL_HOME/conf/zeppelin-site.xml (create if not exists) | ||
Example: | ||
<property> | ||
<name>zeppelin.interpreters</name> | ||
<value>org.apache.zeppelin.spark.SparkInterpreter,org.apache.zeppelin.spark.PySparkInterpreter,org.apache.zeppelin.spark.SparkRInterpreter,org.apache.zeppelin.spark.SparkSqlInterpreter,org.apache.zeppelin.spark.DepInterpreter,org.apache.zeppelin.markdown.Markdown,org.apache.zeppelin.angular.AngularInterpreter,org.apache.zeppelin.shell.ShellInterpreter,org.apache.zeppelin.file.HDFSFileInterpreter,org.apache.zeppelin.flink.FlinkInterpreter,,org.apache.zeppelin.python.PythonInterpreter,org.apache.zeppelin.python.PythonInterpreterPandasSql,org.apache.zeppelin.python.PythonCondaInterpreter,org.apache.zeppelin.python.PythonDockerInterpreter,org.apache.zeppelin.lens.LensInterpreter,org.apache.zeppelin.ignite.IgniteInterpreter,org.apache.zeppelin.ignite.IgniteSqlInterpreter,org.apache.zeppelin.cassandra.CassandraInterpreter,org.apache.zeppelin.geode.GeodeOqlInterpreter,org.apache.zeppelin.jdbc.JDBCInterpreter,org.apache.zeppelin.kylin.KylinInterpreter,org.apache.zeppelin.elasticsearch.ElasticsearchInterpreter,org.apache.zeppelin.scalding.ScaldingInterpreter,org.apache.zeppelin.alluxio.AlluxioInterpreter,org.apache.zeppelin.hbase.HbaseInterpreter,org.apache.zeppelin.livy.LivySparkInterpreter,org.apache.zeppelin.livy.LivyPySparkInterpreter,org.apache.zeppelin.livy.LivyPySpark3Interpreter,org.apache.zeppelin.livy.LivySparkRInterpreter,org.apache.zeppelin.livy.LivySparkSQLInterpreter,org.apache.zeppelin.bigquery.BigQueryInterpreter,org.apache.zeppelin.beam.BeamInterpreter,org.apache.zeppelin.pig.PigInterpreter,org.apache.zeppelin.pig.PigQueryInterpreter,org.apache.zeppelin.scio.ScioInterpreter,org.apache.zeppelin.groovy.GroovyInterpreter</value> | ||
<description>Comma separated interpreter configurations. First interpreter become a default</description> | ||
</property> | ||
4. Add carbon to list of interpreters mentioned by zeppelin.interpreter.order @ ZEPPELIN_INSTALL_HOME/conf/zeppelin-site.xml | ||
Example: | ||
<property> | ||
<name>zeppelin.interpreter.group.order</name> | ||
<value>spark,md,angular,sh,livy,alluxio,file,psql,flink,python,ignite,lens,cassandra,geode,kylin,elasticsearch,scalding,jdbc,hbase,bigquery,beam,groovy</value> | ||
<description></description> | ||
</property> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<assembly> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please move zeppelin folder to integration folder |
||
<id>compress</id> | ||
<formats> | ||
<format>tar.gz</format> | ||
</formats> | ||
|
||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<dependencySets> | ||
<dependencySet> | ||
<outputDirectory>/carbon</outputDirectory> | ||
<useTransitiveDependencies>false</useTransitiveDependencies> | ||
<includes> | ||
<include>com.fasterxml.jackson.core:*:jar</include> | ||
</includes> | ||
</dependencySet> | ||
</dependencySets> | ||
|
||
<fileSets> | ||
|
||
<fileSet> | ||
<directory>misc/</directory> | ||
<outputDirectory>carbon</outputDirectory> | ||
<includes> | ||
<include>*.json</include> | ||
</includes> | ||
</fileSet> | ||
|
||
<fileSet> | ||
<directory>target</directory> | ||
<outputDirectory>carbon</outputDirectory> | ||
<includes> | ||
<include>carbondata-zeppelin-*.jar</include> | ||
</includes> | ||
</fileSet> | ||
|
||
</fileSets> | ||
</assembly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"group": "carbon", | ||
"name": "carbon", | ||
"className": "org.apache.carbondata.zeppelin.CarbonInterpreter", | ||
"properties": { | ||
"carbon.query.api.url": { | ||
"envName": null, | ||
"propertyName": "carbon.query.api.url", | ||
"defaultValue": "", | ||
"description": "API URL for request", | ||
"type": "string" | ||
} | ||
}, | ||
"editor": { | ||
"language": "sql", | ||
"editOnDblClick": false, | ||
"completionKey": "TAB", | ||
"completionSupport": true | ||
} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.carbondata</groupId> | ||
<artifactId>carbondata-parent</artifactId> | ||
<version>1.5.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>carbondata-zeppelin</artifactId> | ||
<name>Apache CarbonData :: Zeppelin</name> | ||
|
||
<properties> | ||
<dev.path>${basedir}/../dev</dev.path> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.zeppelin</groupId> | ||
<artifactId>zeppelin-interpreter</artifactId> | ||
<version>0.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<version>2.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.8.11.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.8.10</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<descriptor>assembly/assembly.xml</descriptor> | ||
<finalName>carbondata-zeppelin-${version}</finalName> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
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.
move it to previous line
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.
Done