Skip to content

[ZEPPELIN-1999] get interpreter property with replaced context parameters#2085

Closed
tinkoff-dwh wants to merge 10 commits into
apache:masterfrom
tinkoff-dwh:ZEPPELIN-1999
Closed

[ZEPPELIN-1999] get interpreter property with replaced context parameters#2085
tinkoff-dwh wants to merge 10 commits into
apache:masterfrom
tinkoff-dwh:ZEPPELIN-1999

Conversation

@tinkoff-dwh
Copy link
Copy Markdown
Contributor

@tinkoff-dwh tinkoff-dwh commented Mar 1, 2017

What is this PR for?

Adds posibility to use context parameters (types: String.class, Double.class, Float.class, Short.class,
Byte.class, Character.class, Boolean.class, Integer.class, Long.class, ) into property value of interpreter.

What type of PR is it?

Feature

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-1999

How should this be tested?

  1. Add text with markers #{contextFieldNAme} (ex. #{noteId} or #{replName}) to interpreter property value (or add new property of interpreter).
  2. Get this property (getProperty(key)), markers should be replaced by context values

Questions:

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

Copy link
Copy Markdown
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.

is there a reason you choose the #{contextParameterName} format?

@tinkoff-dwh
Copy link
Copy Markdown
Contributor Author

tinkoff-dwh commented Mar 1, 2017

  1. uniqueness of the marker to replace
  2. similar format of the parameters in the paragraph https://github.com/apache/zeppelin/blob/master/docs/manual/dynamicform.md (${}, not the same, not to be confused)

@andrykrp
Copy link
Copy Markdown

andrykrp commented Mar 2, 2017

Looks good

@mgarmash
Copy link
Copy Markdown

mgarmash commented Mar 6, 2017

Nice feature! +1

@tinkoff-dwh
Copy link
Copy Markdown
Contributor Author

@felixcheung
Are there problems for merge?

Comment thread .gitignore Outdated
.idea/
*.iml
*.iws
*.ipr
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what are these for?

Copy link
Copy Markdown
Contributor Author

@tinkoff-dwh tinkoff-dwh Mar 12, 2017

Choose a reason for hiding this comment

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

it is excludes extensions of project (jetbrains IDEA)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If it's not related to this PR, can you please create new minor PR for handling it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jongyoul
done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

Comment thread docs/manual/interpreters.md Outdated

Properties are exported as environment variable when property name is consisted of upper characters, numbers and underscore ([A-Z_0-9]). Otherwise set properties as JVM property.
Properties are exported as environment variable when property name is consisted of upper characters, numbers and underscore ([A-Z_0-9]). Otherwise set properties as JVM property.
You may use parameters from the context of interpreter by add #{contextParameterName} (except fields of paragraph) in value, parameter can be of the following types: string, number, boolean. The list of available context parameters can be viewed in the class [InterpreterContext.java](https://github.com/apache/zeppelin/blob/master/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterContext.java) + parameter #{user}.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since this is talking about a new concept, let's put this into a new paragraph (ie. double new line in markdown,before this line)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think it'd be better to get casual users to look at Java code - could you add a table here of the types/context parameters it could support?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.. and with some code/paragraph example in text that the user can run and test with?

@felixcheung
Copy link
Copy Markdown
Member

I think this is a good feature to have. Let's hold on to get a bit more feedback on this - @Leemoonsoo what do you think about something like this?

@dwhsys
Copy link
Copy Markdown

dwhsys commented Mar 15, 2017

I think that this PR is a great step forward to enterprise version of Zeppelin. Using this feature there will be an ability to implement native integration between different interpreters based on single schema per user / note in core analytical DBMS. Another feature is the possibility of data access control without using credentials.

@felixcheung, @Leemoonsoo, what do you think?

@Leemoonsoo
Copy link
Copy Markdown
Member

Thanks @tinkoff-dwh for useful new feature.
LGTM!

Comment thread docs/manual/interpreters.md Outdated

Properties are exported as environment variable when property name is consisted of upper characters, numbers and underscore ([A-Z_0-9]). Otherwise set properties as JVM property.

Properties are exported as environment variable when property name is consisted of upper characters, numbers and underscore ([A-Z_0-9]). Otherwise set properties as JVM property.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One minor suggestion: )
as environment variable -> as environment variables

Comment thread docs/manual/interpreters.md Outdated

Properties are exported as environment variable when property name is consisted of upper characters, numbers and underscore ([A-Z_0-9]). Otherwise set properties as JVM property.

You may use parameters from the context of interpreter by add #{contextParameterName} (except fields of paragraph) in value, parameter can be of the following types: string, number, boolean.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about
"You might want to use parameters from the context of interpreter by adding #{contextParameterName} (except fields of paragraph) in the value. In this case, the parameter can be one of the following types: string, number or boolean."

Probably it's only for me, but in my case, hard to understand what "except fields of paragraph" means. It'll be better we have more information what except fields is. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

list of available parameters described below

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assumed that the other readers may same with me. Couldn't get "except fields of paragraph" has same meaning with "list of available parameters described below".

Comment thread docs/manual/interpreters.md Outdated

If context parameter is null then replaced by empty string.

