GitHub user sanjaydasgupta opened a pull request:
https://github.com/apache/zeppelin/pull/2825
[ZEPPELIN-1967]: New pull request
### What is this PR for?
The code in this PR enables embedding/interpolating Z variables into
command strings passed to Spark's SQL and Shell interpreters. It implements the
functionality described in issue
[ZEPPELIN-1967](https://issues.apache.org/jira/browse/ZEPPELIN-1967)
This PR resumes a fresh effort while taking into consideration all of the
discussion in the context of the earlier
[PR-2502](https://github.com/apache/zeppelin/pull/2502). The earlier PR-2502
was closed due to a corruption in my repo that could not be corrected.
The code in this PR resolves all of the discussion and suggestions in the
body of the earlier [PR-2502](https://github.com/apache/zeppelin/pull/2502).
The following description is a summary of the current implementation:
Patterns of the form `{var-name}` within commands will be interpolated only
if a predefined object of the specified name exists in `z`. Additionally,
**all** such patterns within the command line should also be translatable for
any interpolation to occur. Partial translation of a command line (where only
some of the patterns are translated, and others are not) is never performed.
Patterns of the form `{{any-text}}` are translated into `{any-text}`.
These translations are performed only when all occurrences of {, }, {{, and
}} in any command string confirm to one of the two forms described above. A
command containing { and/or } characters used in any other way (than
`{var-name}` and `{{any-text}}` described above) is used as-is without any
changes.
No error is flagged in any case. This behavior is identical to the
implementation of a similar feature in
Jupyter's shell invocation using the ! magic command.
At present only the SQL and Shell interpreters support object
interpolation.
### What type of PR is it?
[Improvement]
### Todos
* [ ] - Task
### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1967
### How should this be tested?
A new unit-test class
([ZeppCtxtVariableTest.java](https://github.com/apache/zeppelin/compare/master...sanjaydasgupta:master#diff-ad942153fbbad8ac1954b1063eabf920))
has been added. The attached screenshots also show tests of the functionality.
### Screenshots (if appropriate)
![figure-1](https://user-images.githubusercontent.com/477015/36888230-9104d3c4-1e1a-11e8-9399-f98b1246730b.png)
![figure-2](https://user-images.githubusercontent.com/477015/36888237-96843bbe-1e1a-11e8-80ac-4bdfe94ead22.png)
![figure-3](https://user-images.githubusercontent.com/477015/36888240-99fe9c3a-1e1a-11e8-9aa0-9faa32c0fa19.png)
![figure-4](https://user-images.githubusercontent.com/477015/36888246-9dd86f34-1e1a-11e8-8151-4ece9d8af8e8.png)
![figure-5](https://user-images.githubusercontent.com/477015/36888251-a1d21644-1e1a-11e8-8431-c5e59773f60c.png)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? Yes, detailed documentation has been added
to the part describing ZeppelinContext variables.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sanjaydasgupta/zeppelin master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/zeppelin/pull/2825.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2825
commit a570cf45150303d9effe5a2b2fa09b8611c6312d
Author: Sanjay Dasgupta
Date: 2018-03-02T07:13:14Z
ZEPPELIN-1967: New pull request
---