Comments (1)
Hey @ThinneshHummingsoft! I'm here to help you with your bug report. I can assist you with solving bugs, answering questions, and even becoming a contributor. Let's get to the bottom of this together!
To resolve the "Unexpected error: TypeError: Cannot read properties of undefined (reading 'some')" error when adding metrics in the tree chart page of Apache Superset, ensure that the savedMetrics
and columns
props passed to the DndMetricSelect
component are properly defined and not undefined
.
The error occurs because the some
method is being called on undefined
in the coerceMetrics
function. This can happen if savedMetrics
or columns
are not properly initialized.
Here is the relevant part of the code where the error might be occurring:
const coerceMetrics = (
addedMetrics: QueryFormMetric | QueryFormMetric[] | undefined | null,
savedMetrics: Metric[],
columns: ColumnMeta[],
) => {
if (!addedMetrics) {
return [];
}
const metricsCompatibleWithDataset = ensureIsArray(addedMetrics).filter(
metric => {
if (isSavedMetric(metric)) {
return savedMetrics.some(
savedMetric => savedMetric.metric_name === metric,
);
}
if (isAdhocMetricSimple(metric)) {
return columns.some(
column => column.column_name === metric.column.column_name,
);
}
return true;
},
);
return metricsCompatibleWithDataset.map(metric => {
if (!isDictionaryForAdhocMetric(metric)) {
return metric;
}
if (isAdhocMetricSimple(metric)) {
const column = columns.find(
col => col.column_name === metric.column.column_name,
);
if (column) {
return new AdhocMetric({ ...metric, column });
}
}
return new AdhocMetric(metric);
});
};
To fix this, ensure that savedMetrics
and columns
are always defined when passed to the DndMetricSelect
component. You can add default values or checks to handle cases where these might be undefined
.
For example:
const DndMetricSelect = (props: any) => {
const { onChange, multi, datasource, savedMetrics = [], columns = [] } = props;
// ... rest of the component code
};
By providing default values ([]
for both savedMetrics
and columns
), you can prevent the some
method from being called on undefined
, thus avoiding the TypeError [1].
To continue talking to Dosu, mention @dosu.
from superset.
Related Issues (20)
- A gamma does not see dataset (even if is public) HOT 1
- [DRAFT][SIP-142] Improving Database Migration Management
- Docker Compose Up does not work HOT 10
- Annotation Layers at Horizontal Barchart HOT 3
- celeryconfig.py HOT 2
- [ParsedQuery] Check is_read_only_query too slow HOT 1
- How to make gradient color for metric puted as bar in mixed chart in Superset 4.0.0. HOT 2
- [Dev build] Stacked chart tooltip highlights a different series than the one I'm hovering over HOT 4
- Schema name and Table name are empty after CSV import HOT 1
- [SIP] Ability to connect with a second user to run db migrations only HOT 2
- Extend API to handle uuid HOT 1
- Getting superset error: 'str' object has no attribute 'tzinfo' when using elasticsearch with superset:// HOT 4
- Error 'DISALLOWED_SQL_FUNCTION' in new superset update 4.0.2 HOT 4
- Superset is not starting because of secret key issue. HOT 4
- [SIP] Ability to connect to postgres with different schema with superset_config HOT 9
- Compose file './docker-compose.yml' invalid HOT 6
- Custom chart plugins not working in Kubernetes deployment HOT 2
- Remove or make less prominent legacy contributing guide HOT 3
- Request for neo4j driver HOT 1
- SQL Lab Error 'str' object has no attribute 'set' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superset.