Class ReadOnlyKeyValueTable
- java.lang.Object
-
- com.snowflake.connectors.common.table.ReadOnlyKeyValueTable
-
- All Implemented Interfaces:
KeyValueTable
public class ReadOnlyKeyValueTable extends Object implements KeyValueTable
Read-only implementation ofKeyValueTable. Any use of update/delete operations will trigger anUnsupportedOperationException.This implementation requires that the backing Snowflake table has the following structure:
- column
keyof typeSTRING - column
valueof typeVariant
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyKeyValueTable(Session session, String tableName)Creates a newReadOnlyKeyValueTable, 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.
-
-
-
Constructor Detail
-
ReadOnlyKeyValueTable
public ReadOnlyKeyValueTable(Session session, String tableName)
Creates a newReadOnlyKeyValueTable, 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)
Description copied from interface:KeyValueTableUpdates 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
-
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
-
-