Feature Request to MapAccum

To the TigerGraph Product Team,

I’d like to submit a feature request to enhance the MapAccum container in GSQL with three quality-of-life improvements that bring it closer to parity with Python’s native dictionary interface. These additions would meaningfully reduce boilerplate in graph queries and improve developer productivity for teams coming from a Python background.


1. get(key, default_value) — Safe Key Lookup with Default

Currently, accessing a key that does not exist in a MapAccum requires a defensive containsKey() check before every lookup, or risks undefined behavior. A get() method with an optional default value would allow safe, concise access in a single expression.

Proposed signature:
map.get(key, default_value)

Behavior:

  • If key exists, return the associated value
  • If key does not exist, return default_value without modifying the map

Python equivalent:
my_dict.get(key, default_value)

Example use case:
INT count = edge_map.get(target_id, 0);

This is particularly valuable in accumulation loops where missing keys are expected and a safe fallback is preferable to a conditional branch.


2. containsValues(value) — Value-Side Membership Test

MapAccum currently supports containsKey() for key-side lookups, but there is no equivalent for testing whether a specific value exists anywhere in the map. A containsValues() method would close this gap.

Proposed signature:
map.containsValues(value)

Behavior:

  • Returns TRUE if the specified value exists in any key-value pair in the map
  • Returns FALSE otherwise
  • Read-only; does not modify the map

Python equivalent:
value in my_dict.values()

Example use case:
IF edge_map.containsValues(“INHIBITS”) THEN …

This enables filter logic based on map contents without requiring a full iteration and manual comparison.


3. Enhanced remove(key) — Returning the Removed Value (pop() Semantics)

The current .remove(key) method deletes a key-value pair but discards the associated value. Enhancing it to return the value at the time of removal — consistent with Python’s dict.pop() — would allow the removed value to be captured and used in downstream logic without requiring a separate get() call beforehand.

Proposed behavior change:
VALUE_TYPE removed_val = map.remove(key);

  • If key exists: remove the key-value pair and return its value
  • If key does not exist: return a type-appropriate zero/null/default and leave the map unchanged

Python equivalent:
removed_val = my_dict.pop(key)

Example use case:
FLOAT score = candidate_scores.remove(node_id);
result_accum += score * weight_factor;

This is especially useful in pipeline patterns where a value must be consumed and removed atomically — for example, draining a MapAccum into a result structure during POST-ACCUM.

These three additions are individually modest in scope but collectively close a significant ergonomic gap between GSQL’s MapAccum and the dictionary semantics that Python-fluent developers expect. I believe they would reduce query complexity and lower the learning curve for developers building GraphRAG pipelines and analytics workloads on TigerGraph.

I am happy to provide additional use cases, sample GSQL queries, or testing support if helpful to the team. Thank you for considering these enhancements.

Kind Regards,

Mitch DeFelice
Founder, Custom Discoveries LLC