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 StringarrayConstruct(String... objects)Creates a String that wraps provided arguments in ARRAY_CONSTRUCT() function.static StringarrayConstruct(List<String> objects)Creates a String that wraps provided arguments in ARRAY_CONSTRUCT() function.static StringasCommaSeparatedSqlList(Collection<String> strings)Quotes each string usingquoteand joins them into one separated by commas.static StringasVarchar(String string)Returns the provided String wrapped in single quotes, so it can be treated as a SQL varchar.static StringasVariant(Variant variant)Returns the provided Variant changed to a JSON String and wrapped in thePARSE_JSONfunction, so it can be used as a SQL Variant.static ConnectorResponsecallProcedure(Session session, String schema, String procedureName, String... arguments)Calls the specified application procedure with the provided arguments.static VariantcallProcedureRaw(Session session, String schema, String procedureName, String... arguments)Calls the specified application procedure with the provided arguments.static ConnectorResponsecallPublicProcedure(Session session, String procedureName, String... arguments)Calls the specified application procedure, created in thePUBLICschema, with the provided arguments.static VariantcallPublicProcedureRaw(Session session, String procedureName, String... arguments)Calls the specified application procedure, created in thePUBLICschema, with the provided arguments.static Stringquoted(String string)Wraps input text with double quotes, e.g.static StringvarcharArgument(String argument)Deprecated, for removal: This API element is subject to removal in a future version.static StringvariantArgument(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 aConnectorResponseinstance.- 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
-
callProcedureRaw
public static Variant callProcedureRaw(Session session, String schema, String procedureName, String... arguments)
Calls the specified application procedure with the provided arguments.The procedure called must return a
Variantwhich will be returned.- Parameters:
session- Snowpark session objectschema- schema in which the procedure existsprocedureName- procedure namearguments- procedure arguments- Returns:
- Variant representing response from a procedure.
-
callPublicProcedure
public static ConnectorResponse callPublicProcedure(Session session, String procedureName, String... arguments)
Calls the specified application procedure, created in thePUBLICschema, with the provided arguments.The procedure called must return a
Variant, which must be possible to map into aConnectorResponseinstance.- Parameters:
session- Snowpark session objectprocedureName- procedure namearguments- procedure arguments- Returns:
- standard connector response created from the Variant returned by the procedure
-
callPublicProcedureRaw
public static Variant callPublicProcedureRaw(Session session, String procedureName, String... arguments)
Calls the specified application procedure, created in thePUBLICschema, with the provided arguments.The procedure called must return a
Variantwhich will be returned- Parameters:
session- Snowpark session objectprocedureName- procedure namearguments- procedure arguments- Returns:
- Variant
-
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
-
arrayConstruct
public static String arrayConstruct(String... objects)
Creates a String that wraps provided arguments in ARRAY_CONSTRUCT() function.- Parameters:
objects- String values that represent ARRAY_CONSTRUCT() function arguments.- Returns:
- provided values wrapped in ARRAY_CONSTRUCT() function.
-
arrayConstruct
public static String arrayConstruct(List<String> objects)
Creates a String that wraps provided arguments in ARRAY_CONSTRUCT() function.- Parameters:
objects- List of string values that represent ARRAY_CONSTRUCT() function arguments.- Returns:
- provided values wrapped in ARRAY_CONSTRUCT() function.
-
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_JSONfunction, 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_JSONfunction
-
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_JSONfunction
-
asCommaSeparatedSqlList
public static String asCommaSeparatedSqlList(Collection<String> strings)
Quotes each string usingquoteand joins them into one separated by commas.- Parameters:
strings- values to be joined- Returns:
- comma separated string
-
-