villebro commented on code in PR #23239:
URL: https://github.com/apache/superset/pull/23239#discussion_r1121259227


##########
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilter/index.js:
##########
@@ -33,44 +34,24 @@ export const CLAUSES = {
   WHERE: 'WHERE',
 };
 
-const OPERATORS_TO_SQL = {
-  '==': '=',
-  '!=': '<>',
-  '>': '>',
-  '<': '<',
-  '>=': '>=',
-  '<=': '<=',
-  IN: 'IN',
-  'NOT IN': 'NOT IN',
-  LIKE: 'LIKE',
-  ILIKE: 'ILIKE',
-  REGEX: 'REGEX',
-  'IS NOT NULL': 'IS NOT NULL',
-  'IS NULL': 'IS NULL',
-  'IS TRUE': 'IS TRUE',
-  'IS FALSE': 'IS FALSE',
-  'LATEST PARTITION': ({ datasource }) =>
-    `= '{{ 
presto.latest_partition('${datasource.schema}.${datasource.datasource_name}') 
}}'`,
-};
-
 const CUSTOM_OPERATIONS = [...CUSTOM_OPERATORS].map(
   op => OPERATOR_ENUM_TO_OPERATOR_TYPE[op].operation,
 );
 
-function translateToSql(adhocMetric, { useSimple } = {}) {
-  if (adhocMetric.expressionType === EXPRESSION_TYPES.SIMPLE || useSimple) {
-    const { subject, comparator } = adhocMetric;
+export function translateToSql(adhocFilter, { useSimple } = {}) {

Review Comment:
   Is this code still needed if we're introducing a new util 
`translateToSQL.ts` with a similar (identical?) function?



##########
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:
##########
@@ -30,19 +30,40 @@ import {
   isFreeFormAdhocFilter,
   isSimpleAdhocFilter,
   NO_TIME_RANGE,
+  isAdhocColumn,
 } from '@superset-ui/core';
+import { Operators } from '../constants';
+import {
+  EXPRESSION_TYPES,
+  translateToSql,
+} from '../components/controls/FilterControl/AdhocFilter';
 
 const simpleFilterToAdhoc = (
   filterClause: QueryObjectFilterClause,
-  clause = 'where',
+  clause: 'WHERE' | 'HAVING' = 'WHERE',

Review Comment:
   I noticed we have this `'WHERE' | 'HAVING'` in a few places. It could be 
nice to bundle them up into a `type AdhocFilterClause = 'WHERE' | 'HAVING'` or 
similar.



-- 
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]

Reply via email to