SBIN2010 commented on code in PR #45680:
URL: https://github.com/apache/superset/pull/45680#discussion_r4416296059
##########
superset-frontend/src/utils/simpleFilterToAdhoc.ts:
##########
@@ -75,16 +75,36 @@ export const simpleFilterToAdhoc = (
let result: AdhocFilter;
if (isAdhocColumn(filterClause.col)) {
- result = {
- expressionType: 'SQL',
- clause,
- sqlExpression: translateToSql({
- expressionType: ExpressionTypes.Simple,
- subject: `(${filterClause.col.sqlExpression})`,
+ // A grain on an adhoc expression has to stay on the column. Compiling it
+ // to raw SQL drops the grain, so the bucket is no longer truncated.
+ if (filterClause.grain) {
+ result = {
+ expressionType: 'SIMPLE',
+ clause,
operator: filterClause.op,
+ operatorId: Object.entries(OPERATOR_ENUM_TO_OPERATOR_TYPE).find(
+ operatorEntry => operatorEntry[1].operation === filterClause.op,
+ )?.[0],
+ subject: {
Review Comment:
The filter pill only read the `column_name` property from the object;
consequently, after selecting "Drill by" → "Edit chart," the result was `[P1M]
= '2021-01-01T00:00:00'`—lacking the column name. If `column_name` is missing,
the label of the ad-hoc column is used instead. There is a specific test for
this scenario, `getDefaultLabel`, which yields: `[P1M] order_date =
'2021-01-01T00:00:00'`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]