Class SqlTools
- java.lang.Object
-
- com.snowflake.connectors.util.sql.SqlTools
-
public class SqlTools extends Object
Set of basic SQL utilities.
-
-
Constructor Summary
Constructors Constructor Description SqlTools()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
asCommaSeparatedSqlList(Collection<String> strings)
Quotes each string usingquote
and joins them into one separated by commas.static String
asVarchar(String string)
Returns the provided String wrapped in single quotes, so it can be treated as a SQL varchar.static String
asVariant(Variant variant)
Returns the provided Variant changed to a JSON String and wrapped in thePARSE_JSON
function, so it can be used as a SQL Variant.static ConnectorResponse
callProcedure(Session session, String schema, String procedureName, String... arguments)
Calls the specified application procedure with the provided arguments.static ConnectorResponse
callPublicProcedure(Session session, String procedureName, String... arguments)
Calls the specified application procedure, created in thePUBLIC
schema, with the provided arguments.static String
quoted(String string)
Wraps input text with double quotes, e.g.static String
varcharArgument(String argument)
Deprecated, for removal: This API element is subject to removal in a future version.static String
variantArgument(Variant variant)
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
-
Method Detail
-
callProcedure
public static ConnectorResponse callProcedure(Session session, String schema, String procedureName, String... arguments)
Calls the specified application procedure with the provided arguments.The procedure called must return a
Variant
, which must be possible to map into aConnectorResponse
instance.- Parameters:
session
- Snowpark session objectschema
- schema in which the procedure existsprocedureName
- procedure namearguments
- procedure arguments- Returns:
- standard connector response created from the Variant returned by the procedure
-
callPublicProcedure
public static ConnectorResponse callPublicProcedure(Session session, String procedureName, String... arguments)
Calls the specified application procedure, created in thePUBLIC
schema, with the provided arguments.The procedure called must return a
Variant
, which must be possible to map into aConnectorResponse
instance.- Parameters:
session
- Snowpark session objectprocedureName
- procedure namearguments
- procedure arguments- Returns:
- standard connector response created from the Variant returned by the procedure
-
asVarchar
public static String asVarchar(String string)
Returns the provided String wrapped in single quotes, so it can be treated as a SQL varchar.If the provided String contains any single quote characters - they are escaped with a backslash character.
- Parameters:
string
- String value- Returns:
- provided value escaped and wrapped in single quotes
-
varcharArgument
@Deprecated(since="2.1.0", forRemoval=true) public static String varcharArgument(String argument)
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, useasVarchar(String)
instead.- Parameters:
argument
- String value- Returns:
- provided value escaped and wrapped in single quotes
-
asVariant
public static String asVariant(Variant variant)
Returns the provided Variant changed to a JSON String and wrapped in thePARSE_JSON
function, so it can be used as a SQL Variant.- Parameters:
variant
- Variant value- Returns:
- provided value changed to a JSON String and wrapped in the
PARSE_JSON
function
-
variantArgument
@Deprecated(since="2.1.0", forRemoval=true) public static String variantArgument(Variant variant)
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, useasVariant(Variant)
instead.- Parameters:
variant
- Variant value- Returns:
- provided value changed to a JSON String and wrapped in the
PARSE_JSON
function
-
asCommaSeparatedSqlList
public static String asCommaSeparatedSqlList(Collection<String> strings)
Quotes each string usingquote
and joins them into one separated by commas.- Parameters:
strings
- values to be joined- Returns:
- comma separated string
-
-