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(core): exclude relationship column and calculated field when selecting all in the analysis result #740

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

goldmedal
Copy link
Contributor

@goldmedal goldmedal commented Aug 8, 2024

Description

close #738
In the normal query, both relationship and calculated field won't be selected when selecting all from a model. We should also exclude them in the analysis result.

assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0).getSelectItems().size()).isEqualTo(1);
assertThat(result.get(0).getSelectItems().get(0).getExpression()).isEqualTo("customer_name");
assertThat(result.get(0).getSelectItems().get(0).getExprSources()).isEqualTo(List.of(new ExprSource("customer_name", "orders", "customer_name", new NodeLocation(1, 8))));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We won't dig into the expression of a calculated field. So, in the exprSource, we only provide itself.

assertThat(result.get(0).getSelectItems().get(0).getExpression()).isEqualTo("customer_name");
assertThat(result.get(0).getSelectItems().get(0).getExprSources()).isEqualTo(List.of(new ExprSource("customer_name", "orders", "customer_name", new NodeLocation(1, 8))));

statement = parseSql("SELECT customer FROM orders");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A relationship column can't be selected directly. we won't fail the case to make the query stable. However, it's an invalid query for Wren engine.

Copy link
Contributor

@grieve54706 grieve54706 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @goldmedal.

@grieve54706
Copy link
Contributor

grieve54706 commented Aug 12, 2024

Hi @goldmedal, does this pr resolve #738? If it is, would you be able to connect the issue?

@goldmedal
Copy link
Contributor Author

Hi @goldmedal, does this pr resolve #738? If it is, would you be able to connect the issue?

Thanks. I have linked the issues.

@grieve54706 grieve54706 merged commit 9784c85 into main Aug 12, 2024
9 checks passed
@grieve54706 grieve54706 deleted the bugfix/738-analysis-no-relationship branch August 12, 2024 09:49
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

selectItems contain relationship type column results in sql analysis api
2 participants