Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Enrich This operator can be used to enrich stream objects with information from a database.

Parameter

  • connection: The database connection to use. Look at Database Feature for a detailed description.
  • query: The SQL query that should be used to enrich den current tuple. The query can contain placeholder for variables that should come from the current input tuple. A placeholder is defined (similar to PreparedStatements in Java) with '?': "SELECT name, description FROM categories WHERE id=?". The attributes used in the SQL string are attached to the current event (here name and description)
  • attributes:A list of attributes from the input schema that should be used in the query, i.e. for each '?' there must be exactly one corresponding attribute in the list (order is important!)

 

  • outerJoin (Boolean): If for a tuple no result is found in the database, the corresponding tuple is removed. If set to true, evet with no corresponding entry in the database are not remove.
  • multiTupleOutput (Boolean):

 

  • caching (Boolean): Should elements from the datebase be cached, i.e. instead of query the database for each input element, look inside the cache first.
  • removalStrategy: If the cache reaches its limit, what is the strategy that should be used, to remove elements from the cache.
  • expirationTime: How long should elements be cached, before they are removed automatically.
  • cacheSize: How many elements should be cached
  • uniqueKeys: To optimize processing, the attributes from the database that are prime (i.e. distinct each value from each other)

Example

Code Block
languagepql
#PARSER PQL
#QUERY
out = dbenrich({connection='connectionName', query='SELECT * FROM mytable', attributes=[]}, nexmark:person))

out = dbenrich({connection='connectionName', query='SELECT name, description FROM categories WHERE id=?', attributes=['category']}, nexmark:auction))