Class ReadOnlyKeyValueTable

  • All Implemented Interfaces:
    KeyValueTable

    public class ReadOnlyKeyValueTable
    extends Object
    implements KeyValueTable
    Read-only implementation of KeyValueTable. Any use of update/delete operations will trigger an UnsupportedOperationException.

    This implementation requires that the backing Snowflake table has the following structure:

    • column key of type STRING
    • column value of type Variant
    • Constructor Detail

      • ReadOnlyKeyValueTable

        public ReadOnlyKeyValueTable​(Session session,
                                     String tableName)
        Creates a new ReadOnlyKeyValueTable, backed by the provided Snowflake table.
        Parameters:
        session - Snowpark session object
        tableName - 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 interface KeyValueTable
        Parameters:
        key - key associated with the value
        Returns:
        value stored under the provided key
      • 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 interface KeyValueTable
        Parameters:
        key - key associated with the value
        value - 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 interface KeyValueTable
        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 interface KeyValueTable
        Parameters:
        ids - keys associated with the values
        fieldName - name of the updated value field
        fieldValue - 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 interface KeyValueTable
        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 interface KeyValueTable
        Parameters:
        key - key associated with the value