|
|
@@ -33,30 +33,6 @@ import { CURRENT_QUERY_TAB_SWITCHED_EVENT } from 'apps/notebook2/snippet';
|
|
|
|
|
|
export const NAME = 'snippet-results';
|
|
|
|
|
|
-const META_TYPE_TO_CSS = {
|
|
|
- TINYINT_TYPE: 'sort-numeric',
|
|
|
- SMALLINT_TYPE: 'sort-numeric',
|
|
|
- INT_TYPE: 'sort-numeric',
|
|
|
- BIGINT_TYPE: 'sort-numeric',
|
|
|
- FLOAT_TYPE: 'sort-numeric',
|
|
|
- DOUBLE_TYPE: 'sort-numeric',
|
|
|
- DECIMAL_TYPE: 'sort-numeric',
|
|
|
- TIMESTAMP_TYPE: 'sort-date',
|
|
|
- DATE_TYPE: 'sort-date',
|
|
|
- DATETIME_TYPE: 'sort-date'
|
|
|
-};
|
|
|
-
|
|
|
-const isNumericColumn = type =>
|
|
|
- ['tinyint', 'smallint', 'int', 'bigint', 'float', 'double', 'decimal', 'real'].indexOf(type) !==
|
|
|
- -1;
|
|
|
-
|
|
|
-const isDateTimeColumn = type => ['timestamp', 'date', 'datetime'].indexOf(type) !== -1;
|
|
|
-
|
|
|
-const isComplexColumn = type => ['array', 'map', 'struct'].indexOf(type) !== -1;
|
|
|
-
|
|
|
-const isStringColumn = type =>
|
|
|
- !isNumericColumn(type) && !isDateTimeColumn(type) && !isComplexColumn(type);
|
|
|
-
|
|
|
// prettier-ignore
|
|
|
const TEMPLATE = `
|
|
|
<div class="snippet-row">
|
|
|
@@ -190,19 +166,10 @@ class SnippetResults extends DisposableComponent {
|
|
|
|
|
|
attachTracker(this.activeExecutable, NAME, this, trackedObservables);
|
|
|
|
|
|
- this.cleanedMeta = ko.pureComputed(() => this.meta().filter(item => item.name !== ''));
|
|
|
-
|
|
|
- this.cleanedDateTimeMeta = ko.pureComputed(() =>
|
|
|
- this.meta().filter(item => item.name !== '' && isDateTimeColumn(item.type))
|
|
|
- );
|
|
|
-
|
|
|
- self.cleanedStringMeta = ko.pureComputed(() =>
|
|
|
- this.meta().filter(item => item.name !== '' && isStringColumn(item.type))
|
|
|
- );
|
|
|
-
|
|
|
- this.cleanedNumericMeta = ko.pureComputed(() =>
|
|
|
- this.meta().filter(item => item.name !== '' && isNumericColumn(item.type))
|
|
|
- );
|
|
|
+ this.cleanedMeta = ko.observableArray();
|
|
|
+ this.cleanedDateTimeMeta = ko.observableArray();
|
|
|
+ this.cleanedStringMeta = ko.observableArray();
|
|
|
+ this.cleanedNumericMeta = ko.observableArray();
|
|
|
|
|
|
this.subscribe(this.showChart, val => {
|
|
|
if (val) {
|
|
|
@@ -253,6 +220,10 @@ class SnippetResults extends DisposableComponent {
|
|
|
this.lastFetchedRows([]);
|
|
|
this.data([]);
|
|
|
this.meta([]);
|
|
|
+ this.cleanedMeta([]);
|
|
|
+ this.cleanedDateTimeMeta([]);
|
|
|
+ this.cleanedNumericMeta([]);
|
|
|
+ this.cleanedStringMeta([]);
|
|
|
this.hasMore(false);
|
|
|
this.type(RESULT_TYPE.TABLE);
|
|
|
}
|
|
|
@@ -268,16 +239,11 @@ class SnippetResults extends DisposableComponent {
|
|
|
this.type(executionResult.type);
|
|
|
|
|
|
if (!this.meta().length && executionResult.meta.length) {
|
|
|
- this.meta(
|
|
|
- executionResult.meta.map((item, index) => ({
|
|
|
- name: item.name,
|
|
|
- type: item.type.replace(/_type/i, '').toLowerCase(),
|
|
|
- comment: item.comment,
|
|
|
- cssClass: META_TYPE_TO_CSS[item.type] || 'sort-string',
|
|
|
- checked: ko.observable(true),
|
|
|
- originalIndex: index
|
|
|
- }))
|
|
|
- );
|
|
|
+ this.meta(executionResult.koEnrichedMeta);
|
|
|
+ this.cleanedMeta(executionResult.cleanedMeta);
|
|
|
+ this.cleanedDateTimeMeta(executionResult.cleanedDateTimeMeta);
|
|
|
+ this.cleanedStringMeta(executionResult.cleanedStringMeta);
|
|
|
+ this.cleanedNumericMeta(executionResult.cleanedNumericMeta);
|
|
|
}
|
|
|
|
|
|
if (executionResult.lastRows.length) {
|