Skip to content

Conversation

@conker84
Copy link
Contributor

@conker84 conker84 commented Jul 10, 2017

What is this PR for?

This contribution would to introduce Neo4j Cypher intepreter and at the same time provides base APIs that enable other graph databases (or graph framworks such as GraphX or Giraph).

What type of PR is it?

[Feature]

Todos

  • - Provide base APIs to manage graph results (under: org.apache.zeppelin.interpreter.graph.*)
  • - Create the Neo4j intepreter

What is the Jira issue?

[ZEPPELIN-2761]

How should this be tested?

Donwload and execute Neo4j v3.x, you can also pull a Docker image.

In order to execute test cases, if you are running Java 7, you need to also provide an environment variable telling the tests where to find Java 8, because Neo4j-the-database needs it to run.

export NEO4J_JAVA=<path/to/java/home>

Use this statement to create a dummy dataset

%neo4j
UNWIND range(1,100) as id
CREATE (p:Person {id:id, name: "Name " + id, age: id % 3}) WITH collect(p) as people
UNWIND people as p1
UNWIND range(1,10) as friend
WITH p1, people[(p1.id + friend) % size(people)] as p2
CREATE (p1)-[:KNOWS {years: abs(p2.id - p2.id)}]->(p2)

Then you can write some simple queries like:

%neo4j
MATCH (p:Person)-[r:KNOWS]-(p1:Person)
RETURN p, r, p1
LIMIT 10;
%neo4j
MATCH (p:Person)-[r:KNOWS]-(p1:Person)
RETURN p.id AS ID_A, p.name AS NAME_A, r.years AS YEARS, p1.id AS ID_B, p1.name AS NAME_B
LIMIT 20;

Video

zeppelin query examples

Questions:

  • Does the licenses files need update? Yes
  • Is there breaking changes for older versions? No
  • Does this needs documentation? Yes

@jexp
Copy link

jexp commented Jul 11, 2017

I looked through the code and the UX and can confirm that this is great work from a Neo4j point of view.

@1ambda
Copy link
Member

1ambda commented Jul 17, 2017

Thanks for the great feature! since this is a big change, I guess it takes a time to review and requires multiple reviewers. Let me take a look.

* [Lens](./interpreter/lens.html)
* [Livy](./interpreter/livy.html)
* [markdown](./interpreter/markdown.html)
* [Neo4j](./interpreter/neo4j.html)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

'bower_components/ace-builds/src-noconflict/mode-python.js',
'bower_components/ace-builds/src-noconflict/mode-sql.js',
'bower_components/ace-builds/src-noconflict/mode-markdown.js',
'bower_components/ace-builds/src-noconflict/mode-pig.js',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to remove mode-pig.js?

@1ambda
Copy link
Member

1ambda commented Aug 8, 2017

This is a new feature that makes utilizing graph type easily. Any other opinions?

@jexp
Copy link

jexp commented Aug 8, 2017

@1ambda any update on the review progress?
We really would love to see this feature in Apache Zeppelin :)

Thanks a lot.

<div id="toc"></div>

## Overview
[Neo4j](https://neo4j.com/product/) is a native graph database, designed to store and process graphs from bottom to top. On the other hand, non-native solutions only add a shallow graph processing layer to an RDBMS or other NoSQL data stores, resulting in sub-optimal performance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part On the other hand, non-native solutions only add a shallow graph processing layer to an RDBMS or other NoSQL data stores, resulting in sub-optimal performance. sounds more like marketing :) think we can drop this from our doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

String username = properties.getProperty(NEO4J_AUTH_USER);
String password = properties.getProperty(NEO4J_AUTH_PASSWORD);
LOGGER.debug("Creating a BASIC authentication to neo4j with user '{}' and password '{}'",
username, password);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably shouldn't log password?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right, it is my forgetfulness.
Removed

<script src="bower_components/ace-builds/src-noconflict/mode-python.js"></script>
<script src="bower_components/ace-builds/src-noconflict/mode-sql.js"></script>
<script src="bower_components/ace-builds/src-noconflict/mode-markdown.js"></script>
<script src="bower_components/ace-builds/src-noconflict/mode-pig.js"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

"neo4j.auth.password": {
"envName": null,
"propertyName": "neo4j.auth.password",
"defaultValue": "neo4j",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, would it be better if the default value for password is ""?

}
} else if (obj instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) obj;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need unchecked here?

