dosubot[bot] commented on issue #30391:
URL: https://github.com/apache/superset/issues/30391#issuecomment-2377229875

   <!-- Answer -->
   To use the `getDataRecordFormatter` function for consistent boolean string 
formatting in Superset, you will need to customize the frontend code. Since you 
are running Superset via Helm in Kubernetes and using `values.yaml` with 
`configOverrides`, you can follow these steps:
   
   1. **Create a Custom JavaScript File**:
      Create a custom JavaScript file that uses the `getDataRecordFormatter` 
function to format your boolean values.
   
      ```ts
      // customFormatter.js
      import { getDataRecordFormatter, GenericDataType } from 
'src/filters/utils';
      import { TRUE_STRING, FALSE_STRING } from 'src/utils/common';
   
      const formatter = getDataRecordFormatter();
   
      export function formatBooleanValues(value) {
        return formatter(value, GenericDataType.Boolean);
      }
      ```
   
   2. **Modify the Superset Configuration**:
      Use the `configOverrides` in your `values.yaml` to include this custom 
JavaScript file in your Superset deployment.
   
      ```yaml
      configOverrides:
        CUSTOM_JS: "/app/pythonpath/customFormatter.js"
      ```
   
   3. **Update the Superset Frontend**:
      Ensure that your custom JavaScript file is loaded and used in the 
Superset frontend. You might need to modify the frontend code to import and use 
your custom formatter function where necessary.
   
   4. **Deploy the Changes**:
      Deploy your changes by updating your Helm chart and applying the new 
configuration.
   
      ```sh
      helm upgrade superset ./helm/superset -f values.yaml
      ```
   
   By following these steps, you can ensure that the boolean values in your 
`final_value` column are consistently formatted, which will help in filtering 
the data correctly. This approach leverages the `getDataRecordFormatter` 
function to handle various data types and ensures that boolean values are 
converted to `TRUE_STRING` or `FALSE_STRING` based on their truthiness 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/filters/utils.ts)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/filters/utils.test.ts)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


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