Class SQLInterpolator
java.lang.Object
com.databricks.jdbc.common.util.SQLInterpolator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringinterpolateSQL(String sql, Map<Integer, ImmutableSqlParameter> params) Interpolates the given SQL string by replacing placeholders with the provided parameters.static StringSurrounds unquoted placeholders (?)
-
Constructor Details
-
SQLInterpolator
public SQLInterpolator()
-
-
Method Details
-
interpolateSQL
public static String interpolateSQL(String sql, Map<Integer, ImmutableSqlParameter> params) throws DatabricksValidationExceptionInterpolates the given SQL string by replacing placeholders with the provided parameters.This method splits the SQL string by placeholders (question marks) and replaces each placeholder with the corresponding parameter from the provided map. The map keys are 1-based indexes, aligning with the SQL parameter positions.
- Parameters:
sql- the SQL string containing placeholders ('?') to be replaced.params- a map of parameters where the key is the 1-based index of the placeholder in the SQL string, and the value is the correspondingImmutableSqlParameter.- Returns:
- the interpolated SQL string with placeholders replaced by the corresponding parameters.
- Throws:
DatabricksValidationException- if the number of placeholders in the SQL string does not match the number of parameters provided in the map.
-
surroundPlaceholdersWithQuotes
-