public InterpreterResult interpret(String cypherQuery, InterpreterContext interpreterContext) {
logger.info("Opening session");
if (StringUtils.isEmpty(cypherQuery)) {
return new InterpreterResult(Code.ERROR, "Cypher query is Empty");
Copy link
Member

@felixcheung felixcheung Aug 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you check other interpeters? it might be preferred to do nothing if the query is empty, instead of returning an error

@Override
public InterpreterResult interpret(String cypherQuery, InterpreterContext interpreterContext) {
logger.info("Opening session");
if (StringUtils.isEmpty(cypherQuery)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check isBlank instead

(Apache 2.0) frontend-maven-plugin 1.3 (com.github.eirslett:frontend-maven-plugin:1.3 - https://github.com/eirslett/frontend-maven-plugin/blob/frontend-plugins-1.3/LICENSE
(Apache 2.0) frontend-plugin-core 1.3 (com.github.eirslett:frontend-plugin-core) - https://github.com/eirslett/frontend-maven-plugin/blob/frontend-plugins-1.3/LICENSE
(Apache 2.0) mongo-java-driver 3.4.1 (org.mongodb:mongo-java-driver:3.4.1) - https://github.com/mongodb/mongo-java-driver/blob/master/LICENSE.txt
(Apache 2.0) Neo4j Java Driver (https://github.com/neo4j/neo4j-java-driver) - https://github.com/neo4j/neo4j-java-driver/blob/1.1/LICENSE.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to include neo4j-harness here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @felixcheung ,
in the #1582 Moon said that "...org.neo4j.test:neo4j-harness is 'test' scope and will not bundled into the binary package, we don't need include it in zeppelin-distribution/src/bin_license/LICENSE file..."

Are you sure?

(Apache 2.0) frontend-maven-plugin 1.3 (com.github.eirslett:frontend-maven-plugin:1.3 - https://github.com/eirslett/frontend-maven-plugin/blob/frontend-plugins-1.3/LICENSE
(Apache 2.0) frontend-plugin-core 1.3 (com.github.eirslett:frontend-plugin-core) - https://github.com/eirslett/frontend-maven-plugin/blob/frontend-plugins-1.3/LICENSE
(Apache 2.0) mongo-java-driver 3.4.1 (org.mongodb:mongo-java-driver:3.4.1) - https://github.com/mongodb/mongo-java-driver/blob/master/LICENSE.txt
(Apache 2.0) Neo4j Java Driver (https://github.com/neo4j/neo4j-java-driver) - https://github.com/neo4j/neo4j-java-driver/blob/1.1/LICENSE.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have version 1.4.0 in the pom file - should we have the same version for license instead of 1.1?

@jexp
Copy link

jexp commented Aug 19, 2017

@conker84 ping :)

@conker84
Copy link
Contributor Author

@felixcheung let me know if i have to do something else!

@conker84
Copy link
Contributor Author

Hi guys, any news/plan about this?

@felixcheung
Copy link
Member

sorry for dropping this. will review shortly.

@jexp
Copy link

jexp commented Sep 14, 2017

@felixcheung thank you. We've also received requests from others waiting for this PR :)

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok LGTM with minor suggestions:

  1. in the doc example/images/video we should avoid referencing political figures :)
    could you please update them?
  2. (optional) shall we move neo4j-java-driver to 1.4.3, and neo4j 3.2.3?

}
},
"editor": {
"language": "cypher",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: there is no syntax highlighting support for cypher, so this won't do anything...

@conker84
Copy link
Contributor Author

Sorry for the late response, i lost it :(
@jexp what do you think about this
(optional) shall we move neo4j-java-driver to 1.4.3, and neo4j 3.2.3?
@felixcheung i'm updating the images :)

@jexp
Copy link

jexp commented Sep 24, 2017

Yes please update.

@conker84
Copy link
Contributor Author

@felixcheung travis is failing, have i to rebase?

@felixcheung
Copy link
Member

Let's try rebasing

@felixcheung
Copy link
Member

I've reviewed the changes

@conker84
Copy link
Contributor Author

conker84 commented Oct 2, 2017

@felixcheung the job #10.2 fails...
Can you help me?

@jexp
Copy link

jexp commented Oct 4, 2017

@felixcheung ping :)

@conker84
Copy link
Contributor Author

conker84 commented Oct 8, 2017

Hi @felixcheung any news?
Thanks
Andrea

@felixcheung
Copy link
Member

could you rebase to pick up the change, I think the test failure is fixed by PR # 2609

@felixcheung
Copy link
Member

since this is a known failure that is already fixed, let's not restart the process.
merging if no more comment

@jexp
Copy link

jexp commented Oct 9, 2017

yay!! thanks so much.

@conker84
Copy link
Contributor Author

Thanks!

@felixcheung
Copy link
Member

merged, thanks!

@asfgit asfgit closed this in e0fafac Oct 11, 2017
@jexp
Copy link

jexp commented Oct 19, 2017

@felixcheung just curious when is the next Zeppelin release planned ? :)
Can't wait to see this out in the wild.

@felixcheung
Copy link
Member

felixcheung commented Oct 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants