diff --git a/apps/zui/src/app/features/inspector/views/null-view.ts b/apps/zui/src/app/features/inspector/views/null-view.ts index 27300bd5de..75b6b252a5 100644 --- a/apps/zui/src/app/features/inspector/views/null-view.ts +++ b/apps/zui/src/app/features/inspector/views/null-view.ts @@ -2,6 +2,14 @@ import {View} from "./view" import * as zed from "@brimdata/zed-js" export class NullView extends View { + get showDecorator() { + return !zed.isPrimitiveType(this.type) + } + + get decorator(): string { + return this.type.toString() + } + render() { return "null" } diff --git a/apps/zui/src/app/features/inspector/views/record-view.ts b/apps/zui/src/app/features/inspector/views/record-view.ts index 87137c9492..5969ecc7d7 100644 --- a/apps/zui/src/app/features/inspector/views/record-view.ts +++ b/apps/zui/src/app/features/inspector/views/record-view.ts @@ -20,7 +20,7 @@ export class RecordView extends ContainerView { } *iterate(n?: number) { - const fields = this.value.fields || [] + const fields = this.value.fields const length = n ? Math.min(n, fields.length) : fields.length for (let i = 0; i < fields.length; ++i) { diff --git a/apps/zui/src/app/query-home/loader.ts b/apps/zui/src/app/query-home/loader.ts index c95a491c40..ce85bce322 100644 --- a/apps/zui/src/app/query-home/loader.ts +++ b/apps/zui/src/app/query-home/loader.ts @@ -11,6 +11,7 @@ import Pools from "src/js/state/Pools" import {invoke} from "src/core/invoke" import {runHistogramQuery} from "src/views/histogram-pane/run-query" import {runResultsQuery} from "src/views/results-pane/run-results-query" +import Layout from "src/js/state/Layout" export function loadRoute(location: Location): Thunk { return (dispatch) => { @@ -46,11 +47,14 @@ function syncEditor(dispatch, getState) { function fetchData() { return (dispatch, getState, {api}) => { const version = Current.getVersion(getState()) + const histogramVisible = Layout.getShowHistogram(getState()) startTransition(() => { if (version) { dispatch(runResultsQuery()) - runHistogramQuery(api) + if (histogramVisible) { + runHistogramQuery(api) + } } }) } diff --git a/packages/zed-js/src/types/type-map.ts b/packages/zed-js/src/types/type-map.ts index f2f8772061..ea33a1b572 100644 --- a/packages/zed-js/src/types/type-map.ts +++ b/packages/zed-js/src/types/type-map.ts @@ -6,7 +6,7 @@ import { ZedMap } from '../values/map'; import { Type } from './types'; export class TypeMap implements Type { - kind = 'union'; + kind = 'map'; constructor(public keyType: Type, public valType: Type) {} diff --git a/packages/zed-js/src/types/type-record.ts b/packages/zed-js/src/types/type-record.ts index a78c341be8..4fc50330a0 100644 --- a/packages/zed-js/src/types/type-record.ts +++ b/packages/zed-js/src/types/type-record.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as zjson from '../zjson'; import { DecodeStream } from '../decode-stream'; import { EncodeStream } from '../encode-stream'; @@ -32,7 +33,7 @@ export class TypeRecord implements Type { } toString() { - if (isNull(this.fields)) return 'null'; + if (isNull(this.fields)) return '{}'; let s = '{'; let sep = ''; this.fields.forEach((f) => { @@ -48,17 +49,19 @@ export class TypeRecord implements Type { stream: DecodeStream, parent?: Field ) { - if (values === null || isNull(this.fields)) return new Record(this, null); + // If this.fields == null that means it's an empty record type + if (values === null) return new Record(this, null); const record = new Record(this, null /* temp */); // If a parent was passed in, then we are constructing a nested record // and the parent is a Field. If no parent, then we are creating the // root record and the parent is this record. const progenitor = parent || record; // just needed another variable name for parent - record.fields = this.fields.map((f, i) => { + record.fields = values.map((value, i) => { + const f = this.fields![i]; if (trueType(f.type) instanceof TypeRecord) { const field = new Field(f.name, new Null() /* temp */, progenitor); - field.value = f.type.create(values[i], stream, field); + field.value = f.type.create(value, stream, field); return field; } else { return new Field(f.name, f.type.create(values[i], stream), progenitor); diff --git a/packages/zed-js/src/values/record.ts b/packages/zed-js/src/values/record.ts index adedbca6d4..48abba3603 100644 --- a/packages/zed-js/src/values/record.ts +++ b/packages/zed-js/src/values/record.ts @@ -134,7 +134,7 @@ export class Record implements Value { } isUnset() { - return false; + return this.fields == null; } toJS(opts: JSOptions = {}) {