Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

675
Views
Postgres: array_agg arroja 'no se pueden acumular matrices vacías' para matrices vacías

Tener problemas al usar array_agg cuando una fila contiene una matriz vacía ( {} ).

Esta es mi consulta SQL:

 SELECT service_name, metric_name, array_agg(value_textarray) FROM service_data WHERE service_name = 'ActivityDataService' GROUP BY service_name, metric_name

Donde las definiciones de las columnas son las siguientes:

 service_name - text metric_name - text value_textarray - text[]

Cuando ejecuto la consulta y tengo una matriz vacía ( {} ) en la base de datos, aparece el siguiente error:

 ERROR: cannot accumulate empty arrays

¿Cómo debo hacer para arreglar esto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Tuve el mismo problema en el que no pude filtrar la matriz vacía y encontré esta función. Esta función evita el error de 'acumulación de matrices vacías'.

 CREATE AGGREGATE array_accum (anyarray) ( sfunc = array_cat, stype = anyarray, initcond = '{}' );

fuente: https://gist.github.com/ryandotsmith/4602274

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!