Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server does not support array_agg #15

Open
danskarda opened this issue Mar 10, 2022 · 0 comments
Open

SQL Server does not support array_agg #15

danskarda opened this issue Mar 10, 2022 · 0 comments

Comments

@danskarda
Copy link
Collaborator

to-many-join-column-query uses array_agg to fetch references with cardinality :many. It returns one row with id and array of referenced ids. Unfortunately some SQL databases does not implement array_agg. [1] [2]

How can the solution look like?

  1. Move GROUP_BY from SQL to clojure group-by
  2. Move to-many into VendorAdapters, use array_agg for adapters which support it and
    a. use string_agg in SQL and str/split in Clojure and use attributes to distinguish between numbers and uuids
    b. go fancy and use XML paths as suggested in [2]

My personal taste is to prefer simple solution over magic and advanced features. I might be wrong but the overhead of moving group-by to Clojure should not be large. You get the same data, but you have to process more rows in resulting dataset.

2a can be tricky and must rely on attribute definition to distinguish numbers and uuids.
2b is too fancy for me.

What kind of patch you would like to see?

[1] https://www.sqlshack.com/implement-array-like-functionality-sql-server/
[2] https://jeremy-dohmann.medium.com/performing-array-aggregations-in-microsoft-sql-server-with-xml-path-9a36a7fe33be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant