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
In LogAggregator, allow the use of a complex dimension w/ an already defined select as. #13729
Conversation
…defined select as.
// if function, do not alias or prefix | ||
if ($this->isFieldFunctionOrComplexExpression($field)) { | ||
$selectAsString = $appendSelectAs = false; | ||
} else if ($this->isFieldFunctionOrComplexExpression($field)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a unit/integration test. the system tests should show a difference (I haven't copied the files over)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just reading https://dev.mysql.com/doc/refman/8.0/en/select.html ... the AS
is optional. I suppose we don't bother about this for now until this is a use case? Be best I think...
does the regex need to check it case insensitive?
also just double checked there cannot be two AS statements in there cause we have an entry for each dimension... just fyi ... was wondering about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR isn't about requiring the AS
, it's about detecting when it's there and just using it instead of assigning a new one. It's a workaround for when a complex sql expression is used as a dimension, which currently doesn't work since it just gets duplicated in both the select & group by parts.
Since it has to be used explicitly by a plugin developer, I think we don't have to check for uniqueness of the AS, since there will be an error and it will be programmer error.
Should be a case insensitive check, will look into that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR isn't about requiring the AS,
I meant if someone used foo bar
we wouldn't detect the bar
alias. All good though and not needed to be detected right now.
FYI @tsteur assuming this is ok to merge, let me know if it needs another change, will make it in another PR |
This change allows the use of complex expressions as dimensions. Currently if someone uses, eg, a complex
CASE WHEN ... END
statement as a dimension, it will be duplicated in the select and in the group by of the query. This will allow users to add their own alias likeCASE WHEN ... END AS blahblah
, which will appear in the select as the entireCASE WHEN ...
but asblahblah
in the group by.Also includes a
hasTable($table)
method addition to DataTable\Map so we can check if a table exists w/o triggering an error w/ getTable.