Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

374
Visualizações
Writing a function (UDF) in SQL to auto populate Group By Numbers

In Snowflake, you can write a UDF to automate many repetitive tasks. One of which I'd like to write a function to is to automatically populate Group By 1,2,3,4,5... columns. Frankly, I am curious why no modern databases do it, cause after all, it should be relatively easy to figure out which column in the result is a dimension and which is an aggregation.

The UDF can be written in Javascript or some other kind of languages.

Any thoughts or suggestions on how I can proceed with this idea?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Such functionality is supported by dbt macros. Using a macro from a package:

select
  field_1,
  field_2,
  field_3,
  field_4,
  field_5,
  count(*)
from my_table
{{ dbt_utils.group_by(5) }}

It requires to know how many non-aggregated column exist in advance. More at: group_by


I am curious why no modern databases do it, cause after all, it should be relatively easy to figure out which column in the result is a dimension and which is an aggregation.

The closest equivalent is GROUP BY ALL from DuckDB: Friendlier SQL with DuckDB

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda