GitHub user wgmayer0 created a discussion: Simplify this query and remove 
redundancy

```
SELECT json_build_object(
  a_label::text, a::text,
  b_label::text, b::text,
  c_label::text, c::text,
  d_label::text, d::text,
  e_label::text, e::text,
  f_label::text, f::text
)
FROM cypher('hermech', $$
  MATCH (a:contact_name)
  OPTIONAL MATCH (a)-[:DIRECT_EMAIL_ADDRESS]->(b:direct_email_address)
  OPTIONAL MATCH (a)<-[:CONTACT_NAME]-(c:account_name)
  OPTIONAL MATCH (c)-[:MAIN_PHONE_NUMBER]->(d:main_phone_number)
  OPTIONAL MATCH (c)-[:MAIN_STREET_ADDRESS]->(e:main_street_address)
  OPTIONAL MATCH (c)-[:MAIN_DOMAIN]->(f:main_domain)
  WHERE id(a) = ${id}
  RETURN
    head(labels(a)) AS a_label,
    a.value AS a,
    head(labels(b)) AS b_label,
    b.value AS b,
    head(labels(c)) AS c_label,
    c.value AS c,
    head(labels(d)) AS d_label,
    d.value AS d,
    head(labels(e)) AS e_label,
    e.value AS e,
    head(labels(f)) AS f_label,
    f.value AS f
$$) AS (
  a_label agtype, 
  a agtype, 
  b_label agtype, 
  b agtype,
  c_label agtype,
  c agtype,
  d_label agtype,
  d agtype,
  e_label agtype,
  e agtype,
  f_label agtype,
  f agtype
```

Is there a way to get rid of all of the redundancy? Is it possible to simplify 
this query? Also am I able to remove null keys from the final json object 
returned?

GitHub link: https://github.com/apache/age/discussions/2226

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to