fix: make __time an ok column name in SQL Lab (#10336)

This commit is contained in:
Ville Brofeldt 2020-07-16 10:34:50 +03:00 committed by GitHub
parent 2341e8d585
commit 611dd7a8f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -321,6 +321,11 @@ export const queryWithBadColumns = {
name: '_TIMESTAMP', name: '_TIMESTAMP',
type: 'TIMESTAMP', type: 'TIMESTAMP',
}, },
{
is_date: true,
name: '__TIME',
type: 'TIMESTAMP',
},
{ {
is_date: true, is_date: true,
name: '__TIMESTAMP', name: '__TIMESTAMP',

View File

@ -104,7 +104,7 @@ class ExploreResultsButton extends React.PureComponent {
getInvalidColumns() { getInvalidColumns() {
const re1 = /^[A-Za-z_]\w*$/; // starts with char or _, then only alphanum 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 const re2 = /__\d+$/; // does not finish with __ and then a number which screams dup col name
const re3 = /^__/; // is not a reserved column name e.g. __timestamp const re3 = /^__timestamp/i; // is not a reserved temporal column alias
return this.props.query.results.selected_columns return this.props.query.results.selected_columns
.map(col => col.name) .map(col => col.name)
@ -199,9 +199,10 @@ class ExploreResultsButton extends React.PureComponent {
<strong>AS my_alias</strong> <strong>AS my_alias</strong>
</code> </code>
){' '} ){' '}
{t(`limited to alphanumeric characters and underscores. Column aliases starting {t(`limited to alphanumeric characters and underscores. The alias "__timestamp"
with double underscores or ending with double underscores followed by a used as for the temporal expression and column aliases ending with
numeric value are not allowed for reasons discussed in Github issue #5739. double underscores followed by a numeric value are not allowed for reasons
discussed in Github issue #5739.
`)} `)}
</div> </div>
); );