<img src="../assets/themes/zeppelin/img/screenshots/interpreter_setting_with_context_parameters.png" width="500px">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems the image size is too small so hard to see now. Needs to be "800px" as this image does.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no, image width more than 500px

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is what I can see for this image. The font in this image is even smaller than the other text around it.
screen shot 2017-03-19 at 10 47 49 pm

Copy link
Copy Markdown
Contributor Author

@tinkoff-dwh tinkoff-dwh Mar 19, 2017

Choose a reason for hiding this comment

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

The font on the following image smaller too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, width should increment to 800

Comment thread docs/manual/interpreters.md Outdated

###### Usage
For example in database exist user `user1` with some password and exists user with same name into Zeppelin. Configure the jdbc interpreter (postgres), set `default.user = #{user}`.
1. Sign in (as `user1`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add one new line before this line? Currently it's rendered like below.
screen shot 2017-03-19 at 9 51 09 pm

Comment thread docs/manual/interpreters.md Outdated
###### Usage
For example in database exist user `user1` with some password and exists user with same name into Zeppelin. Configure the jdbc interpreter (postgres), set `default.user = #{user}`.
1. Sign in (as `user1`)
2. Open interpreter
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you mean exactly "Open interpreter" ? Can we use more elaborative word in here?

Comment thread docs/manual/interpreters.md Outdated
<img src="../assets/themes/zeppelin/img/screenshots/interpreter_setting_with_context_parameters.png" width="500px">

###### Usage
For example in database exist user `user1` with some password and exists user with same name into Zeppelin. Configure the jdbc interpreter (postgres), set `default.user = #{user}`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For example in database exist user user1 with some password and exists user with same name into Zeppelin.

As the above sentence, we assume that the readers already know about how they configure user setting and enable Shiro. But as you know, this manual/interpreters.md mainly focuses on Zeppelin beginners(e.g. don't know about what interpreter is in Zeppelin/ how they can bind interpreter to the note ..). Not sure what can be the better description for this, i just thought this sentence need more information. What do you think? :)

Copy link
Copy Markdown
Contributor

@masyan masyan Mar 19, 2017

Choose a reason for hiding this comment

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

maybe, but it is common doc to all interpreters and the best place which I found. might be better to remove this pragraph.

@AhyoungRyu
Copy link
Copy Markdown
Contributor

@tinkoff-dwh Saw your latest update. As you did,

###### Usage		
 For example in database exist user `user1` with some password and exists user with same name into Zeppelin. Configure the jdbc interpreter (postgres), set `default.user = #{user}`.
		
   1. Sign in (as `user1`)		
   2. Open interpreter		
   3. Execute `select current_user`

The above usage example can be added JDBC interpreter docs. But it's okay we can update it in later time not in this PR. LGTM

Copy link
Copy Markdown
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.

any other comment?

p = p.replaceAll(String.format(markerTemplate, field.getName()),
value != null ? value.toString() : StringUtils.EMPTY);
} catch (Exception e) {
logger.error("Cannot replace context parameter", e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should it stop or continue with #{name} in it if it couldn't find a match?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if field with name name exists in context then replaced in any case

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could you add a test for that new case then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

test testPropertyWithReplacedContextFields covers this case, replName in context is NULL and replaced with an empty string

@felixcheung
Copy link
Copy Markdown
Member

felixcheung commented Mar 23, 2017 via email

@asfgit asfgit closed this in 998c8f3 Mar 25, 2017
@tinkoff-dwh tinkoff-dwh deleted the ZEPPELIN-1999 branch March 27, 2017 05:49
masyan pushed a commit to Tinkoff/zeppelin that referenced this pull request Sep 5, 2017
…ters

### What is this PR for?
Adds posibility to use context parameters (types: String.class, Double.class, Float.class, Short.class,
Byte.class, Character.class, Boolean.class, Integer.class, Long.class, ) into property value of interpreter.

### What type of PR is it?
Feature

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1999

### How should this be tested?
1. Add text with markers #{contextFieldNAme} (ex. #{noteId} or #{replName}) to interpreter property value (or add new property of interpreter).
2. Get this property (getProperty(key)), markers should be replaced by context values

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? yes

Author: Tinkoff DWH <tinkoff.dwh@gmail.com>

Closes apache#2085 from tinkoff-dwh/ZEPPELIN-1999 and squashes the following commits:

fa1500a [Tinkoff DWH] [ZEPPELIN-1999] fix logic of replace
93c759d [Tinkoff DWH] Merge remote-tracking branch 'origin/master' into ZEPPELIN-1999
be4fada [Tinkoff DWH] [ZEPPELIN-1999] revert gitignore
c0110e9 [Tinkoff DWH] [ZEPPELIN-1999] documentation
61ac564 [Tinkoff DWH] [ZEPPELIN-1999] docs
a10dc0e [Tinkoff DWH] [ZEPPELIN-1999] skip fields of paragraph
ea9c6a3 [Tinkoff DWH] [ZEPPELIN-1999] docs
7c4489c [Tinkoff DWH] Merge remote-tracking branch 'origin/master' into ZEPPELIN-1999
527419a [Tinkoff DWH] Merge remote-tracking branch 'origin/master' into ZEPPELIN-1999
b5424b9 [Tinkoff DWH] [ZEPPELIN-1999] get interpreter property with replaced context parameters
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.

9 participants