Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align the source and sink behaviours using the @attributes annotation #81

Open
pierre-borckmans opened this issue Oct 30, 2019 · 1 comment

Comments

@pierre-borckmans
Copy link

Description:
Currently, the @attributes annotation cannot be used with sinks the same way they can be used with sources.

For instance, this mapping

@map(type='json', enclosing.element="$ @attributes(symbol = "company.symbol", price = "price", volume = "volume"))

would correctly parse the following json, when used on a source:

{
    "company" : {
        "symbol": "AAPL"
    },
    "price": 1234,
    "volume": 1000
}

but does not work when used one a sink, to produce the same json from for instance the following stream:

define stream TestStream(symbol string, price int, volume int)
@suhothayan
Copy link
Contributor

@pierre-borckmans currently the option we have for sinks is to use @payload

@sink(type='...',  
        @map(type='json', enclosing.element='$',
                    @payload( """
{
    "company" : {
        "symbol": "{{symbol}}"
    },
    "price": {{price}},
    "volume": {{volume}}
}""")))
define stream BarStream (symbol string, price float, volume long);

We'll try to incorporate your suggestion in future releases by constructing the JSON from XPath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants