Class DefaultKeyValueTable
- java.lang.Object
-
- com.snowflake.connectors.common.table.DefaultKeyValueTable
-
- All Implemented Interfaces:
KeyValueTable
public class DefaultKeyValueTable extends Object implements KeyValueTable
Default implementation ofKeyValueTable.This implementation requires that the backing Snowflake table has the following structure:
- column
keyof typeSTRING - column
valueof typeVariant - column
updated_atof typeTIMESTAMP_NTZ
-
-
Field Summary
Fields Modifier and Type Field Description static intEXPRESSION_LIMITMaximum limit of inserted/updated records.
-
Constructor Summary
Constructors Constructor Description DefaultKeyValueTable(Session session, String tableName)Creates a newDefaultKeyValueTable, backed by the provided Snowflake table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(String key)Deletes the value stored under the provided key from this table.Variantfetch(String key)Fetches the value stored under the provided key.Map<String,Variant>fetchAll()Fetches all key-value pairs and returns them as a Map.List<Variant>getAllWhere(Column filter)Returns all values from this table where the record matches the provided filter.voidupdate(String key, Variant value)Updates the value stored under the provided key.voidupdateAll(List<KeyValue> keyValues)Updates the key-value pairs.voidupdateMany(List<String> ids, String fieldName, Variant fieldValue)Updates the provided field of the Variant value stored under the provided keys.
-
-
-
Field Detail
-
EXPRESSION_LIMIT
public static final int EXPRESSION_LIMIT
Maximum limit of inserted/updated records.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultKeyValueTable
public DefaultKeyValueTable(Session session, String tableName)
Creates a newDefaultKeyValueTable, backed by the provided Snowflake table.- Parameters:
session- Snowpark session objecttableName- name of the Snowflake table
-
-
Method Detail
-
fetch
public Variant fetch(String key)
Description copied from interface:KeyValueTableFetches the value stored under the provided key.- Specified by:
fetchin interfaceKeyValueTable- Parameters:
key- key associated with the value- Returns:
- value stored under the provided key
-
fetchAll
public Map<String,Variant> fetchAll()
Description copied from interface:KeyValueTableFetches all key-value pairs and returns them as a Map.- Specified by:
fetchAllin interfaceKeyValueTable- Returns:
- all key-value pairs
-
update
public void update(String key, Variant value)
Updates the value stored under the provided key.If no value is currently stored under the provided key - it will be inserted into this table.
- Specified by:
updatein interfaceKeyValueTable- Parameters:
key- key associated with the valuevalue- value- Throws:
RuntimeException- when the number of affected rows is different from 1
-
getAllWhere
public List<Variant> getAllWhere(Column filter)
Description copied from interface:KeyValueTableReturns all values from this table where the record matches the provided filter.- Specified by:
getAllWherein interfaceKeyValueTable- Parameters:
filter- filter for the table records- Returns:
- values from records which match the provided filter
-
updateMany
public void updateMany(List<String> ids, String fieldName, Variant fieldValue)
Description copied from interface:KeyValueTableUpdates the provided field of the Variant value stored under the provided keys.If no value is currently stored under the provided key - it will be ignored.
- Specified by:
updateManyin interfaceKeyValueTable- Parameters:
ids- keys associated with the valuesfieldName- name of the updated value fieldfieldValue- new value for the updated field
-
updateAll
public void updateAll(List<KeyValue> keyValues)
Description copied from interface:KeyValueTableUpdates the key-value pairs.If no value is currently stored under the provided key - it will be inserted into this table.
- Specified by:
updateAllin interfaceKeyValueTable- Parameters:
keyValues- list of key-value pairs
-
delete
public void delete(String key)
Description copied from interface:KeyValueTableDeletes the value stored under the provided key from this table.- Specified by:
deletein interfaceKeyValueTable- Parameters:
key- key associated with the value
-
-