Open kraftaa opened 2 days ago
Hey there, @kraftaa! I'm here to help you with any bugs, questions, or contributions you have for Superset. Let's work together to solve the issue you're facing.
To resolve the issue of False/True
vs false/true
in the final_value
column when filtering data in Superset, you can use the getDataRecordFormatter
function to ensure consistent boolean string formatting. This function converts various representations of boolean values to a standardized format (TRUE_STRING
or FALSE_STRING
).
Here is an example of how you can use getDataRecordFormatter
to handle this:
import { getDataRecordFormatter, GenericDataType } from 'src/filters/utils';
import { TRUE_STRING, FALSE_STRING } from 'src/utils/common';
const formatter = getDataRecordFormatter();
// Example usage:
const formattedValue1 = formatter('true', GenericDataType.Boolean); // returns TRUE_STRING
const formattedValue2 = formatter('False', GenericDataType.Boolean); // returns FALSE_STRING
const formattedValue3 = formatter(true, GenericDataType.Boolean); // returns TRUE_STRING
const formattedValue4 = formatter(false, GenericDataType.Boolean); // returns FALSE_STRING
console.log(formattedValue1); // "true"
console.log(formattedValue2); // "false"
console.log(formattedValue3); // "true"
console.log(formattedValue4); // "false"
By using this formatter, you can ensure that all boolean values in the final_value
column are consistently formatted, which will help in filtering the data correctly. The getDataRecordFormatter
function handles various data types and ensures that boolean values are converted to TRUE_STRING
or FALSE_STRING
based on their truthiness [1][2].
To continue talking to Dosu, mention @dosu.
hi, thank you.
I'm sorry it's not clear to me -where/how should I use it? I'm running superset via helm in kubernetes. I'm changing some config params via values.yaml
with configOverrides
.
thank you
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:
Create a Custom JavaScript File:
Create a custom JavaScript file that uses the getDataRecordFormatter
function to format your boolean values.
// 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);
}
Modify the Superset Configuration:
Use the configOverrides
in your values.yaml
to include this custom JavaScript file in your Superset deployment.
configOverrides:
CUSTOM_JS: "/app/pythonpath/customFormatter.js"
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.
Deploy the Changes: Deploy your changes by updating your Helm chart and applying the new configuration.
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 [1][2].
To continue talking to Dosu, mention @dosu.
thank you.
I think there is no way to modify Frontend files if I only can change values.yaml
for helm chart in kubernetes and not rebuilding the image.
Bug description
I'm running Superset in kubernetes via helm chart.
I have a postgres table with such a definition
I've added values there
Then I'm looking in
sql lab
and see thatfinal_value
is converted to Python booleanI'm looking at the dashboard and seeing
False/True
infinal_value
columnIf I select another filter it'll show
false/true
notFalse/True
infinal_value
columnFor now the value is Jsonb and it won't work with the filter so I'm adding to the dataset (to be able to use IN and LIKE )
How to reproduce the bug
go to the dataset, choose
False
in and see No data returned, because there is notFalse/True
in this columnIf I type for
like
I can typetrue/false
and it shows the stuff correctlyI know if I do my dataset as
select id, client_id, animal, final_value::text from example_table
I'll get all text values, but I wonder whats happening with the above example betweenFalse/True
andfalse/true
.Screenshots/recordings
No response
Superset version
4.0.2
Python version
3.10
Node version
I don't know
Browser
Chrome
Additional context
No response
Checklist