[
https://issues.apache.org/jira/browse/SAMZA-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16502665#comment-16502665
]
ASF GitHub Bot commented on SAMZA-1740:
---------------------------------------
GitHub user atoomula opened a pull request:
https://github.com/apache/samza/pull/545
SAMZA-1740: Moving SamzaSqlRelRecord to samza-api as it is needed to be
used in UDFs
Please see description in the ticket.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/atoomula/samza sql
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/samza/pull/545.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 #545
----
commit 2783ac2fd27cf56e1d7e0f6259e39f46919a3f7a
Author: Aditya Toomula <atoomula@...>
Date: 2018-06-05T23:53:00Z
Moving SamzaSqlRelRecord to samza-api as it is needed to be used in UDFs.
----
> Samza-sql: Move SamzaSqlRelRecord class out of SamzaSqlRelMessage (for UDFs).
> -----------------------------------------------------------------------------
>
> Key: SAMZA-1740
> URL: https://issues.apache.org/jira/browse/SAMZA-1740
> Project: Samza
> Issue Type: Bug
> Reporter: Aditya
> Priority: Major
>
> For app users to extract nested fields from avro records, they need to write
> their own UDFs. For that, they will have to refer to avro records as Java
> types that Samza SQL translates to and uses, and not as Avro GenericRecord.
> In Samza-sql, we convert GenericRecord to SamzaSqlRelRecord. Currently,
> SamzaSqlRelRecord is an inner class of SamzaSqlRelMessage. Considering that
> we are making these Java types be directly usable by app writers in UDFs, we
> will have to make SamzaSqlRelRecord an independent class. We will also have
> to move this class to Samza api module.
> An example of how SamzaSqlRelRecord could be used in UDF to extract pageKey
> from PageViewEvent is below:
> /**
> *UDF that fetches the brooklin envelope metadata value, given a fieldName.
> */
> public class GetPageKeyUdf implements ScalarUdf<String> {
> @Override
> public void init(Config udfConfig) {
> }
> @Override
> public String execute(Object... args) {
> SamzaSqlRelRecord record = (SamzaSqlRelRecord) args[0];
> Optional<Object> fieldValue = Optional.empty();
> if (record != null)
> { fieldValue = record.getField("pageKey"); }
> if (fieldValue.isPresent())
> { return fieldValue.get().toString(); }
> return null;
> }
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)