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

fix: wildcard expand + group by doesnt skip expand #990

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

patricebender
Copy link
Member

No description provided.

Comment on lines +799 to +800
const wildcardIndex = column.expand.findIndex(e => e === '*')
if (wildcardIndex === -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const wildcardIndex = column.expand.findIndex(e => e === '*')
if (wildcardIndex === -1) {
if (column.expand.includes('*')) {

Copy link
Contributor

@danjoa danjoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that mean that:

  1. For SELECT Items {*} from Orders group by Items.ID we would not skip the expand?
  2. For SELECT Items { ID } from Orders group by Items.ID we would skip the expand?

→ still seems wrong

@danjoa
Copy link
Contributor

danjoa commented Jan 28, 2025

As discussed we need to revisit the way we translate OData $apply requests to valid queries, and have those queries translated to native SQL without any assumption of its origin from OData. → bed7329 adds comments to relevant tests about expected valid queries.

@danjoa
Copy link
Contributor

danjoa commented Jan 28, 2025

Moreover, and more importantly, we have to ensure that we correctly implement group by, also for things which OData cannot express. In particular, for expands of to-many associations like that:

SELECT from Orders {
   ID, sum (Items.product.price * Items.quantity) as total,
   Items { product.name, quantity }
} group by ID

@patricebender
Copy link
Member Author

As discussed we need to revisit the way we translate OData $apply requests to valid queries, and have those queries translated to native SQL without any assumption of its origin from OData. → bed7329 adds comments to relevant tests about expected valid queries.

Agree 👍

Moreover, and more importantly, we have to ensure that we correctly implement group by, also for things which OData cannot express. In particular, for expands of to-many associations like that:

SELECT from Orders {
   ID, sum (Items.product.price * Items.quantity) as total,
   Items { product.name, quantity }
} group by ID

Also agree, however I would make vote for a two step approach:

  1. revert changes in db-service which implemented OData stuff on cqn transformation level, to be OData agnostic again → coordinate with runtime to make the OData adapter come up with a proper CQN which is then transformed as usual.
  2. Come up with a plan to implement group by, which also depends on the actual DB-Driver we are talking to

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

Successfully merging this pull request may close these issues.

2 participants