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
key
of typeSTRING
- column
value
of 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 void
delete(String key)
Deletes the value stored under the provided key from this table.Variant
fetch(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.void
update(String key, Variant value)
Updates the value stored under the provided key.void
updateAll(List<KeyValue> keyValues)
Updates the key-value pairs.void
updateMany(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:KeyValueTable
Fetches the value stored under the provided key.- Specified by:
fetch
in 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:KeyValueTable
Fetches all key-value pairs and returns them as a Map.- Specified by:
fetchAll
in interfaceKeyValueTable
- Returns:
- all key-value pairs
-
update
public void update(String key, Variant value)
Description copied from interface:KeyValueTable
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:
update
in interfaceKeyValueTable
- Parameters:
key
- key associated with the valuevalue
- value
-
getAllWhere
public List<Variant> getAllWhere(Column filter)
Description copied from interface:KeyValueTable
Returns all values from this table where the record matches the provided filter.- Specified by:
getAllWhere
in 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:KeyValueTable
Updates 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:
updateMany
in 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:KeyValueTable
Updates the key-value pairs.If no value is currently stored under the provided key - it will be inserted into this table.
- Specified by:
updateAll
in interfaceKeyValueTable
- Parameters:
keyValues
- list of key-value pairs
-
delete
public void delete(String key)
Description copied from interface:KeyValueTable
Deletes the value stored under the provided key from this table.- Specified by:
delete
in interfaceKeyValueTable
- Parameters:
key
- key associated with the value
-
-