Skip to content

Commit

Permalink
[explore flow] handling duplicated column aliases (apache#5778)
Browse files Browse the repository at this point in the history
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
  • Loading branch information
mistercrunch authored and betodealmeida committed Oct 30, 2018
1 parent 0c46117 commit 4ecfd0c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions superset/assets/src/SqlLab/components/ExploreResultsButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ExploreResultsButton extends React.PureComponent {
title: t('Explore'),
body: msg,
actions: [
Dialog.DefaultAction('Ok', () => {}, 'btn-danger'),
Dialog.DefaultAction('Ok', () => {}, 'btn-primary'),
],
bsSize: 'large',
bsStyle: 'warning',
Expand All @@ -82,8 +82,11 @@ class ExploreResultsButton extends React.PureComponent {
return moment.duration(this.props.query.endDttm - this.props.query.startDttm).asSeconds();
}
getInvalidColumns() {
const re = /^[A-Za-z_]\w*$/;
return this.props.query.results.columns.map(col => col.name).filter(col => !re.test(col));
const re1 = /^[A-Za-z_]\w*$/; // starts with char or _, then only alphanum
const re2 = /__\d+$/; // does not finish with __ and then a number which screams dup col name

return this.props.query.results.columns.map(col => col.name)
.filter(col => !re1.test(col) || re2.test(col));
}
datasourceName() {
const { query } = this.props;
Expand Down Expand Up @@ -156,7 +159,9 @@ class ExploreResultsButton extends React.PureComponent {
<code>SELECT count(*)
<strong>AS my_alias</strong>
</code>){' '}
{t('limited to alphanumeric characters and underscores')}
{t('limited to alphanumeric characters and underscores. Column aliases ending with ' +
'double underscores followed by a numeric value are not allowed for reasons ' +
'discussed in Github issue #5739.')}
</div>);
}
render() {
Expand Down

0 comments on commit 4ecfd0c

Please sign in to comment.