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

Ability to "soft rename" fields #127

Closed
vruusmann opened this issue Sep 4, 2018 · 2 comments
Closed

Ability to "soft rename" fields #127

vruusmann opened this issue Sep 4, 2018 · 2 comments

Comments

@vruusmann
Copy link
Member

Some application environments do not support JPMML-style field names.

For example, all JPMML conversion libraries use a pattern probability(<category level>) for naming probability fields, which is known to crash Apache Hive query parser:
jpmml/jpmml-converter#10
jpmml/jpmml-evaluator-hive#2

The JPMML-Evaluator library should provide API for "soft renaming" fields. Here, "soft rename" means that the field is given a different name/alias at the logical JPMML-Evaluator library level, but not at the physical PMML document level.

Perhaps, class org.jpmml.evaluator.ModelField should treat the name property as mutable, and offer a #setName() method (in addition to the #getName() method). Application developers could then soft rename fields like this:

org.jpmml.evaluator.OutputField outputField = outputFields.get(0);

if(("probability(0)").equals(outputField.getName().getValue())){
  outputField.setName(FieldName.create("probability_0"));
}
@PakhomovAlexander
Copy link

PakhomovAlexander commented Oct 10, 2018

Hello! Does this issue have some pitfalls? Or it will be enough to add one method #setName() and test it.

@vruusmann
Copy link
Member Author

Does this issue have some pitfalls?

None that I'm aware of - it a matter of defining a org.jpmml.evaluator.ModelField#name property, which can then be get and set by accessor methods. If the property is not set (ie. null), then the getter method should fall back to returning getDataField().getName().

I just don't have time to work on the JPMML-Evaluator project right now. If I ever get a chance to do so, then I will implement a nice set of other enhancements too. Most notably, there is going to be an EvaluatorBuilder class for creating and configuring org.jpmml.evaluator.Evaluator instances properly; the ability to soft-rename argument and result fields (probably using some withSoftRenamedFields(Pattern) builder method) is a sub-task of it.

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