razzius opened a new issue #13396:
URL: https://github.com/apache/superset/issues/13396


   When creating a chart based on a Druid datasource, clicking "Add metric" 
gives an error which crashes the frontend.
   
   ### Expected results
   
   Clicking "Add metric" shows the metric picker popup.
   
   ### Actual results
   
   App crashes.
   
   #### Screenshots
   
   <img width="1552" alt="image" 
src="https://user-images.githubusercontent.com/2244895/109567897-b9cabd00-7aab-11eb-8bcc-0cdd774ab3e7.png";>
   
   #### How to reproduce the bug
   
   1. Hover over the + and select "Chart" to add a new chart
   2. Choose a dataset backed by druid
   3. Click "CREATE NEW CHART"
   4. Click the + to the right of "METRICS" to add a new metric
   
   ### Environment
   
   - superset version: `1.0.1`
   - python version: `3.8.5`
   - node.js version: `14.11.0`
   
   ### Checklist
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   
   ### Additional context
   
   React logs this message in the console:
   ```
   The above error occurred in the <AdhocMetricEditPopover> component:
       in AdhocMetricEditPopover (created by AdhocMetricPopoverTrigger)
   ```
   
   Stacktrace:
   
   ```
   Uncaught TypeError: it is undefined
       exports filter.js:6
       render AdhocMetricEditPopover.jsx:323
       finishClassComponent react-dom.development.js:17185
       updateClassComponent react-dom.development.js:17135
       ...
   ```
   
   It seems like the erroring code is:
   
   ```js
   // 
superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover.jsx:302
   
       const aggregateSelectProps = {
         placeholder: t('%s aggregates(s)', AGGREGATES_OPTIONS.length),
         value: adhocMetric.aggregate || 
adhocMetric.inferSqlExpressionAggregate(),
         onChange: this.onAggregateChange,
         allowClear: true,
         autoFocus: !!columnValue,
         showSearch: true,
       };
   
       // ...
   
       if (this.props.datasourceType === 'druid') {
         aggregateSelectProps.options = aggregateSelectProps.options.filter(
           aggregate => aggregate !== 'AVG',
         );
       }
   ```
   
   `aggregateSelectProps` doesn't have `options` defined, so calling 
`aggregateSelectProps.options.filter()` triggers the error


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

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