SBIN2010 commented on code in PR #45680:
URL: https://github.com/apache/superset/pull/45680#discussion_r4417760652
##########
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: {
+ ...filterClause.col,
+ columnType: 'BASE_AXIS',
+ timeGrain: filterClause.col.timeGrain || filterClause.grain,
Review Comment:
Good catch—`getSimpleSQLExpression` no longer substitutes the `label`. It
now uses `column_name` for dataset columns and `sqlExpression` for Custom SQL.
The pill’s label still displays the `label` value, but only via
`getDefaultLabel`. The SQL tab now shows `CAST(order_date AS TIMESTAMP) =
'2021-01-01T00:00:00'` instead of the `bucket_date` alias.
--
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]