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

Simplify join query in mosaic #41

Closed
willeppy opened this issue Feb 8, 2024 · 1 comment
Closed

Simplify join query in mosaic #41

willeppy opened this issue Feb 8, 2024 · 1 comment

Comments

@willeppy
Copy link
Member

willeppy commented Feb 8, 2024

Can move the distinct on out potentially if used correctly
Current is:

`(SELECT ${asRelation(table)}.* EXCLUDE ${asColumn(
      joinKey
    )}, _joinTable.* FROM ${asColumn(
      table
    )} JOIN (${q2.toString()}) _joinTable ON ${asRelation(table)}.${asColumn(
      joinKey
    )} = _joinTable.${asColumn(joinKey)} ORDER BY ${asRelation(table)}.${asColumn(joinKey)})`

Can be updated to:

`(SELECT DISTINCT ON (${asRelation(table)}.${asColumn(joinKey)}) * FROM ${asRelation(table)} JOIN ${asRelation(rightTable)} ON ${asRelation(table)}.${asColumn(joinKey)} = ${asRelation(rightTable)}.${asColumn(joinKey)})`;

But need a flag for distinct on because this causes issues right now if table order switched

@willeppy
Copy link
Member Author

Updated with new query format in willeppy/mosaic#5

This issue was closed.
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