[
https://issues.apache.org/jira/browse/CALCITE-4087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17143499#comment-17143499
]
Farid Zakaria edited comment on CALCITE-4087 at 6/24/20, 4:11 AM:
------------------------------------------------------------------
Great addition and something I was trying to achieve in similar fashion.
I think a good inclusion to the documentation of _Hoist_ would be to draw
parallels to prepared statements.
Furthermore some pre-canned Functions might make good inclusions for instance
{code:java}
private static final Function<Variable,String> TO_ORDINAL_VAR_STR = v -> ?" +
v.ordinal;{code}
{code:java}
// not sure the correct Calcite code here
private static final Function<Variable, String> ONLY_STR = fn -> v -> if
(v.getType() == CHAR) { v.toValue(); } else { fn(v) }
{code}
was (Author: fzakaria):
Great addition and something I was trying to achieve in similar fashion.
I think a good inclusion to the documentation of _Hoist_ would be to draw
parallels to prepared statements.
Furthermore some pre-canned Functions might make good inclusions for instance
```
private static final Function<Variable,String> TO_ORDINAL_VAR_STR = v -> ?" +
v.ordinal;
// not sure the correct Calcite code here
private static final Function<Variable, String> ONLY_STR = fn -> v -> if
(v.getType() == CHAR) \{ v.toValue(); } else \{ fn(v) };
```
> Hoist, a utility to replace literals in a SQL string with placeholders
> ----------------------------------------------------------------------
>
> Key: CALCITE-4087
> URL: https://issues.apache.org/jira/browse/CALCITE-4087
> Project: Calcite
> Issue Type: New Feature
> Components: babel
> Affects Versions: 1.23.0
> Reporter: Julian Hyde
> Assignee: Julian Hyde
> Priority: Major
>
> Add "Hoist", a utility to replace literals in a SQL string with placeholders.
> By default it uses Calcite's parser, but you can configure to use different
> quoting, casing, and also to use a different parser such as Babel for other
> dialects of SQL.
> It generates a data structure, {{Hoisted}}, that contains a map of where the
> literals occur within the SQL string. The Hoisted.substitute method generates
> an alternative SQL string, replacing the literals with a custom string.
> It does not call {{SqlNode.unparse}}, and therefore does not lose any of the
> original formatting.
> For more examples, see tests added to {{SqlParserTest}} and
> {{BabelParserTest}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)