You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by "Mark Payne (JIRA)" <ji...@apache.org> on 2015/12/04 14:30:10 UTC

[jira] [Updated] (NIFI-1249) Allow ReplaceText expression language functions to access matching group values

     [ https://issues.apache.org/jira/browse/NIFI-1249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Payne updated NIFI-1249:
-----------------------------
    Description: 
Chanru from the user's mailing list asked how we'd support a pretty simple use case of converting 

{quote}
col1,col2,col3
2006,10-01-2004,10may2004
2007,15-05-2006,10jun2005
2009,8-8-2008,10aug2008
{quote}

to this

{quote}
col1,col2,col3
2006,10-01-2004,2004-05-10
2007,15-05-2006,2005-06-10
2009,8-8-2008,2008-08-10
{quote}

And we can do it today but it is surprising more effort than it should be.  The problem is that ReplaceText as-is gets us sooo close.  But what it cannot do is convert the original column three into a formatted Date object which can then be written out as a formatted string.  If it could then this would be easy.  So for example if we extracted each column as a matching group and the replacement value could be

{code}
${ $3:toDate('ddMMMyyy'):format('yyyy/MM/ddd')}
{code}

Then we'd be all set.  But right now there is no way to take that third matching group and do anything fun with expression language on it because it is not a subject passed into the EL on which functions could be applied.  If instead we simply added those matching groups as keys/subjects available to the EL then this becomes a quite powerful tool.


  was:
Chanru from the user's mailing list asked how we'd support a pretty simple use case of converting 

{quote}
col1,col2,col3
2006,10-01-2004,10may2004
2007,15-05-2006,10jun2005
2009,8-8-2008,10aug2008
{quote}

to this

{quote}
col1,col2,col3
2006,10-01-2004,2004-05-10
2007,15-05-2006,2005-06-10
2009,8-8-2008,2008-08-10
{quote}

And we can do it today but it is surprising more effort than it should be.  The problem is that ReplaceText as-is gets us sooo close.  But what it cannot do is convert the original column three into a formatted Date object which can then be written out as a formatted string.  If it could then this would be easy.  So for example if we extracted each column as a matching group and the replacement value could be

{quote}
${ $3:toDate('ddMMMyyy'):format('yyyy/MM/ddd')}
{quote}

Then we'd be all set.  But right now there is no way to take that third matching group and do anything fun with expression language on it because it is not a subject passed into the EL on which functions could be applied.  If instead we simply added those matching groups as keys/subjects available to the EL then this becomes a quite powerful tool.



> Allow ReplaceText expression language functions to access matching group values
> -------------------------------------------------------------------------------
>
>                 Key: NIFI-1249
>                 URL: https://issues.apache.org/jira/browse/NIFI-1249
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Joseph Witt
>
> Chanru from the user's mailing list asked how we'd support a pretty simple use case of converting 
> {quote}
> col1,col2,col3
> 2006,10-01-2004,10may2004
> 2007,15-05-2006,10jun2005
> 2009,8-8-2008,10aug2008
> {quote}
> to this
> {quote}
> col1,col2,col3
> 2006,10-01-2004,2004-05-10
> 2007,15-05-2006,2005-06-10
> 2009,8-8-2008,2008-08-10
> {quote}
> And we can do it today but it is surprising more effort than it should be.  The problem is that ReplaceText as-is gets us sooo close.  But what it cannot do is convert the original column three into a formatted Date object which can then be written out as a formatted string.  If it could then this would be easy.  So for example if we extracted each column as a matching group and the replacement value could be
> {code}
> ${ $3:toDate('ddMMMyyy'):format('yyyy/MM/ddd')}
> {code}
> Then we'd be all set.  But right now there is no way to take that third matching group and do anything fun with expression language on it because it is not a subject passed into the EL on which functions could be applied.  If instead we simply added those matching groups as keys/subjects available to the EL then this becomes a quite powerful tool.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)