Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix More Nulls #2876

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/zui/src/app/features/inspector/views/null-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import {View} from "./view"
import * as zed from "@brimdata/zed-js"

export class NullView extends View<zed.Any> {
get showDecorator() {
return !zed.isPrimitiveType(this.type)
}

get decorator(): string {
return this.type.toString()
}

render() {
return "null"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/zui/src/app/features/inspector/views/record-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class RecordView extends ContainerView<zed.Record> {
}

*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) {
Expand Down
6 changes: 5 additions & 1 deletion apps/zui/src/app/query-home/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zed-js/src/types/type-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
11 changes: 7 additions & 4 deletions packages/zed-js/src/types/type-record.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) => {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/zed-js/src/values/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Record implements Value {
}

isUnset() {
return false;
return this.fields == null;
}

toJS(opts: JSOptions = {}) {
Expand Down