[ZEPPELIN-1999] get interpreter property with replaced context parameters#2085
[ZEPPELIN-1999] get interpreter property with replaced context parameters#2085tinkoff-dwh wants to merge 10 commits into
Conversation
# Conflicts: # zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java
felixcheung
left a comment
There was a problem hiding this comment.
is there a reason you choose the #{contextParameterName} format?
|
|
Looks good |
|
Nice feature! +1 |
|
@felixcheung |
| .idea/ | ||
| *.iml | ||
| *.iws | ||
| *.ipr |
There was a problem hiding this comment.
it is excludes extensions of project (jetbrains IDEA)
There was a problem hiding this comment.
If it's not related to this PR, can you please create new minor PR for handling it?
|
|
||
| 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}. |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
.. and with some code/paragraph example in text that the user can run and test with?
|
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? |
|
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? |
|
Thanks @tinkoff-dwh for useful new feature. |
|
|
||
| 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. |
There was a problem hiding this comment.
One minor suggestion: )
as environment variable -> as environment variables
|
|
||
| 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
list of available parameters described below
There was a problem hiding this comment.
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".
|
|
||
| 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"> |
There was a problem hiding this comment.
It seems the image size is too small so hard to see now. Needs to be "800px" as this image does.
There was a problem hiding this comment.
no, image width more than 500px
There was a problem hiding this comment.
The font on the following image smaller too
There was a problem hiding this comment.
I agree, width should increment to 800
|
|
||
| ###### 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`) |
| ###### 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 |
There was a problem hiding this comment.
What do you mean exactly "Open interpreter" ? Can we use more elaborative word in here?
| <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}`. |
There was a problem hiding this comment.
For example in database exist user
user1with 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? :)
There was a problem hiding this comment.
maybe, but it is common doc to all interpreters and the best place which I found. might be better to remove this pragraph.
|
@tinkoff-dwh Saw your latest update. As you did, 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 |
| p = p.replaceAll(String.format(markerTemplate, field.getName()), | ||
| value != null ? value.toString() : StringUtils.EMPTY); | ||
| } catch (Exception e) { | ||
| logger.error("Cannot replace context parameter", e); |
There was a problem hiding this comment.
should it stop or continue with #{name} in it if it couldn't find a match?
There was a problem hiding this comment.
if field with name name exists in context then replaced in any case
There was a problem hiding this comment.
could you add a test for that new case then?
There was a problem hiding this comment.
test testPropertyWithReplacedContextFields covers this case, replName in context is NULL and replaced with an empty string
|
Ok.
Any other comment? Merging if no more discussion.
|
…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


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?
Questions: