Skip to content

ZEPPELIN-289: User can now enter custom expressions in notebooks' input fields - #320

Closed
rolmovel wants to merge 2 commits into
apache:masterfrom
keedio:eval-notebook-expression
Closed

ZEPPELIN-289: User can now enter custom expressions in notebooks' input fields#320
rolmovel wants to merge 2 commits into
apache:masterfrom
keedio:eval-notebook-expression

Conversation

@rolmovel

Copy link
Copy Markdown

Actually, with Zeppelin we can use Spark SQL UDFs perfectly fine.

We developed a custom UDF library that parses absolute and relative dates. Feeding this library into Spark SQL using the standard UDF mechanism is suboptimal, since each UDF call is repeated for each row of the queried table.

Example:

select * from my_table where agg_date >= parseDate(“-5d”)

This repeats the call to parseDate(...) for every single row of 'my_table'.

Even worse, if we filter for a date range like in:

select * from my_table where agg_date >= parseDate(“-5d”) and agg_date <= parseDate(“now”)

the call to parseDate(...) is performed twice for each row in the table.

Since Spark's UDFs do not have a concept of 'execution context' we were not able to overcome the problem.

We implemented a mechanism of UDF evaluation in Zeppelin, before the query parameters are sent to the interpreter. Parametrizing queries as usual in Zeppelin, in Zeppelin's input forms you can now enter expressions like:

eval:parseDate("-5d")

or:

eval:com.company.custom.udf.UDFUtility.parseDate("-5d")

this is similar to how standard SQL works, where parameters are evaluated before being sent to the execution engine.

You can find more info in the org.apache.zeppelin.display.Evaluator javadoc.

The above mentioned query over a table of 1 million records lasts about 1 minute. Applying this PR the execution time is reduced to 15 seconds.

Rodrigo Olmo Velascoand others added 2 commits September 22, 2015 16:56
…ut fields. Expression will be evaluated server-side by Zeppelin before being sent to the interpreter.
@bzz

bzz commented Oct 6, 2015

Copy link
Copy Markdown
Member

Looks interesting, thank you for contributing!

Please help me to understand, am I right that these changes potentially affect all interpreter's syntax and code-wise are not localised to your particular use-case with spark sql?

@lucarosellini

Copy link
Copy Markdown
Contributor

Hi @bzz,
this feature is unaware of the underlying interpreter the code is being sent to, no interpreter specific code has been changed.
We've tested it successfully with spark sql, hive and markdown interpreters, it should work with any other interpreter as well.

@bzz

bzz commented Jan 5, 2016

Copy link
Copy Markdown
Member

@lucarosellini thanks for the explanation!

@rolmovel Could you merge latest master in to resolve conflicts as well as update zeppelin-distribution/src/bin_license/LICENSE with new dependencies added?

@corneadoug

Copy link
Copy Markdown
Contributor

@rolmovel If this PRs is still needed, can we try to rebase it?

@felixcheung

Copy link
Copy Markdown
Member

This looks to be an unique and important feature to have, will be great to have this in Zeppelin

@asfgitasfgit closed this in c38a0a0May 9, 2018
asfgit pushed a commit that referenced this pull request May 9, 2018
close#83close#86close#125close#133close#139close#146close#193close#203close#246close#262close#264close#273close#291close#299close#320close#347close#389close#413close#423close#543close#560close#658close#670close#728close#765close#777close#782close#783close#812close#822close#841close#843close#878close#884close#918close#989close#1076close#1135close#1187close#1231close#1304close#1316close#1361close#1385close#1390close#1414close#1422close#1425close#1447close#1458close#1466close#1485close#1492close#1495close#1497close#1536close#1545close#1561close#1577close#1600close#1603close#1678close#1695close#1739close#1748close#1765close#1767close#1776close#1783close#1799
Sign up for freeto 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.

5 participants

@rolmovel@bzz@lucarosellini@corneadoug@felixcheung