gianm opened a new pull request #7327: SQL: Add STRING_FORMAT function.
URL: https://github.com/apache/incubator-druid/pull/7327
 
 
   ### Motivation
   
   String formatting is a useful function in general. This also provides the 
reverse of https://github.com/apache/incubator-druid/pull/7326's ability to 
parse hexadecimal strings, since `%x` can be used to convert back in the other 
direction.
   
   ### Proposed changes
   
   - Add a `format` Druid expression function (see math-expr.md for docs)
   - Add a `STRING_FORMAT` Druid SQL function (see sql.md for docs)
   
   Both functions have a required argument (pattern) and a variable number of 
optional arguments (format parameters). Both return `null` if the pattern is 
null. Both suppress errors in the manner of `StringUtils.nonStrictFormat` 
(since they use this under the hood).
   
   ### Rationale
   
   I think the function is self evidently useful, but there are some different 
ways it could have been implemented. I could have used strict formatting rather 
than non-strict formatting, but decided to go with non-strict to avoid failing 
the entire query if the format is bad or if some input data is bad.
   
   I could have added an option to specify the locale, but decided not to, 
mostly because I don't need it right now. This could be added in a future patch 
if anyone needs it.
   
   ### Operational impact
   
   None.
   
   ### Test plan
   
   Unit tests.
   
   ### Future work
   
   Add support for formatting in different locales.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to