@Value.Enclosing public class Hoist extends Object
Simple use:
final String sql =
"select 'x' from emp where deptno < 10";
final Hoist.Hoisted hoisted =
Hoist.create(Hoist.config()).hoist();
print(hoisted); // "select ?0 from emp where deptno < ?1"
Calling Hoist.Hoisted.toString() generates a string that is similar to
SQL where a user has manually converted all constants to bind variables, and
which could then be executed using PreparedStatement.execute().
That is not a goal of this utility, but see
[CALCITE-963]
Hoist literals.
For more advanced formatting, use Hoist.Hoisted.substitute(Function).
Adjust Hoist.Config to use a different parser or parsing options.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Hoist.Config
Configuration.
|
static class |
Hoist.Hoisted
Result of hoisting.
|
static class |
Hoist.Variable
Variable.
|
| Modifier and Type | Method and Description |
|---|---|
static Hoist.Config |
config()
Creates a Config.
|
static Hoist |
create(Hoist.Config config)
Creates a Hoist.
|
Hoist.Hoisted |
hoist(String sql)
Hoists literals in a given SQL string, returning a
Hoist.Hoisted. |
static String |
ordinalString(Hoist.Variable v)
Converts a
Hoist.Variable to a string "?N",
where N is the Hoist.Variable.ordinal. |
static String |
ordinalStringIfChar(Hoist.Variable v)
Converts a
Hoist.Variable to a string "?N",
where N is the Hoist.Variable.ordinal,
if the fragment is a character literal. |
public static Hoist.Config config()
public static Hoist create(Hoist.Config config)
public static String ordinalString(Hoist.Variable v)
Hoist.Variable to a string "?N",
where N is the Hoist.Variable.ordinal.public static String ordinalStringIfChar(Hoist.Variable v)
Hoist.Variable to a string "?N",
where N is the Hoist.Variable.ordinal,
if the fragment is a character literal. Other fragments are unchanged.public Hoist.Hoisted hoist(String sql)
Hoist.Hoisted.Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.