-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add support for protected types in JSONToTuple #12
Comments
FWIW, I did this for the text toolkit. |
@hildrum how did you implement it? |
It looks like it's not a documented feature. Oops, gotta update that. I picked a quotePrefix |
ok, i had something similar in the earlier version of the JSON operators. However I dont find that to be an elegant solution. I was thinking that the operator could accept parameters that could be in key=value format. Here key would be the JSON attribute name and the value would be its mapping to the corresponding tuple type. This should give more flexibility in attribute naming. e.g. Thoughts? |
I think that's a good, more general, solution. We have something similar proposed for HBASE: |
The attributeMap parameter approach sounds good. A related but slightly different mechanism is used in the Mining toolkit: Not a single parameter whose value is a map, but one operator parameter for each model parameter. I can't fully articulate the pros and cons of the two approaches, but I think the single parameter with a map value (the one proposed here) is cleaner. There's something weird about parameters that are not predefined in the operator model. Last I checked, this feature is still missing. Is this likely to move forward? Who is maintaining this toolkit now? |
I'm the one maintaining the toolkit. But since this issue hadn't been commented on for a year, I didn't think there was anyone who could use this feature. Is this something you need? |
Recently I was building a demo using FAA airport data, which included an element called "type". I found myself having to massage the JSON string before converting it:
That works, but has workaround written all over it. I had used an earlier version of the toolkit back in 2013 and was wondering what had happened to the protected-prefix parameter I remembered seeing (but did not need at the time). To be honest, I failed to find this discussion thread. So "need" is relative, but I've only used JSON parsing twice and needed something like it 50% of the time. (And no, I'm not taking that statistic seriously.) I'd say, it's a very nice-to-have. |
I'll try to get the feature in sometime soon, then. I think the way it'd work is that you'd specify |
+1 for adding this feature. Just wondering whether there is a best-practice way of implementing a map-like parameter. Here it seems that you're thinking of a string containing a list of expressions that you have to custom-parse. Would an SPL map literal make sense? I did not do an exhaustive search of other operators but maybe the compiler team has suggestions. |
What's best practice depends on whether you're talking about a Java primitive operator or a C++ primitive operator. Java operators don't support parameters that are maps or tuples, so we end up having to work around that with strings. If this were a C++ primitive operator, we could use maps, but I'd probably take a different approach and use custom output functions, so it'd be something like
|
Makes sense. Thanks. |
I had this issue with a JSON file that contains {type:"xxx" and timestamp:"1234567"}. Then having to tweak the java code to check the _type and _timestamp
|
Operators should handle this similar to the XML parse operator with the ignorePrefix parameter |
Closing after merge of Mark's changes. |
For examples this is a valid json
{ "rstring" : "mystring", "type" : "mytype" }
However there is no tuple structure that will allow for this json to be mapped since rstring and type are SPL protected names that cannot be used as attribute names in tuples.
We need a way to have these type of attributes accessible.
The text was updated successfully, but these errors were encountered: