Repository: brimsec/zq
Pull request #2340 (2021-03-14 18:35:01)

TZNG->ZSON transition ztests below zio/
There's a couple tests in here that still have TZNG because they exit precisely to test I/O of that format. If we should ever reach the point where we're genuinely phasing out TZNG altogether, we could dump 'em then.


Patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 1bd5793c2..3369aa203 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -12,7 +12,7 @@ jobs:
     steps:
       - uses: actions/setup-go@v2
         with:
-          go-version: '1.15'
+          go-version: '1.16'
       - uses: actions/checkout@v1
       - run: go mod download
       - run: make fmt
@@ -28,7 +28,7 @@ jobs:
     steps:
       - uses: actions/setup-go@v2
         with:
-          go-version: '1.15'
+          go-version: '1.16'
       - uses: actions/checkout@v1
       - run: go test -short ./...
       - run: mkdir dist -ea 0
@@ -40,7 +40,7 @@ jobs:
     steps:
       - uses: actions/setup-go@v2
         with:
-          go-version: '1.15'
+          go-version: '1.16'
       - uses: actions/checkout@v1
       - run: make install
       - run: make z-output-check
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b73919b7f..c5bb41df2 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,7 +9,7 @@ jobs:
     steps:
     - uses: actions/setup-go@v2
       with:
-        go-version: '1.15'
+        go-version: '1.16'
     - uses: actions/checkout@v1
     - run: go mod download
     - run: make fmt
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a508756b4..f2e390892 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,8 +17,8 @@ add a processor in [zq/proc](proc) or an aggregate function in [zq/expr/agg](exp
 
 ## Development
 
-`zq` requires Go 1.15 or later, and uses [Go modules](https://github.com/golang/go/wiki/Modules).
-Dependencies are specified in the [`go.mod` file](./go.mod) and managed
+`zq` requires Go 1.16 or later, and uses [Go modules](https://github.com/golang/go/wiki/Modules).
+Dependencies are specified in the [`go.mod` file](./go.mod) and fetched
 automatically by commands like `go build` and `go test`.  No explicit
 fetch commands are necessary.  However, you must set the environment
 variable `GO111MODULE=on` if your repo is at
diff --git a/Dockerfile b/Dockerfile
index 24635a1fc..8672af99a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM golang:1.15-alpine AS build
+FROM golang:1.16-alpine AS build
 RUN apk --update add ca-certificates
 
 # All these steps will be cached
diff --git a/README.md b/README.md
index 660aca214..a03b66f2b 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ To install `zq` or any other tool from this repo, you can either clone the repo
  [release](https://github.com/brimsec/zq/releases), available for Windows, macOS, and Linux.
 
 If you don't have Go installed, download and install it from the
-[Go downloads page](https://golang.org/dl/). Go version 1.15 or later is
+[Go downloads page](https://golang.org/dl/). Go version 1.16 or later is
 required.
 
 To install the binaries in `$GOPATH/bin`, clone this repo and
diff --git a/expr/cast.go b/expr/cast.go
index 70ebae6d1..10c030180 100644
--- a/expr/cast.go
+++ b/expr/cast.go
@@ -3,8 +3,11 @@ package expr
 import (
 	"math"
 	"net"
+	"time"
 
 	"github.com/brimsec/zq/expr/coerce"
+	"github.com/brimsec/zq/expr/function"
+	"github.com/brimsec/zq/pkg/byteconv"
 	"github.com/brimsec/zq/pkg/nano"
 	"github.com/brimsec/zq/zng"
 )
@@ -103,7 +106,22 @@ func castToIP(zv zng.Value) (zng.Value, error) {
 }
 
 func castToDuration(zv zng.Value) (zng.Value, error) {
-	if zng.IsFloat(zv.Type.ID()) {
+	id := zv.Type.ID()
+	if zng.IsStringy(id) {
+		d, err := time.ParseDuration(byteconv.UnsafeString(zv.Bytes))
+		var ns int64
+		if err == nil {
+			ns = int64(d)
+		} else {
+			f, ferr := byteconv.ParseFloat64(zv.Bytes)
+			if ferr != nil {
+				return zng.NewError(err), nil
+			}
+			ns = int64(f * 1e9)
+		}
+		return zng.Value{zng.TypeDuration, zng.EncodeDuration(ns)}, nil
+	}
+	if zng.IsFloat(id) {
 		f, _ := zng.DecodeFloat64(zv.Bytes)
 		ts := int64(nano.FloatToTs(f))
 		// XXX GC
@@ -113,21 +131,15 @@ func castToDuration(zv zng.Value) (zng.Value, error) {
 	if !ok {
 		return zng.Value{}, ErrBadCast
 	}
-	return zng.Value{zng.TypeDuration, zng.EncodeDuration(ns)}, nil
+	return zng.Value{zng.TypeDuration, zng.EncodeDuration(1_000_000_000 * ns)}, nil
 }
 
 func castToTime(zv zng.Value) (zng.Value, error) {
-	if zng.IsFloat(zv.Type.ID()) {
-		f, _ := zng.DecodeFloat64(zv.Bytes)
-		ts := nano.FloatToTs(f)
-		// XXX GC
-		return zng.Value{zng.TypeTime, zng.EncodeTime(ts)}, nil
-	}
-	ns, ok := coerce.ToInt(zv)
-	if !ok {
-		return zng.Value{}, ErrBadCast
+	ts, err := function.CastToTime(zv)
+	if err != nil {
+		return zng.NewError(err), nil
 	}
-	return zng.Value{zng.TypeTime, zng.EncodeTime(nano.Ts(ns))}, nil
+	return zng.Value{zng.TypeTime, zng.EncodeTime(ts)}, nil
 }
 
 func castToStringy(typ zng.Type) func(zng.Value) (zng.Value, error) {
diff --git a/expr/function/function.go b/expr/function/function.go
index cf2cac412..5f952dfac 100644
--- a/expr/function/function.go
+++ b/expr/function/function.go
@@ -75,16 +75,10 @@ func New(zctx *zson.Context, name string, narg int) (Interface, bool, error) {
 		f = &trim{}
 	case "iso":
 		f = &iso{}
-	case "sec":
-		f = &sec{}
 	case "split":
 		argmin = 2
 		argmax = 2
 		f = newSplit(zctx)
-	case "msec":
-		f = &msec{}
-	case "usec":
-		f = &usec{}
 	case "trunc":
 		argmin = 2
 		argmax = 2
diff --git a/expr/function/time.go b/expr/function/time.go
index 8bac9b689..6c658c8c3 100644
--- a/expr/function/time.go
+++ b/expr/function/time.go
@@ -1,10 +1,12 @@
 package function
 
 import (
+	"fmt"
 	"time"
 
 	"github.com/brimsec/zq/expr/coerce"
 	"github.com/brimsec/zq/expr/result"
+	"github.com/brimsec/zq/pkg/byteconv"
 	"github.com/brimsec/zq/pkg/nano"
 	"github.com/brimsec/zq/zng"
 )
@@ -14,90 +16,47 @@ type iso struct {
 }
 
 func (i *iso) Call(args []zng.Value) (zng.Value, error) {
-	zv := args[0]
-	if !zv.IsStringy() {
-		return badarg("iso")
-	}
-	if zv.Bytes == nil {
-		return zng.Value{zng.TypeTime, nil}, nil
-	}
-	// Handles ISO 8601 with time zone of Z or an offset not containing a colon.
-	format := "2006-01-02T15:04:05.999999999Z0700"
-	if l := len(zv.Bytes); l > 2 && zv.Bytes[l-3] == ':' {
-		// Handles ISO 8601 with time zone of Z or an offset containing a colon.
-		format = time.RFC3339Nano
-	}
-	ts, err := time.Parse(format, string(zv.Bytes))
+	ts, err := CastToTime(args[0])
 	if err != nil {
-		return badarg("iso")
+		return zng.NewError(err), nil
 	}
-	return zng.Value{zng.TypeTime, i.Time(nano.Ts(ts.UnixNano()))}, nil
+	return zng.Value{zng.TypeTime, i.Time(ts)}, nil
 }
 
-type sec struct {
-	result.Buffer
-}
-
-func (s *sec) Call(args []zng.Value) (zng.Value, error) {
-	zv := args[0]
+func CastToTime(zv zng.Value) (nano.Ts, error) {
 	if zv.Bytes == nil {
-		return zng.Value{zng.TypeInt64, nil}, nil
+		// Any nil value is cast to a zero time.
+		return 0, nil
 	}
-	ns, ok := coerce.ToInt(zv)
-	if !ok {
-		sec, ok := coerce.ToFloat(zv)
-		if !ok {
-			return badarg("sec")
+	id := zv.Type.ID()
+	if zng.IsStringy(id) {
+		// Handles ISO 8601 with time zone of Z or an offset not containing a colon.
+		format := "2006-01-02T15:04:05.999999999Z0700"
+		if l := len(zv.Bytes); l > 2 && zv.Bytes[l-3] == ':' {
+			// Handles ISO 8601 with time zone of Z or an offset containing a colon.
+			format = time.RFC3339Nano
 		}
-		ns = int64(1e9 * sec)
-	} else {
-		ns *= 1_000_000_000
-	}
-	return zng.Value{zng.TypeInt64, s.Int(ns)}, nil
-}
-
-type msec struct {
-	result.Buffer
-}
-
-func (m *msec) Call(args []zng.Value) (zng.Value, error) {
-	zv := args[0]
-	if zv.Bytes == nil {
-		return zng.Value{zng.TypeInt64, nil}, nil
-	}
-	ns, ok := coerce.ToInt(zv)
-	if !ok {
-		ms, ok := coerce.ToFloat(zv)
-		if !ok {
-			return badarg("msec")
+		ts, err := time.Parse(format, byteconv.UnsafeString(zv.Bytes))
+		if err != nil {
+			sec, ferr := byteconv.ParseFloat64(zv.Bytes)
+			if ferr != nil {
+				return 0, err
+			}
+			return nano.Ts(1e9 * sec), nil
 		}
-		ns = int64(1e6 * ms)
-	} else {
-		ns *= 1_000_000
+		return nano.Ts(ts.UnixNano()), nil
 	}
-	return zng.Value{zng.TypeInt64, m.Int(ns)}, nil
-}
-
-type usec struct {
-	result.Buffer
-}
-
-func (u *usec) Call(args []zng.Value) (zng.Value, error) {
-	zv := args[0]
-	if zv.Bytes == nil {
-		return zng.Value{zng.TypeInt64, nil}, nil
+	if zng.IsInteger(id) {
+		if sec, ok := coerce.ToInt(zv); ok {
+			return nano.Ts(sec * 1_000_000_000), nil
+		}
 	}
-	ns, ok := coerce.ToInt(zv)
-	if !ok {
-		us, ok := coerce.ToFloat(zv)
-		if !ok {
-			return badarg("usec")
+	if zng.IsFloat(id) {
+		if sec, ok := coerce.ToFloat(zv); ok {
+			return nano.Ts(sec * 1e9), nil
 		}
-		ns = int64(1000. * us)
-	} else {
-		ns *= 1000
 	}
-	return zng.Value{zng.TypeInt64, u.Int(ns)}, nil
+	return 0, fmt.Errorf("cannot convert value of type %s to time", zv.Type)
 }
 
 type trunc struct {
diff --git a/go.mod b/go.mod
index f2a9443eb..92719629d 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/brimsec/zq
 
-go 1.15
+go 1.16
 
 require (
 	github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
diff --git a/go.sum b/go.sum
index 1c1fc92e4..d9a5806ba 100644
--- a/go.sum
+++ b/go.sum
@@ -101,7 +101,6 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
 github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
 github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
 github.com/cockroachdb/cockroach-go v0.0.0-20190925194419-606b3d062051/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
-github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=
 github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
 github.com/colinmarc/hdfs/v2 v2.1.1/go.mod h1:M3x+k8UKKmxtFu++uAZ0OtDU8jR3jnaZIAc6yK4Ue0c=
 github.com/containerd/containerd v1.4.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
@@ -996,7 +995,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.0-20210106172901-c476de37821d h1:827r06Ng1EGlK/5Qb/mj+yHDj6pgKf5CjoX4v24FRJ0=
 gopkg.in/yaml.v3 v3.0.0-20210106172901-c476de37821d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
 gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/k8s/troubleshooting.md b/k8s/troubleshooting.md
index 34cadcba0..6d8927ced 100644
--- a/k8s/troubleshooting.md
+++ b/k8s/troubleshooting.md
@@ -264,8 +264,8 @@ aws configure
 # make sure you can see the S3 buckets
 aws s3 ls
 # install golang tools from https://golang.org/dl/
-wget https://golang.org/dl/go1.15.linux-amd64.tar.gz
-sudo tar -C /usr/local -xzf go1.15.linux-amd64.tar.gz
+wget https://golang.org/dl/go1.16.linux-amd64.tar.gz
+sudo tar -C /usr/local -xzf go1.16.linux-amd64.tar.gz
 echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bash_profile
 source ~/.bash_profile
 go version  # make sure go is there!
diff --git a/microindex/findreader.go b/microindex/findreader.go
index 5cd1ca225..b58842cf4 100644
--- a/microindex/findreader.go
+++ b/microindex/findreader.go
@@ -15,6 +15,7 @@ import (
 type FinderReader struct {
 	compare expr.KeyCompareFn
 	finder  *Finder
+	inputs  []string
 	reader  zbuf.Reader
 }
 
@@ -23,28 +24,31 @@ func NewFinderReader(ctx context.Context, zctx *resolver.Context, uri iosrc.URI,
 	if err != nil {
 		return nil, err
 	}
-	keys, err := finder.ParseKeys(inputs...)
-	if err != nil {
-		finder.Close()
-		return nil, err
-	}
-	compare, err := expr.NewKeyCompareFn(keys)
+	return &FinderReader{finder: finder, inputs: inputs}, nil
+}
+
+func (f *FinderReader) init() error {
+	keys, err := f.finder.ParseKeys(f.inputs...)
 	if err != nil {
-		finder.Close()
-		return nil, err
+		return err
 	}
-	reader, err := finder.search(compare)
+	f.compare, err = expr.NewKeyCompareFn(keys)
 	if err != nil {
-		finder.Close()
-		return nil, err
+		return err
 	}
-	return &FinderReader{compare: compare, finder: finder, reader: reader}, nil
+	f.reader, err = f.finder.search(f.compare)
+	return err
 }
 
 func (f *FinderReader) Read() (*zng.Record, error) {
 	if f.finder.IsEmpty() {
 		return nil, nil
 	}
+	if f.compare == nil {
+		if err := f.init(); err != nil {
+			return nil, err
+		}
+	}
 	return lookup(f.reader, f.compare, f.finder.trailer.Order, eql)
 }
 


Test patch:
diff --git a/expr/expr_test.go b/expr/expr_test.go
index ae0fbfc1d..0b32f198e 100644
--- a/expr/expr_test.go
+++ b/expr/expr_test.go
@@ -649,7 +649,6 @@ func TestCasts(t *testing.T) {
 	// Test casts to time
 	ts := zng.Value{zng.TypeTime, zng.EncodeTime(nano.Ts(1589126400_000_000_000))}
 	testSuccessful(t, "1589126400.0 :time", "", ts)
-	ts = zng.Value{zng.TypeTime, zng.EncodeTime(nano.Ts(1589126400))}
 	testSuccessful(t, "1589126400 :time", "", ts)
 	testSuccessful(t, `"1589126400" :time`, "", ts)
 
diff --git a/expr/functions_test.go b/expr/functions_test.go
index d16147db0..29afee926 100644
--- a/expr/functions_test.go
+++ b/expr/functions_test.go
@@ -191,25 +191,9 @@ func TestTime(t *testing.T) {
 
 	exp := fmt.Sprintf(`iso("%s")`, iso)
 	testSuccessful(t, exp, "", zval)
-	exp = fmt.Sprintf("msec(%d):time", msec)
-	testSuccessful(t, exp, "", zval)
-	exp = fmt.Sprintf("msec(%d.0):time", msec)
-	testSuccessful(t, exp, "", zval)
-	exp = fmt.Sprintf("usec(%d):time", msec*1000)
-	testSuccessful(t, exp, "", zval)
-	exp = fmt.Sprintf("usec(%d.0):time", msec*1000)
-	testSuccessful(t, exp, "", zval)
-	exp = fmt.Sprintf("%d:time", nsec)
-	testSuccessful(t, exp, "", zval)
-	testSuccessful(t, "trunc(1590506867.967, 1)", "", zng.Value{zng.TypeTime, zng.EncodeTime(nano.Ts(1590506867 * 1_000_000_000))})
 
-	testError(t, "iso()", "", function.ErrTooFewArgs, "Time.fromISO() with no args")
-	testError(t, `iso("abc", "def")`, "", function.ErrTooManyArgs, "Time.fromISO() with too many args")
-	testError(t, "iso(1234)", "", function.ErrBadArgument, "Time.fromISO() with wrong argument type")
-
-	testError(t, "msec()", "", function.ErrTooFewArgs, "Time.fromMilliseconds() with no args")
-	testError(t, "msec(123, 456)", "", function.ErrTooManyArgs, "Time.fromMilliseconds() with too many args")
+	testSuccessful(t, "trunc(1590506867.967, 1)", "", zng.Value{zng.TypeTime, zng.EncodeTime(nano.Ts(1590506867 * 1_000_000_000))})
 
-	testError(t, "usec()", "", function.ErrTooFewArgs, "Time.fromMicroseconds() with no args")
-	testError(t, "usec(123, 456)", "", function.ErrTooManyArgs, "Time.fromMicroseconds() with too many args")
+	testError(t, "iso()", "", function.ErrTooFewArgs, "iso() with no args")
+	testError(t, `iso("abc", "def")`, "", function.ErrTooManyArgs, "iso() with too many args")
 }
diff --git a/expr/ztests/cast-time.yaml b/expr/ztests/cast-time.yaml
new file mode 100644
index 000000000..1a43fe0c3
--- /dev/null
+++ b/expr/ztests/cast-time.yaml
@@ -0,0 +1,9 @@
+zql: put t=t:time
+
+input: |
+  {t:1521911720.600843}
+  {t:"2018-03-24T17:15:20.600843Z"}
+
+output: |
+  {t:2018-03-24T17:15:20.600843008Z}
+  {t:2018-03-24T17:15:20.600843Z}
diff --git a/expr/ztests/time-duration-cast.yaml b/expr/ztests/time-duration-cast.yaml
index e3df75dfa..ea72c9a0a 100644
--- a/expr/ztests/time-duration-cast.yaml
+++ b/expr/ztests/time-duration-cast.yaml
@@ -1,17 +1,11 @@
 zql: cut t=t:time,d=d:duration
 
 input: |
-  #0:record[t:string,d:string]
-  0:[1;1;]
-  #1:record[t:int64,d:int64]
-  1:[1;1;]
-  #2:record[t:float64,d:float64]
-  2:[1;1;]
-
-output-flags: -f tzng
+  {t:"1",d:"1"}
+  {t:1,d:1}
+  {t:1.,d:1.}
 
 output: |
-  #0:record[t:time,d:duration]
-  0:[0.000000001;0.000000001;]
-  0:[0.000000001;0.000000001;]
-  0:[1;1;]
+  {t:1970-01-01T00:00:01Z,d:1s}
+  {t:1970-01-01T00:00:01Z,d:1s}
+  {t:1970-01-01T00:00:01Z,d:1s}
diff --git a/ppl/zqd/temporal/spaceworkflow_test.go b/ppl/zqd/temporal/spaceworkflow_test.go
index 5b655d6be..cc765c5b5 100644
--- a/ppl/zqd/temporal/spaceworkflow_test.go
+++ b/ppl/zqd/temporal/spaceworkflow_test.go
@@ -2,7 +2,6 @@ package temporal
 
 import (
 	"context"
-	"go.temporal.io/sdk/workflow"
 	"testing"
 	"time"
 
@@ -10,6 +9,7 @@ import (
 	"github.com/stretchr/testify/mock"
 	"github.com/stretchr/testify/require"
 	"go.temporal.io/sdk/testsuite"
+	"go.temporal.io/sdk/workflow"
 )
 
 var testConfig = Config{
diff --git a/zio/csvio/ztests/bool.yaml b/zio/csvio/ztests/bool.yaml
index 9fa7bf363..3d7724c87 100644
--- a/zio/csvio/ztests/bool.yaml
+++ b/zio/csvio/ztests/bool.yaml
@@ -1,10 +1,9 @@
 zql: '*'
 
 input: |
-  #0:record[bool:bool]
-  0:[-;]
-  0:[F;]
-  0:[T;]
+  {bool:null (bool)}
+  {bool:false}
+  {bool:true}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/bstring.yaml b/zio/csvio/ztests/bstring.yaml
index 7f445462e..4789197d4 100644
--- a/zio/csvio/ztests/bstring.yaml
+++ b/zio/csvio/ztests/bstring.yaml
@@ -1,14 +1,13 @@
 zql: '*'
 
 input: |
-  #0:record[bstring:bstring]
-  0:[-;]
-  0:[;]
-  0:[";]
-  0:[,;]
-  0:[\x2d;]
-  0:[\\;]
-  0:[\x00\xff;]
+  {bstring:null (bstring)} (=0)
+  {bstring:""} (0)
+  {bstring:"\""} (0)
+  {bstring:","} (0)
+  {bstring:"-"} (0)
+  {bstring:"\\"} (0)
+  {bstring:"\x00\xff"} (0)
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/bytes.yaml b/zio/csvio/ztests/bytes.yaml
index fb8003c55..61a476c61 100644
--- a/zio/csvio/ztests/bytes.yaml
+++ b/zio/csvio/ztests/bytes.yaml
@@ -1,10 +1,9 @@
 zql: '*'
 
 input: |
-  #0:record[bytes:bytes]
-  0:[-;]
-  0:[;]
-  0:[aGVsbG8K;]
+  {bytes:null (bytes)}
+  {bytes:0x}
+  {bytes:0x68656c6c6f0a}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/csvfuse-default.yaml b/zio/csvio/ztests/csvfuse-default.yaml
index 72b2adc44..531a9d37d 100644
--- a/zio/csvio/ztests/csvfuse-default.yaml
+++ b/zio/csvio/ztests/csvfuse-default.yaml
@@ -1,10 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[a:string]
-  0:[hello;]
-  #1:record[b:int32]
-  1:[123;]
+  {a:"hello"}
+  {b:123 (int32)} (=0)
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/csvfuse-false.yaml b/zio/csvio/ztests/csvfuse-false.yaml
index e8d06d23e..db091c018 100644
--- a/zio/csvio/ztests/csvfuse-false.yaml
+++ b/zio/csvio/ztests/csvfuse-false.yaml
@@ -1,10 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[a:string]
-  0:[hello;]
-  #1:record[b:int32]
-  1:[123;]
+  {a:"hello"}
+  {b:123 (int32)} (=0)
 
 output-flags: -f csv -csvfuse=false
 
diff --git a/zio/csvio/ztests/csvfuse-true.yaml b/zio/csvio/ztests/csvfuse-true.yaml
index 5dfa78963..0fc2a9e0b 100644
--- a/zio/csvio/ztests/csvfuse-true.yaml
+++ b/zio/csvio/ztests/csvfuse-true.yaml
@@ -1,10 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[a:string]
-  0:[hello;]
-  #1:record[b:int32]
-  1:[123;]
+  {a:"hello"}
+  {b:123 (int32)} (=0)
 
 output-flags: -f csv -csvfuse=true
 
diff --git a/zio/csvio/ztests/duration.yaml b/zio/csvio/ztests/duration.yaml
index de75e4978..6932bca6e 100644
--- a/zio/csvio/ztests/duration.yaml
+++ b/zio/csvio/ztests/duration.yaml
@@ -1,11 +1,10 @@
 zql: '*'
 
 input: |
-  #0:record[duration:duration]
-  0:[-;]
-  0:[0;]
-  0:[-9223372036.854775808;]
-  0:[9223372036.854775807;]
+  {duration:null (duration)}
+  {duration:0s}
+  {duration:-2562047h47m16.854775808s}
+  {duration:2562047h47m16.854775807s}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/error.yaml b/zio/csvio/ztests/error.yaml
index a422ce864..4ebfb3d83 100644
--- a/zio/csvio/ztests/error.yaml
+++ b/zio/csvio/ztests/error.yaml
@@ -1,13 +1,12 @@
 zql: '*'
 
 input: |
-  #0:record[error:error]
-  0:[-;]
-  0:[;]
-  0:[";]
-  0:[,;]
-  0:[\u002d;]
-  0:[\u005c;]
+  {error:null (error)} (=0)
+  {error:""} (0)
+  {error:"\""} (0)
+  {error:","} (0)
+  {error:"\\u002d"} (0)
+  {error:"\\u005c"} (0)
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/float.yaml b/zio/csvio/ztests/float.yaml
index 9d28de0c8..035416705 100644
--- a/zio/csvio/ztests/float.yaml
+++ b/zio/csvio/ztests/float.yaml
@@ -3,14 +3,14 @@ zql: '*'
 # 1.797693134862315708145274237317043567981e+308 is Go's math.MaxFloat64.
 # 4.940656458412465441765687928682213723651e-324 is Go's math.SmallestNonzeroFloat64.
 input: |
-  #0:record[float64:float64]
-  0:[-;]
-  0:[0.0;]
-  0:[1.797693134862315708145274237317043567981e+308;]
-  0:[4.940656458412465441765687928682213723651e-324;]
-  0:[-Inf;]
-  0:[Inf;]
-  0:[NaN;]
+  {float64:null (float64)}
+  {float64:0.0}
+  {float64:1.797693134862315708145274237317043567981e+308}
+  {float64:4.940656458412465441765687928682213723651e-324}
+  {float64:-Inf}
+  {float64:+Inf}
+  {float64:NaN}
+
 output-flags: -f csv
 
 output: |
diff --git a/zio/csvio/ztests/int.yaml b/zio/csvio/ztests/int.yaml
index 3ce9d2d70..0c70af70d 100644
--- a/zio/csvio/ztests/int.yaml
+++ b/zio/csvio/ztests/int.yaml
@@ -1,11 +1,10 @@
 zql: '*'
 
 input: |
-  #0:record[int8:int8,int16:int16,int32:int32,int64:int64]
-  0:[-;-;-;-;]
-  0:[0;0;0;0;]
-  0:[-128;-32768;-2147483648;-9223372036854775808;]
-  0:[127;32767;2147483647;9223372036854775807;]
+  {int8:null (int8),int16:null (int16),int32:null (int32),int64:null (int64)} (=0)
+  {int8:0,int16:0,int32:0,int64:0} (0)
+  {int8:-128,int16:-32768,int32:-2147483648,int64:-9223372036854775808} (0)
+  {int8:127,int16:32767,int32:2147483647,int64:9223372036854775807} (0)
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/ip.yaml b/zio/csvio/ztests/ip.yaml
index e836b509d..c060aacde 100644
--- a/zio/csvio/ztests/ip.yaml
+++ b/zio/csvio/ztests/ip.yaml
@@ -1,9 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[ip:ip]
-  0:[-;]
-  0:[1.2.3.4;]
+  {ip:null (ip)}
+  {ip:1.2.3.4}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/net.yaml b/zio/csvio/ztests/net.yaml
index 28dab088e..429320cfa 100644
--- a/zio/csvio/ztests/net.yaml
+++ b/zio/csvio/ztests/net.yaml
@@ -1,9 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[net:net]
-  0:[-;]
-  0:[1.2.3.4/32;]
+  {net:null (net)}
+  {net:1.2.3.4/32}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/null-nested.yaml b/zio/csvio/ztests/null-nested.yaml
index 496a1734f..a3d91fc22 100644
--- a/zio/csvio/ztests/null-nested.yaml
+++ b/zio/csvio/ztests/null-nested.yaml
@@ -1,10 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[a:record[b:record[a1:array[string],a2:array[string]]]]
-  0:[-;]
-  #1:record[s:string]
-  1:[x;]
+  {a:null (0=({b:1=({a1:2=([string]),a2:2})}))}
+  {s:"x"}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/null.yaml b/zio/csvio/ztests/null.yaml
index 27d692c17..7cfbd3dc8 100644
--- a/zio/csvio/ztests/null.yaml
+++ b/zio/csvio/ztests/null.yaml
@@ -1,9 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[null:null]
-  0:[-;]
-  0:[;]
+  {null:null (null)} (=0)
+  {null:null} (0)
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/record-flat.yaml b/zio/csvio/ztests/record-flat.yaml
index e1bd4fda4..2d85accbe 100644
--- a/zio/csvio/ztests/record-flat.yaml
+++ b/zio/csvio/ztests/record-flat.yaml
@@ -1,10 +1,9 @@
 zql: '*'
 
 input: |
-  #0:record[a:string,b:string]
-  0:[hello;world;]
-  0:[goodnight;gracie;]
-  0:[,;gracie;]
+  {a:"hello",b:"world"}
+  {a:"goodnight",b:"gracie"}
+  {a:",",b:"gracie"}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/record-nested.yaml b/zio/csvio/ztests/record-nested.yaml
index 0ae178093..cfc232078 100644
--- a/zio/csvio/ztests/record-nested.yaml
+++ b/zio/csvio/ztests/record-nested.yaml
@@ -1,8 +1,7 @@
 zql: '*'
 
 input: |
-  #0:record[a:string,b:record[c:string,d:string]]
-  0:[hello;[world;goodbye;]]
+  {a:"hello",b:{c:"world",d:"goodbye"}}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/string.yaml b/zio/csvio/ztests/string.yaml
index a21d8eb18..e71b9001a 100644
--- a/zio/csvio/ztests/string.yaml
+++ b/zio/csvio/ztests/string.yaml
@@ -1,13 +1,12 @@
 zql: '*'
 
 input: |
-  #0:record[string:string]
-  0:[-;]
-  0:[;]
-  0:[";]
-  0:[,;]
-  0:[\u002d;]
-  0:[\u005c;]
+  {string:null (string)}
+  {string:""}
+  {string:"\""}
+  {string:","}
+  {string:"-"}
+  {string:"\\"}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/time-epoch.yaml b/zio/csvio/ztests/time-epoch.yaml
index 3600d8651..4a0cd3dd7 100644
--- a/zio/csvio/ztests/time-epoch.yaml
+++ b/zio/csvio/ztests/time-epoch.yaml
@@ -1,11 +1,10 @@
 zql: '*'
 
 input: |
-  #0:record[time:time]
-  0:[-;]
-  0:[0;]
-  0:[-9223372036.854775808;]
-  0:[9223372036.854775807;]
+  {time:null (time)}
+  {time:1970-01-01T00:00:00Z}
+  {time:1677-09-21T00:12:43.145224192Z}
+  {time:2262-04-11T23:47:16.854775807Z}
 
 output-flags: -f csv -E
 
diff --git a/zio/csvio/ztests/time.yaml b/zio/csvio/ztests/time.yaml
index 967a1ad20..90db33a19 100644
--- a/zio/csvio/ztests/time.yaml
+++ b/zio/csvio/ztests/time.yaml
@@ -1,11 +1,10 @@
 zql: '*'
 
 input: |
-  #0:record[time:time]
-  0:[-;]
-  0:[0;]
-  0:[-9223372036.854775808;]
-  0:[9223372036.854775807;]
+  {time:null (time)}
+  {time:1970-01-01T00:00:00Z}
+  {time:1677-09-21T00:12:43.145224192Z}
+  {time:2262-04-11T23:47:16.854775807Z}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/type.yaml b/zio/csvio/ztests/type.yaml
index e1b61c32e..850c52c33 100644
--- a/zio/csvio/ztests/type.yaml
+++ b/zio/csvio/ztests/type.yaml
@@ -1,8 +1,7 @@
 zql: '*'
 
 input: |
-  #0:record[type:type]
-  0:[-;]
+  {type:null (type)}
 
 output-flags: -f csv
 
diff --git a/zio/csvio/ztests/uint.yaml b/zio/csvio/ztests/uint.yaml
index f5897b86d..905cf671a 100644
--- a/zio/csvio/ztests/uint.yaml
+++ b/zio/csvio/ztests/uint.yaml
@@ -1,10 +1,9 @@
 zql: '*'
 
 input: |
-  #0:record[uint8:uint8,uint16:uint16,uint32:uint32,uint64:uint64]
-  0:[-;-;-;-;]
-  0:[0;0;0;0;]
-  0:[255;65535;4294967295;18446744073709551615;]
+  {uint8:null (uint8),uint16:null (uint16),uint32:null (uint32),uint64:null (uint64)} (=0)
+  {uint8:0,uint16:0,uint32:0,uint64:0} (0)
+  {uint8:255,uint16:65535,uint32:4294967295,uint64:18446744073709551615} (0)
 
 output-flags: -f csv
 
diff --git a/zio/detector/ztests/bzng-gz.yaml b/zio/detector/ztests/bzng-gz.yaml
index 43186f044..abc39dbc0 100644
--- a/zio/detector/ztests/bzng-gz.yaml
+++ b/zio/detector/ztests/bzng-gz.yaml
@@ -9,9 +9,5 @@ input: !!binary |
   Oz23ubNO1HqzYehbnXGRnA/uAk8PFF2MeT03GA+36Ivc4RHg7OcRj0O91eoUVjwSmDtlYZ
   aNamYlGyCvVYa3notT2zr+brG11/xUmQAQAA
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:bstring,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl" (bstring),ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
diff --git a/zio/detector/ztests/fake-zng.yaml b/zio/detector/ztests/fake-zng.yaml
index b38ef8f08..62dfcfe9a 100644
--- a/zio/detector/ztests/fake-zng.yaml
+++ b/zio/detector/ztests/fake-zng.yaml
@@ -1,4 +1,4 @@
-script: zq -f tzng -
+script: zq -z -
 
 inputs:
   - name: stdin
diff --git a/zio/detector/ztests/ndjson-gz.yaml b/zio/detector/ztests/ndjson-gz.yaml
index 21ba9a7c1..f92f3dabf 100644
--- a/zio/detector/ztests/ndjson-gz.yaml
+++ b/zio/detector/ztests/ndjson-gz.yaml
@@ -9,8 +9,5 @@ input: !!binary |
   LSE6z5IIkwO5z4Ezb4IUyPe5HlaZ4kyUARUNJ8lmTTohgPDuOQGRab6sbYtFtv7l/sdlnU
   LfL2XKuWB2V6hk8Vor+Q0YhH9fyBe5rC8eoTRjsGvfkBAAA=
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string,cert_chain_fuids:array[null],cipher:string,client_cert_chain_fuids:array[null],client_issuer:null,client_subject:null,curve:null,established:bool,id:record[orig_h:string,orig_p:int64,resp_h:string,resp_p:int64],issuer:null,last_alert:null,next_protocol:string,resumed:bool,server_name:string,subject:null,ts:record[ns:int64,sec:int64],uid:string,validation_status:null,version:string]
-  0:[ssl;[]TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;[]-;-;-;T;[10.10.7.90;51913;54.230.87.24;443;]-;-;http/1.1;T;choices.truste.com;-;[53424000;1490385563;]CfEBop2hbfJYpjG5Hd;-;TLSv12;]
+  {_path:"ssl",cert_chain_fuids:[] (0=([null])),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",client_cert_chain_fuids:[] (0),client_issuer:null (null),client_subject:null (null),curve:null (null),established:true,id:{orig_h:"10.10.7.90",orig_p:51913,resp_h:"54.230.87.24",resp_p:443},issuer:null (null),last_alert:null (null),next_protocol:"http/1.1",resumed:true,server_name:"choices.truste.com",subject:null (null),ts:{ns:53424000,sec:1490385563},uid:"CfEBop2hbfJYpjG5Hd",validation_status:null (null),version:"TLSv12"} (=1)
diff --git a/zio/detector/ztests/ndjson-nonewline.yaml b/zio/detector/ztests/ndjson-nonewline.yaml
index 5d40fea56..9f1b6a43d 100644
--- a/zio/detector/ztests/ndjson-nonewline.yaml
+++ b/zio/detector/ztests/ndjson-nonewline.yaml
@@ -2,8 +2,5 @@ zql: '*'
 
 input: '{"_path":"ssl","cert_chain_fuids":[],"cipher":"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256","client_cert_chain_fuids":[],"client_issuer":null,"client_subject":null,"curve":null,"established":true,"id":{"orig_h":"10.10.7.90","orig_p":51913,"resp_h":"54.230.87.24","resp_p":443},"issuer":null,"last_alert":null,"next_protocol":"http/1.1","resumed":true,"server_name":"choices.truste.com","subject":null,"ts":{"sec":1490385563,"ns":53424000},"uid":"CfEBop2hbfJYpjG5Hd","validation_status":null,"version":"TLSv12"}'
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string,cert_chain_fuids:array[null],cipher:string,client_cert_chain_fuids:array[null],client_issuer:null,client_subject:null,curve:null,established:bool,id:record[orig_h:string,orig_p:int64,resp_h:string,resp_p:int64],issuer:null,last_alert:null,next_protocol:string,resumed:bool,server_name:string,subject:null,ts:record[sec:int64,ns:int64],uid:string,validation_status:null,version:string]
-  0:[ssl;[]TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;[]-;-;-;T;[10.10.7.90;51913;54.230.87.24;443;]-;-;http/1.1;T;choices.truste.com;-;[1490385563;53424000;]CfEBop2hbfJYpjG5Hd;-;TLSv12;]
+  {_path:"ssl",cert_chain_fuids:[] (0=([null])),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",client_cert_chain_fuids:[] (0),client_issuer:null (null),client_subject:null (null),curve:null (null),established:true,id:{orig_h:"10.10.7.90",orig_p:51913,resp_h:"54.230.87.24",resp_p:443},issuer:null (null),last_alert:null (null),next_protocol:"http/1.1",resumed:true,server_name:"choices.truste.com",subject:null (null),ts:{sec:1490385563,ns:53424000},uid:"CfEBop2hbfJYpjG5Hd",validation_status:null (null),version:"TLSv12"} (=1)
diff --git a/zio/detector/ztests/ndjson.yaml b/zio/detector/ztests/ndjson.yaml
index b18771fa0..7d750fcf6 100644
--- a/zio/detector/ztests/ndjson.yaml
+++ b/zio/detector/ztests/ndjson.yaml
@@ -3,8 +3,5 @@ zql: '*'
 input: |
   {"_path":"ssl","cert_chain_fuids":[],"cipher":"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256","client_cert_chain_fuids":[],"client_issuer":null,"client_subject":null,"curve":null,"established":true,"id":{"orig_h":"10.10.7.90","orig_p":51913,"resp_h":"54.230.87.24","resp_p":443},"issuer":null,"last_alert":null,"next_protocol":"http/1.1","resumed":true,"server_name":"choices.truste.com","subject":null,"ts":{"sec":1490385563,"ns":53424000},"uid":"CfEBop2hbfJYpjG5Hd","validation_status":null,"version":"TLSv12"}
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string,cert_chain_fuids:array[null],cipher:string,client_cert_chain_fuids:array[null],client_issuer:null,client_subject:null,curve:null,established:bool,id:record[orig_h:string,orig_p:int64,resp_h:string,resp_p:int64],issuer:null,last_alert:null,next_protocol:string,resumed:bool,server_name:string,subject:null,ts:record[sec:int64,ns:int64],uid:string,validation_status:null,version:string]
-  0:[ssl;[]TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;[]-;-;-;T;[10.10.7.90;51913;54.230.87.24;443;]-;-;http/1.1;T;choices.truste.com;-;[1490385563;53424000;]CfEBop2hbfJYpjG5Hd;-;TLSv12;]
+  {_path:"ssl",cert_chain_fuids:[] (0=([null])),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",client_cert_chain_fuids:[] (0),client_issuer:null (null),client_subject:null (null),curve:null (null),established:true,id:{orig_h:"10.10.7.90",orig_p:51913,resp_h:"54.230.87.24",resp_p:443},issuer:null (null),last_alert:null (null),next_protocol:"http/1.1",resumed:true,server_name:"choices.truste.com",subject:null (null),ts:{sec:1490385563,ns:53424000},uid:"CfEBop2hbfJYpjG5Hd",validation_status:null (null),version:"TLSv12"} (=1)
diff --git a/zio/detector/ztests/tzng-nonewline.yaml b/zio/detector/ztests/tzng-nonewline.yaml
new file mode 100644
index 000000000..d48c5aa5d
--- /dev/null
+++ b/zio/detector/ztests/tzng-nonewline.yaml
@@ -0,0 +1,9 @@
+zql: '*'
+
+input: |-
+  #port=uint16
+  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
+  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+
+output: |
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd",id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12",cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",curve:null (string),server_name:"choices.truste.com",resumed:true,last_alert:null (string),next_protocol:"http/1.1",established:true,cert_chain_fuids:null (1=([string])),client_cert_chain_fuids:null (1),subject:null (string),issuer:null (string),client_subject:null (string),client_issuer:null (string),validation_status:null (string)} (=2)
diff --git a/zio/detector/ztests/zng-nonewline.yaml b/zio/detector/ztests/tzng.yaml
similarity index 50%
rename from zio/detector/ztests/zng-nonewline.yaml
rename to zio/detector/ztests/tzng.yaml
index b19819c84..229a1324e 100644
--- a/zio/detector/ztests/zng-nonewline.yaml
+++ b/zio/detector/ztests/tzng.yaml
@@ -5,9 +5,5 @@ input: |
   #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
   0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd",id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12",cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",curve:null (string),server_name:"choices.truste.com",resumed:true,last_alert:null (string),next_protocol:"http/1.1",established:true,cert_chain_fuids:null (1=([string])),client_cert_chain_fuids:null (1),subject:null (string),issuer:null (string),client_subject:null (string),client_issuer:null (string),validation_status:null (string)} (=2)
diff --git a/zio/detector/ztests/zeek-gz.yaml b/zio/detector/ztests/zeek-gz.yaml
index cb276c9c5..d5e702cc9 100644
--- a/zio/detector/ztests/zeek-gz.yaml
+++ b/zio/detector/ztests/zeek-gz.yaml
@@ -10,9 +10,5 @@ input: !!binary |
   puM0h7IQWZ6I0akIF4oih+X1ok+zbZCz6fl8Jm8XE3l3uZzLyWwh02wkL6Y3cjGfZOUJHI
   GurdFIgn1HjELbDSwDrpndcSrSXfFtRe8oe/bwfQIAAA==
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
diff --git a/zio/detector/ztests/zeek-nonewline.yaml b/zio/detector/ztests/zeek-nonewline.yaml
index 16d33e2c0..bc9fb30fd 100644
--- a/zio/detector/ztests/zeek-nonewline.yaml
+++ b/zio/detector/ztests/zeek-nonewline.yaml
@@ -10,9 +10,5 @@ input: |-
   #types	time	string	addr	port	addr	port	string	string	string	string	bool	string	string	bool	vector[string]	vector[string]	string	string	string	string	string
   1490385563.053424	CfEBop2hbfJYpjG5Hd	10.10.7.90	51913	54.230.87.24	443	TLSv12	TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256	-	choices.truste.com	T	-	http/1.1	T	-	-	-	-	-	-	-
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
diff --git a/zio/detector/ztests/zeek.yaml b/zio/detector/ztests/zeek.yaml
index e089bf06f..4ddd56eeb 100644
--- a/zio/detector/ztests/zeek.yaml
+++ b/zio/detector/ztests/zeek.yaml
@@ -10,9 +10,5 @@ input: |
   #types	time	string	addr	port	addr	port	string	string	string	string	bool	string	string	bool	vector[string]	vector[string]	string	string	string	string	string
   1490385563.053424	CfEBop2hbfJYpjG5Hd	10.10.7.90	51913	54.230.87.24	443	TLSv12	TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256	-	choices.truste.com	T	-	http/1.1	T	-	-	-	-	-	-	-
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
diff --git a/zio/detector/ztests/zjson-gz.yaml b/zio/detector/ztests/zjson-gz.yaml
index 74f49850a..aa20c0db7 100644
--- a/zio/detector/ztests/zjson-gz.yaml
+++ b/zio/detector/ztests/zjson-gz.yaml
@@ -11,9 +11,5 @@ input: !!binary |
   9We1pB/GGL+dflgl2uZuznt6slmy1WjFZjdj6/YKvlrGpHUAy+7wsQnVZCInHWo5NE6N0x
   wovaOWc+U0KTuezr5vHTE6LshnChBAAA
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd",id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12",cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",curve:null (string),server_name:"choices.truste.com",resumed:true,last_alert:null (string),next_protocol:"http/1.1",established:true,cert_chain_fuids:null (1=([string])),client_cert_chain_fuids:null (1),subject:null (string),issuer:null (string),client_subject:null (string),client_issuer:null (string),validation_status:null (string)} (=2)
diff --git a/zio/detector/ztests/zjson-nonewline.yaml b/zio/detector/ztests/zjson-nonewline.yaml
index a586b1da7..ed645345b 100644
--- a/zio/detector/ztests/zjson-nonewline.yaml
+++ b/zio/detector/ztests/zjson-nonewline.yaml
@@ -3,9 +3,5 @@ zql: '*'
 input: |
   {"id":26,"schema":{"of":[{"name":"_path","type":"string"},{"name":"ts","type":"time"},{"name":"uid","type":"string"},{"name":"id","of":[{"name":"orig_h","type":"ip"},{"name":"orig_p","type":"port"},{"name":"resp_h","type":"ip"},{"name":"resp_p","type":"port"}],"type":"record"},{"name":"version","type":"string"},{"name":"cipher","type":"string"},{"name":"curve","type":"string"},{"name":"server_name","type":"string"},{"name":"resumed","type":"bool"},{"name":"last_alert","type":"string"},{"name":"next_protocol","type":"string"},{"name":"established","type":"bool"},{"name":"cert_chain_fuids","of":"string","type":"array"},{"name":"client_cert_chain_fuids","of":"string","type":"array"},{"name":"subject","type":"string"},{"name":"issuer","type":"string"},{"name":"client_subject","type":"string"},{"name":"client_issuer","type":"string"},{"name":"validation_status","type":"string"}],"type":"record"},"aliases":[{"name":"port","type":"uint16"}],"values":["ssl","1490385563.053424","CfEBop2hbfJYpjG5Hd",["10.10.7.90","51913","54.230.87.24","443"],"TLSv12","TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",null,"choices.truste.com","T",null,"http/1.1","T",null,null,null,null,null,null,null]}
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd",id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12",cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",curve:null (string),server_name:"choices.truste.com",resumed:true,last_alert:null (string),next_protocol:"http/1.1",established:true,cert_chain_fuids:null (1=([string])),client_cert_chain_fuids:null (1),subject:null (string),issuer:null (string),client_subject:null (string),client_issuer:null (string),validation_status:null (string)} (=2)
diff --git a/zio/detector/ztests/zjson.yaml b/zio/detector/ztests/zjson.yaml
index a586b1da7..ed645345b 100644
--- a/zio/detector/ztests/zjson.yaml
+++ b/zio/detector/ztests/zjson.yaml
@@ -3,9 +3,5 @@ zql: '*'
 input: |
   {"id":26,"schema":{"of":[{"name":"_path","type":"string"},{"name":"ts","type":"time"},{"name":"uid","type":"string"},{"name":"id","of":[{"name":"orig_h","type":"ip"},{"name":"orig_p","type":"port"},{"name":"resp_h","type":"ip"},{"name":"resp_p","type":"port"}],"type":"record"},{"name":"version","type":"string"},{"name":"cipher","type":"string"},{"name":"curve","type":"string"},{"name":"server_name","type":"string"},{"name":"resumed","type":"bool"},{"name":"last_alert","type":"string"},{"name":"next_protocol","type":"string"},{"name":"established","type":"bool"},{"name":"cert_chain_fuids","of":"string","type":"array"},{"name":"client_cert_chain_fuids","of":"string","type":"array"},{"name":"subject","type":"string"},{"name":"issuer","type":"string"},{"name":"client_subject","type":"string"},{"name":"client_issuer","type":"string"},{"name":"validation_status","type":"string"}],"type":"record"},"aliases":[{"name":"port","type":"uint16"}],"values":["ssl","1490385563.053424","CfEBop2hbfJYpjG5Hd",["10.10.7.90","51913","54.230.87.24","443"],"TLSv12","TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",null,"choices.truste.com","T",null,"http/1.1","T",null,null,null,null,null,null,null]}
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd",id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12",cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",curve:null (string),server_name:"choices.truste.com",resumed:true,last_alert:null (string),next_protocol:"http/1.1",established:true,cert_chain_fuids:null (1=([string])),client_cert_chain_fuids:null (1),subject:null (string),issuer:null (string),client_subject:null (string),client_issuer:null (string),validation_status:null (string)} (=2)
diff --git a/zio/detector/ztests/zng-gz.yaml b/zio/detector/ztests/zng-gz.yaml
index 0560b2527..efbfe2d35 100644
--- a/zio/detector/ztests/zng-gz.yaml
+++ b/zio/detector/ztests/zng-gz.yaml
@@ -9,9 +9,5 @@ input: !!binary |
   nZ7b1NmvajVRuPwrzjjQxgf3AS+Pgi7OPJ6TjAfT/EHe8IDwfnOAz6XrdXaNFYcMqgrVUG
   mrWpWJSsQj3WWh522h2zr+brGxTKoGqQAQAA
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+  {_path:"ssl",ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd",id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12",cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",curve:null (string),server_name:"choices.truste.com",resumed:true,last_alert:null (string),next_protocol:"http/1.1",established:true,cert_chain_fuids:null (1=([string])),client_cert_chain_fuids:null (1),subject:null (string),issuer:null (string),client_subject:null (string),client_issuer:null (string),validation_status:null (string)} (=2)
diff --git a/zio/detector/ztests/zng-rdwr-comp.yaml b/zio/detector/ztests/zng-rdwr-comp.yaml
index 30b402878..32e1582ab 100644
--- a/zio/detector/ztests/zng-rdwr-comp.yaml
+++ b/zio/detector/ztests/zng-rdwr-comp.yaml
@@ -1,24 +1,18 @@
 script: |
-  zq -znglz4blocksize=0 -o uncomp.zng in.tzng
-  zq  -o comp.zng in.tzng
-  zq -f tzng uncomp.zng
+  zq -znglz4blocksize=0 -o uncomp.zng in.zson
+  zq  -o comp.zng in.zson
+  zq -z uncomp.zng
   echo ===
-  zq -f tzng comp.zng
+  zq -z comp.zng
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #port=uint16
-      #0:record[_path:bstring,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-      0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+      {_path:"ssl" (bstring),ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
 
 outputs:
   - name: stdout
     data: |
-      #port=uint16
-      #0:record[_path:bstring,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-      0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+      {_path:"ssl" (bstring),ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
       ===
-      #port=uint16
-      #0:record[_path:bstring,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:array[bstring],client_cert_chain_fuids:array[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring]
-      0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
+      {_path:"ssl" (bstring),ts:2017-03-24T19:59:23.053424Z,uid:"CfEBop2hbfJYpjG5Hd" (bstring),id:{orig_h:10.10.7.90,orig_p:51913 (port=(uint16)),resp_h:54.230.87.24,resp_p:443 (port)} (=0),version:"TLSv12" (bstring),cipher:"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" (bstring),curve:null (bstring),server_name:"choices.truste.com" (bstring),resumed:true,last_alert:null (bstring),next_protocol:"http/1.1" (bstring),established:true,cert_chain_fuids:null (1=([bstring])),client_cert_chain_fuids:null (1),subject:null (bstring),issuer:null (bstring),client_subject:null (bstring),client_issuer:null (bstring),validation_status:null (bstring)} (=2)
diff --git a/zio/detector/ztests/zng.yaml b/zio/detector/ztests/zng.yaml
deleted file mode 100644
index b19819c84..000000000
--- a/zio/detector/ztests/zng.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-zql: '*'
-
-input: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
-
-output-flags: -f tzng
-
-output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:string,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:string,cipher:string,curve:string,server_name:string,resumed:bool,last_alert:string,next_protocol:string,established:bool,cert_chain_fuids:array[string],client_cert_chain_fuids:array[string],subject:string,issuer:string,client_subject:string,client_issuer:string,validation_status:string]
-  0:[ssl;1490385563.053424;CfEBop2hbfJYpjG5Hd;[10.10.7.90;51913;54.230.87.24;443;]TLSv12;TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;-;choices.truste.com;T;-;http/1.1;T;-;-;-;-;-;-;-;]
diff --git a/zio/detector/ztests/zson.yaml b/zio/detector/ztests/zson.yaml
index a886843e5..2ddc050a2 100644
--- a/zio/detector/ztests/zson.yaml
+++ b/zio/detector/ztests/zson.yaml
@@ -7,13 +7,9 @@ input: |
   {a:["foo","bar"] (=1)} (=2)
   {a:["bar"]} (2)
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string]
-  0:[conn;]
-  0:[foo;]
-  0:[conn;]
-  #1:record[a:array[string]]
-  1:[[foo;bar;]]
-  1:[[bar;]]
+  {_path:"conn"}
+  {_path:"foo"}
+  {_path:"conn"}
+  {a:["foo","bar"]}
+  {a:["bar"]}
diff --git a/zio/zeekio/ztests/close-date.yaml b/zio/zeekio/ztests/close-date.yaml
index 7817f494a..4faa72260 100644
--- a/zio/zeekio/ztests/close-date.yaml
+++ b/zio/zeekio/ztests/close-date.yaml
@@ -11,8 +11,5 @@ input: |
   10.000000	1
   #close  2019-10-10-08-30-35
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string,ts:time,d:float64]
-  0:[a;10;1;]
+  {_path:"a",ts:1970-01-01T00:00:10Z,d:1.}
diff --git a/zio/zeekio/ztests/close-nodate.yaml b/zio/zeekio/ztests/close-nodate.yaml
index 4689e47fc..fba7fd927 100644
--- a/zio/zeekio/ztests/close-nodate.yaml
+++ b/zio/zeekio/ztests/close-nodate.yaml
@@ -11,8 +11,5 @@ input: |
   10.000000	1
   #close
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string,ts:time,d:float64]
-  0:[a;10;1;]
+  {_path:"a",ts:1970-01-01T00:00:10Z,d:1.}
diff --git a/zio/zeekio/ztests/complex-array-incompat.yaml b/zio/zeekio/ztests/complex-array-incompat.yaml
index 7610e5561..a2d9f0dd6 100644
--- a/zio/zeekio/ztests/complex-array-incompat.yaml
+++ b/zio/zeekio/ztests/complex-array-incompat.yaml
@@ -3,8 +3,7 @@ script: zq -f zeek -
 inputs:
   - name: stdin
     data: |
-        #0:record[a:array[record[s:string]]]
-        0:[[[foo;]]]
+        {a:[{s:"foo"}]}
 
 outputs:
   - name: stderr
diff --git a/zio/zeekio/ztests/duration.yaml b/zio/zeekio/ztests/duration.yaml
index 7c4efe41f..c1359851a 100644
--- a/zio/zeekio/ztests/duration.yaml
+++ b/zio/zeekio/ztests/duration.yaml
@@ -1,12 +1,11 @@
 zql: '*'
 
 input: |
-  #0:record[_path:string,ts:time,d:duration]
-  0:[conn;1e9;1e9;]
-  0:[conn;1;-1;]
-  0:[conn;1.0;1.0;]
-  0:[conn;1.123e8;1.123e8;]
-  0:[conn;1e-8;1e-8;]
+  {_path:"conn",ts:2001-09-09T01:46:40Z,d:277777h46m40s}
+  {_path:"conn",ts:1970-01-01T00:00:01Z,d:-1s}
+  {_path:"conn",ts:1970-01-01T00:00:01Z,d:1s}
+  {_path:"conn",ts:1973-07-23T18:26:40Z,d:31194h26m40s}
+  {_path:"conn",ts:1970-01-01T00:00:00.00000001Z,d:10ns}
 
 output-flags: -f zeek
 
diff --git a/zio/zeekio/ztests/multizeek.yaml b/zio/zeekio/ztests/multizeek.yaml
index b17e7a3d8..d72dcd0e7 100644
--- a/zio/zeekio/ztests/multizeek.yaml
+++ b/zio/zeekio/ztests/multizeek.yaml
@@ -13,10 +13,6 @@ input: |
   #types	time	int
   11.0	1
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:string,ts:time,d:float64]
-  0:[a;10;1;]
-  #1:record[_path:string,ts:time,d:int64]
-  1:[b;11;1;]
+  {_path:"a",ts:1970-01-01T00:00:10Z,d:1.}
+  {_path:"b",ts:1970-01-01T00:00:11Z,d:1}
diff --git a/zio/zeekio/ztests/multizng.yaml b/zio/zeekio/ztests/multizng.yaml
index d01e89df1..07c1fa045 100644
--- a/zio/zeekio/ztests/multizng.yaml
+++ b/zio/zeekio/ztests/multizng.yaml
@@ -1,10 +1,8 @@
 zql: '*'
 
 input: |
-  #0:record[_path:string,ts:time,d:float64]
-  0:[a;10;1;]
-  #1:record[_path:string,ts:time,d:int64]
-  1:[b;11;1;]
+  {_path:"a",ts:1970-01-01T00:00:10Z,d:1.}
+  {_path:"b",ts:1970-01-01T00:00:11Z,d:1}
 
 output-flags: -f zeek
 
diff --git a/zio/zeekio/ztests/nested-2.yaml b/zio/zeekio/ztests/nested-2.yaml
index 0764a9e10..3f372f393 100644
--- a/zio/zeekio/ztests/nested-2.yaml
+++ b/zio/zeekio/ztests/nested-2.yaml
@@ -1,9 +1,7 @@
 zql: '*'
 
 input: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],referenced_file:record[ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],fuid:bstring]]
-  0:[smb_cmd;1258594907.85978;Chjxid42dvvzIzdeG8;[192.168.1.102;1076;192.168.1.1;139;][1258594907.85978;Chjxid42dvvzIzdeG8;[192.168.1.102;1076;192.168.1.1;139;]ZYjxid42dvvzIzdeG8;]]
+  {_path:"smb_cmd",ts:2009-11-19T01:41:47.85978Z,uid:"Chjxid42dvvzIzdeG8" (bstring),id:{orig_h:192.168.1.102,orig_p:1076 (port=(uint16)),resp_h:192.168.1.1,resp_p:139 (port)} (=0),referenced_file:{ts:2009-11-19T01:41:47.85978Z,uid:"Chjxid42dvvzIzdeG8" (bstring),id:{orig_h:192.168.1.102,orig_p:1076,resp_h:192.168.1.1,resp_p:139} (0),fuid:"ZYjxid42dvvzIzdeG8" (bstring)} (=1)} (=2)
 
 output-flags: -f zeek
 
diff --git a/zio/zeekio/ztests/nested-record-name-is-prefix-of-another-field.yaml b/zio/zeekio/ztests/nested-record-name-is-prefix-of-another-field.yaml
index ab8526b11..c4276b0e9 100644
--- a/zio/zeekio/ztests/nested-record-name-is-prefix-of-another-field.yaml
+++ b/zio/zeekio/ztests/nested-record-name-is-prefix-of-another-field.yaml
@@ -11,9 +11,5 @@ input: |
   #types	time	string	addr	port	addr	port	count	string	string	string	addr	string	port	addr	string	port
   1521932484.182433	C8Yyb34kUAKDIM5ff1	10.199.194.15	39041	10.47.8.251	7777	5	-	-	connection not allowed by ruleset	-	-	-	-	google.com	0
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],version:uint64,user:bstring,password:bstring,status:bstring,request:record[host:ip,name:bstring],request_p:port,bound:record[host:ip,name:bstring],bound_p:port]
-  0:[socks;1521932484.182433;C8Yyb34kUAKDIM5ff1;[10.199.194.15;39041;10.47.8.251;7777;]5;-;-;connection not allowed by ruleset;[-;-;]-;[-;google.com;]0;]
+  {_path:"socks",ts:2018-03-24T23:01:24.182433Z,uid:"C8Yyb34kUAKDIM5ff1" (bstring),id:{orig_h:10.199.194.15,orig_p:39041 (port=(uint16)),resp_h:10.47.8.251,resp_p:7777 (port)} (=0),version:5 (uint64),user:null (bstring),password:null (bstring),status:"connection not allowed by ruleset" (bstring),request:{host:null (ip),name:null (bstring)} (=1),request_p:null (port),bound:{host:null,name:"google.com"} (1),bound_p:0 (port)} (=2)
diff --git a/zio/zeekio/ztests/nested-record-with-nonadjacent-fields.yaml b/zio/zeekio/ztests/nested-record-with-nonadjacent-fields.yaml
index 3ae72af22..effd6b2e1 100644
--- a/zio/zeekio/ztests/nested-record-with-nonadjacent-fields.yaml
+++ b/zio/zeekio/ztests/nested-record-with-nonadjacent-fields.yaml
@@ -11,10 +11,5 @@ input: |
   #types	time	string	addr	port	addr	port	enum	string	interval	count	count	string	bool	bool	count	string	count	count	count	count	set[string]	string	string	string	set[string]	string	set[string]
   1598243094.015046	CWjxkd3jpmxuvN21uj	10.124.2.117	61927	10.70.70.70	8080	tcp	-	0.002716	0	77	SF	F	F	0	FdfR	3	120	2	157	-	-	-	-	-	SSL_SNI	oneclient.sfx.ms,bats.video.yahoo.com,ctldl.windowsupdate.com,tapestry.tapad.com,www.gstatic.com,www.google.com:443,c.clicktale.net,eb2.3lift.com:443,13-237-209-96.expertcity.com:443,pr-bh.ybp.yahoo.com:443,clientservices.googleapis.com:443,js-sec.indexww.com:443,collect.tealiumiq.com,www.pacast.com,oneclient.sfx.ms:443,clientservices.googleapis.com,bats.video.yahoo.com:443,www.youtube.com
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #zenum=string
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port,orig_h_name:record[src:bstring,vals:set[bstring]],resp_h_name:record[src:bstring,vals:set[bstring]]],proto:zenum,service:bstring,duration:duration,orig_bytes:uint64,resp_bytes:uint64,conn_state:bstring,local_orig:bool,local_resp:bool,missed_bytes:uint64,history:bstring,orig_pkts:uint64,orig_ip_bytes:uint64,resp_pkts:uint64,resp_ip_bytes:uint64,tunnel_parents:set[bstring],orig_cc:bstring,resp_cc:bstring]
-  0:[conn;1598243094.015046;CWjxkd3jpmxuvN21uj;[10.124.2.117;61927;10.70.70.70;8080;[-;-;][SSL_SNI;[www.pacast.com;c.clicktale.net;www.gstatic.com;www.youtube.com;oneclient.sfx.ms;eb2.3lift.com:443;tapestry.tapad.com;www.google.com:443;bats.video.yahoo.com;oneclient.sfx.ms:443;collect.tealiumiq.com;js-sec.indexww.com:443;ctldl.windowsupdate.com;pr-bh.ybp.yahoo.com:443;bats.video.yahoo.com:443;clientservices.googleapis.com;13-237-209-96.expertcity.com:443;clientservices.googleapis.com:443;]]]tcp;-;0.002716;0;77;SF;F;F;0;FdfR;3;120;2;157;-;-;-;]
+  {_path:"conn",ts:2020-08-24T04:24:54.015046Z,uid:"CWjxkd3jpmxuvN21uj" (bstring),id:{orig_h:10.124.2.117,orig_p:61927 (port=(uint16)),resp_h:10.70.70.70,resp_p:8080 (port),orig_h_name:{src:null (bstring),vals:null (0=(|[bstring]|))} (=1),resp_h_name:{src:"SSL_SNI",vals:|["www.pacast.com","c.clicktale.net","www.gstatic.com","www.youtube.com","oneclient.sfx.ms","eb2.3lift.com:443","tapestry.tapad.com","www.google.com:443","bats.video.yahoo.com","oneclient.sfx.ms:443","collect.tealiumiq.com","js-sec.indexww.com:443","ctldl.windowsupdate.com","pr-bh.ybp.yahoo.com:443","bats.video.yahoo.com:443","clientservices.googleapis.com","13-237-209-96.expertcity.com:443","clientservices.googleapis.com:443"]|} (1)} (=2),proto:"tcp" (=zenum),service:null (bstring),duration:2.716ms,orig_bytes:0 (uint64),resp_bytes:77 (uint64),conn_state:"SF" (bstring),local_orig:false,local_resp:false,missed_bytes:0 (uint64),history:"FdfR" (bstring),orig_pkts:3 (uint64),orig_ip_bytes:120 (uint64),resp_pkts:2 (uint64),resp_ip_bytes:157 (uint64),tunnel_parents:null (0),orig_cc:null (bstring),resp_cc:null (bstring)} (=3)
diff --git a/zio/zeekio/ztests/nested.yaml b/zio/zeekio/ztests/nested.yaml
index 867856d61..ef85d4af2 100644
--- a/zio/zeekio/ztests/nested.yaml
+++ b/zio/zeekio/ztests/nested.yaml
@@ -12,9 +12,5 @@ input: |
   1258594907.859780	Chjxid42dvvzIzdeG8	192.168.1.102	1076	192.168.1.1	139	1258594907.859780	Chjxid42dvvzIzdeG8	192.168.1.102	1076	192.168.1.1	139	ZYjxid42dvvzIzdeG8
   #close	2018-08-17-16-04-30
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[_path:string,ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],referenced_file:record[ts:time,uid:bstring,id:record[orig_h:ip,orig_p:port,resp_h:ip,resp_p:port],fuid:bstring]]
-  0:[smb_cmd;1258594907.85978;Chjxid42dvvzIzdeG8;[192.168.1.102;1076;192.168.1.1;139;][1258594907.85978;Chjxid42dvvzIzdeG8;[192.168.1.102;1076;192.168.1.1;139;]ZYjxid42dvvzIzdeG8;]]
+  {_path:"smb_cmd",ts:2009-11-19T01:41:47.85978Z,uid:"Chjxid42dvvzIzdeG8" (bstring),id:{orig_h:192.168.1.102,orig_p:1076 (port=(uint16)),resp_h:192.168.1.1,resp_p:139 (port)} (=0),referenced_file:{ts:2009-11-19T01:41:47.85978Z,uid:"Chjxid42dvvzIzdeG8" (bstring),id:{orig_h:192.168.1.102,orig_p:1076,resp_h:192.168.1.1,resp_p:139} (0),fuid:"ZYjxid42dvvzIzdeG8" (bstring)} (=1)} (=2)
diff --git a/zio/zeekio/ztests/no-path.yaml b/zio/zeekio/ztests/no-path.yaml
index 40d9574d4..54f55b959 100644
--- a/zio/zeekio/ztests/no-path.yaml
+++ b/zio/zeekio/ztests/no-path.yaml
@@ -11,11 +11,7 @@ input: |
   #path -
   😁
 
-output-flags: -f tzng
-
 output: |
-  #0:record[foo:bstring]
-  0:[😁;]
-  #1:record[_path:string,foo:bstring]
-  1:[magic;😁;]
-  0:[😁;]
+  {foo:"😁" (bstring)} (=0)
+  {_path:"magic",foo:"😁" (bstring)} (=1)
+  {foo:"😁"} (0)
diff --git a/zio/zeekio/ztests/path.yaml b/zio/zeekio/ztests/path.yaml
index 58e13dfa7..77e91d460 100644
--- a/zio/zeekio/ztests/path.yaml
+++ b/zio/zeekio/ztests/path.yaml
@@ -10,8 +10,5 @@ input: |
   #types	string	string
   conn	yes
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:bstring,foo:bstring]
-  0:[conn;yes;]
+  {_path:"conn" (bstring),foo:"yes" (bstring)} (=0)
diff --git a/zio/zeekio/ztests/path2.yaml b/zio/zeekio/ztests/path2.yaml
index 219678366..9ec7f7d78 100644
--- a/zio/zeekio/ztests/path2.yaml
+++ b/zio/zeekio/ztests/path2.yaml
@@ -10,8 +10,5 @@ input: |
   #types	string	string
   notconn	yes
 
-output-flags: -f tzng
-
 output: |
-  #0:record[_path:bstring,foo:bstring]
-  0:[notconn;yes;]
+  {_path:"notconn" (bstring),foo:"yes" (bstring)} (=0)
diff --git a/zio/zeekio/ztests/shared-context-bug-2.yaml b/zio/zeekio/ztests/shared-context-bug-2.yaml
index 04a96e4e5..57a137b8d 100644
--- a/zio/zeekio/ztests/shared-context-bug-2.yaml
+++ b/zio/zeekio/ztests/shared-context-bug-2.yaml
@@ -9,8 +9,5 @@ input: |
   #types	addr	port	addr	port	set[string]
   10.164.94.120	39681	10.47.3.155	3389	-
 
-output-flags: -f tzng
-
 output: |
-  #0:record[id:record[orig_h:ip]]
-  0:[[10.164.94.120;]]
+  {id:{orig_h:10.164.94.120}}
diff --git a/zio/zeekio/ztests/shared-context-bug.yaml b/zio/zeekio/ztests/shared-context-bug.yaml
index b9894af0c..5935809ef 100644
--- a/zio/zeekio/ztests/shared-context-bug.yaml
+++ b/zio/zeekio/ztests/shared-context-bug.yaml
@@ -9,9 +9,5 @@ input: |
   #types	addr	port	addr	port	set[string]
   10.164.94.120	39681	10.47.3.155	3389	-
 
-output-flags: -f tzng
-
 output: |
-  #port=uint16
-  #0:record[id:record[orig_p:port,resp_h:ip,resp_p:port],id2:ip]
-  0:[[39681;10.47.3.155;3389;]10.164.94.120;]
+  {id:{orig_p:39681 (port=(uint16)),resp_h:10.47.3.155,resp_p:3389 (port)} (=0),id2:10.164.94.120} (=1)
diff --git a/zio/zeekio/ztests/time.yaml b/zio/zeekio/ztests/time.yaml
index b9be70cb1..7c41946f6 100644
--- a/zio/zeekio/ztests/time.yaml
+++ b/zio/zeekio/ztests/time.yaml
@@ -1,12 +1,11 @@
 zql: '*'
 
 input: |
-  #0:record[_path:string,ts:time,ts2:time]
-  0:[conn;1425565514.419939;1;]
-  0:[conn;1425565514.4199391;1;]
-  0:[conn;1425565514.419939;1;]
-  0:[conn;-1425565514.419939;1;]
-  0:[conn;-;-;]
+  {_path:"conn",ts:2015-03-05T14:25:14.419939Z,ts2:1970-01-01T00:00:01Z}
+  {_path:"conn",ts:2015-03-05T14:25:14.4199391Z,ts2:1970-01-01T00:00:01Z}
+  {_path:"conn",ts:2015-03-05T14:25:14.419939Z,ts2:1970-01-01T00:00:01Z}
+  {_path:"conn",ts:1924-10-29T09:34:45.580061Z,ts2:1970-01-01T00:00:01Z}
+  {_path:"conn",ts:null (time),ts2:null (time)}
 
 output-flags: -f zeek
 
diff --git a/zio/zeekio/ztests/union-incompat.yaml b/zio/zeekio/ztests/union-incompat.yaml
index 5097917f6..bccac17e8 100644
--- a/zio/zeekio/ztests/union-incompat.yaml
+++ b/zio/zeekio/ztests/union-incompat.yaml
@@ -3,8 +3,7 @@ script: zq -f zeek -
 inputs:
   - name: stdin
     data: |
-        #0:record[u:union[string,int32]]
-        0:[0:foo;]
+        {u:"foo" (0=((string,int32)))} (=1)
 
 outputs:
   - name: stderr
diff --git a/zio/zeekio/ztests/utf8.yaml b/zio/zeekio/ztests/utf8.yaml
index 211f8d2cb..58ed25518 100644
--- a/zio/zeekio/ztests/utf8.yaml
+++ b/zio/zeekio/ztests/utf8.yaml
@@ -1,12 +1,11 @@
-script: zq -f zeek -U in.tzng
+script: zq -f zeek -U in.zson
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-        #0:record[_path:string,foo:bstring]
-        0:[;\xf0\x9f\x98\x81;]
-        0:[magic;\xf0\x9f\x98\x81;]
-        0:[;foo\xf0\x9f\x98\x81bar\x00\x01baz;]
+        {_path:"",foo:"😁" (bstring)} (=0)
+        {_path:"magic",foo:"😁"} (0)
+        {_path:"",foo:"foo😁bar\x00\x01baz"} (0)
 
 outputs:
   - name: stdout
diff --git a/zio/zeekio/ztests/zng-types.yaml b/zio/zeekio/ztests/zng-types.yaml
index 626b3ccda..4ff26e719 100644
--- a/zio/zeekio/ztests/zng-types.yaml
+++ b/zio/zeekio/ztests/zng-types.yaml
@@ -3,8 +3,7 @@
 zql: '*'
 
 input: |
-  #0:record[b:uint8,i16:int16,u16:uint16,i32:int32,u32:uint32,i64:int64,u64:uint64,a:ip,n:net,d:duration]
-  0:[0;0;0;0;0;0;0;10.1.2.3;10.0.0.0/8;1000;]
+  {b:0 (uint8),i16:0 (int16),u16:0 (uint16),i32:0 (int32),u32:0 (uint32),i64:0,u64:0 (uint64),a:10.1.2.3,n:10.0.0.0/8,d:16m40s} (=0)
 
 output-flags: -f zeek
 
diff --git a/zio/zjsonio/ztests/enum.yaml b/zio/zjsonio/ztests/enum.yaml
index b3c417cf8..3aa7bcd54 100644
--- a/zio/zjsonio/ztests/enum.yaml
+++ b/zio/zjsonio/ztests/enum.yaml
@@ -1,19 +1,17 @@
 script: |
-  zq -f zjson in.tzng | zq -f tzng -
+  zq -f zjson in.zson | zq -z -
 
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #0:record[e:enum[int32,foo:[1],bar:[2],baz:[4]]]
-      0:[0;]
-      0:[1;]
-      0:[2;]
+      {e:foo (0=(<foo:1 (int32),bar:2,baz:4>))} (=1)
+      {e:bar} (1)
+      {e:baz} (1)
 
 outputs:
   - name: stdout
     data: |
-      #0:record[e:enum[int32,foo:[1],bar:[2],baz:[4]]]
-      0:[0;]
-      0:[1;]
-      0:[2;]
+      {e:foo (0=(<foo:1 (int32),bar:2,baz:4>))} (=1)
+      {e:bar} (1)
+      {e:baz} (1)
diff --git a/zio/zjsonio/ztests/map.yaml b/zio/zjsonio/ztests/map.yaml
index 72d101627..71969ddd5 100644
--- a/zio/zjsonio/ztests/map.yaml
+++ b/zio/zjsonio/ztests/map.yaml
@@ -1,15 +1,13 @@
 script: |
-  zq -f zjson in.tzng | zq -f tzng -
+  zq -f zjson in.zson | zq -z -
 
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #0:record[m:map[string,record[a:int32,b:int32]]]
-      0:[[a;[1;2;]b;[2;3;]c;[3;4;]]]
+      {m:|{{"a",{a:1 (int32),b:2 (int32)} (=0)},{"b",{a:2,b:3} (0)},{"c",{a:3,b:4} (0)}}| (=1)} (=2)
 
 outputs:
   - name: stdout
     data: |
-      #0:record[m:map[string,record[a:int32,b:int32]]]
-      0:[[a;[1;2;]b;[2;3;]c;[3;4;]]]
+      {m:|{{"a",{a:1 (int32),b:2 (int32)} (=0)},{"b",{a:2,b:3} (0)},{"c",{a:3,b:4} (0)}}| (=1)} (=2)
diff --git a/zio/zngio/ztests/big-value.yaml b/zio/zngio/ztests/big-value.yaml
index b359646f4..8d92c4fb4 100644
--- a/zio/zngio/ztests/big-value.yaml
+++ b/zio/zngio/ztests/big-value.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -znglz4blocksize=0 -o out.zng in.tzng
+  zq -znglz4blocksize=0 -o out.zng in.zson
   for i in {1..7}; do
     cat out.zng out.zng out.zng out.zng > out2.zng
     mv out2.zng out.zng
@@ -8,11 +8,10 @@ script: |
   zq  -i zng -o /dev/null -readmax 10KB "count()" bigrow.zng
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #0:record[s:string]
-      0:[big data;]
-      0:[too big;]
+      {s:"big data"}
+      {s:"too big"}
 
 outputs:
   - name: stderr
diff --git a/zio/zsonio/ztests/enum.yaml b/zio/zsonio/ztests/enum.yaml
index 931c4ffa7..838b96230 100644
--- a/zio/zsonio/ztests/enum.yaml
+++ b/zio/zsonio/ztests/enum.yaml
@@ -3,10 +3,9 @@ zql: "*"
 output-flags: -f zson -pretty=4
 
 input: |
-  #0:record[flip:enum[uint8,HEADS:[0],TAILS:[1]]]
-  0:[0;]
-  0:[1;]
-  0:[0;]
+  {flip:HEADS (0=(<HEADS:0 (uint8),TAILS:1>))} (=1)
+  {flip:TAILS} (1)
+  {flip:HEADS} (1)
 
 output: |
   {
diff --git a/zio/zsonio/ztests/first-test.yaml b/zio/zsonio/ztests/first-test.yaml
index d99b2affc..1539a23e4 100644
--- a/zio/zsonio/ztests/first-test.yaml
+++ b/zio/zsonio/ztests/first-test.yaml
@@ -3,26 +3,17 @@ zql: "*"
 output-flags: -f zson -pretty=4
 
 input: |
-  #port=uint16
-  #zenum=string
-  #flow=record[orig_h:ip,orig_p:port,resp_h:ip,resp_port:port]
-  #0:record[_path:string,ts:time,id:flow,proto:zenum]
-  0:[conn;1521911720.600725;[10.47.1.152;49562;23.217.103.245;80;]tcp;]
-  0:[conn;1521911720.6008;[10.128.0.207;13;10.47.19.254;14;]icmp;]
-  0:[conn;1521911720.60131;[10.128.0.207;59777;10.47.28.6;443;]tcp;]
-  #1:record[flows:array[flow]]
-  1:[[[10.47.1.152;49562;23.217.103.245;80;]]]
-  1:[[[10.47.1.152;49562;23.217.103.245;80;][10.128.0.207;13;10.47.19.254;14;]]]
-  #2:record[ips:set[ip]]
-  2:[[10.0.0.1;192.168.1.1;]]
-  #3:record[nums:set[uint64]]
-  3:[[1;2;3;]]
-  #4:record[u:union[uint64,string]]
-  4:[0:12;]
-  4:[1:foo;]
-  #5:record[m:map[string,int32]]
-  5:[[a;1;b;2;c;3;]]
-  5:[[d;5;e;6;]]
+  {_path:"conn",ts:2018-03-24T17:15:20.600725Z,id:{orig_h:10.47.1.152,orig_p:49562 (port=(uint16)),resp_h:23.217.103.245,resp_port:80 (port)} (=flow),proto:"tcp" (=zenum)} (=0)
+  {_path:"conn",ts:2018-03-24T17:15:20.6008Z,id:{orig_h:10.128.0.207,orig_p:13,resp_h:10.47.19.254,resp_port:14},proto:"icmp"} (0)
+  {_path:"conn",ts:2018-03-24T17:15:20.60131Z,id:{orig_h:10.128.0.207,orig_p:59777,resp_h:10.47.28.6,resp_port:443},proto:"tcp"} (0)
+  {flows:[{orig_h:10.47.1.152,orig_p:49562,resp_h:23.217.103.245,resp_port:80} (flow)] (=1)} (=2)
+  {flows:[{orig_h:10.47.1.152,orig_p:49562,resp_h:23.217.103.245,resp_port:80},{orig_h:10.128.0.207,orig_p:13,resp_h:10.47.19.254,resp_port:14}]} (2)
+  {ips:|[10.0.0.1,192.168.1.1]|}
+  {nums:|[1 (uint64),2 (uint64),3 (uint64)]| (=3)} (=4)
+  {u:12 (uint64) (5=((uint64,string)))} (=6)
+  {u:"foo"} (6)
+  {m:|{{"a",1 (int32)},{"b",2 (int32)},{"c",3 (int32)}}| (=7)} (=8)
+  {m:|{{"d",5},{"e",6}}|} (8)
 
 output: |
   {
diff --git a/zio/zsonio/ztests/tv.yaml b/zio/zsonio/ztests/tv.yaml
index 9ac1ac158..d04898fd8 100644
--- a/zio/zsonio/ztests/tv.yaml
+++ b/zio/zsonio/ztests/tv.yaml
@@ -3,10 +3,8 @@ zql: "put t=typeof(s) | put tt=typeof(t)"
 output-flags: -f zson -pretty=4
 
 input: |
-  #foo=uint8
-  #0:record[s:string,n:int32,a:array[foo]]
-  0:[hello;123;[1;2;3;]]
-  0:[goodbye;34;[3;4;]]
+  {s:"hello",n:123 (int32),a:[1 (foo=(uint8)),2 (foo),3 (foo)] (=0)} (=1)
+  {s:"goodbye",n:34,a:[3,4]} (1)
 
 output: |
   {
diff --git a/zio/zsonio/ztests/zson-zng.yaml b/zio/zsonio/ztests/zson-zng.yaml
index 5a57468b4..1b5cbc05d 100644
--- a/zio/zsonio/ztests/zson-zng.yaml
+++ b/zio/zsonio/ztests/zson-zng.yaml
@@ -1,15 +1,13 @@
 # Send zson into zng and back out to make sure binary encoding of typevals works.
 
 script: |
-  zq -Z "put t=typeof(.)" in.tzng
+  zq -Z "put t=typeof(.)" in.zson
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #foo=uint8
-      #0:record[a:string,b:string,n:int32,f:array[foo]]
-      0:[hello;world;123;[1;2;3;]]
-      0:[goodbye;world;456;[4;5;6;]]
+      {a:"hello",b:"world",n:123 (int32),f:[1 (foo=(uint8)),2 (foo),3 (foo)] (=0)} (=1)
+      {a:"goodbye",b:"world",n:456,f:[4,5,6]} (1)
 
 outputs:
   - name: stdout
diff --git a/zson/ztests/container-types.yaml b/zson/ztests/container-types.yaml
index 1ccfb17ac..9514b768a 100644
--- a/zson/ztests/container-types.yaml
+++ b/zson/ztests/container-types.yaml
@@ -6,14 +6,8 @@ input: |
   { n: null ([string]) }
   { n: null ({a: string}) }
 
-output-flags: -f tzng
-
 output: |
-  #0:record[n:map[string,int32]]
-  0:[-;]
-  #1:record[n:set[string]]
-  1:[-;]
-  #2:record[n:array[string]]
-  2:[-;]
-  #3:record[n:record[a:string]]
-  3:[-;]
+  {n:null (0=(|{stringint32}|))} (=1)
+  {n:null (2=(|[string]|))}
+  {n:null (3=([string]))}
+  {n:null (4=({a:string}))}
diff --git a/zson/ztests/empty-array.yaml b/zson/ztests/empty-array.yaml
index 63eea0335..9c3494c87 100644
--- a/zson/ztests/empty-array.yaml
+++ b/zson/ztests/empty-array.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson -pretty=0 in.zson
+  zq -z in.zson
 
 inputs:
   - name: in.zson
@@ -10,7 +10,5 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #0:record[version:array[null]]
-      0:[[]]
-      #1:record[version:array[int64]]
-      1:[[1;]]
+      {version:[] (0=([null]))} (=1)
+      {version:[1]}
diff --git a/zson/ztests/implied-nulls-repeated.yaml b/zson/ztests/implied-nulls-repeated.yaml
index ee53af510..abea725d2 100644
--- a/zson/ztests/implied-nulls-repeated.yaml
+++ b/zson/ztests/implied-nulls-repeated.yaml
@@ -1,13 +1,12 @@
 script: |
-  zq -f zson -pretty=0 in.tzng
+  zq -z in.zson
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #0:record[a:string,b:array[record[a:string,b:string]]]
-      0:[hello;[[a;b;][c;d;][e;f;]]]
-      0:[world;-;]
-      0:[goodnight;-;]
+      {a:"hello",b:[{a:"a",b:"b"},{a:"c",b:"d"},{a:"e",b:"f"}]}
+      {a:"world",b:null (0=([1=({a:string,b:string})]))}
+      {a:"goodnight",b:null (0)}
 
 outputs:
   - name: stdout
diff --git a/zson/ztests/implied-nulls.yaml b/zson/ztests/implied-nulls.yaml
index 9b1e1cf9e..1351eea9a 100644
--- a/zson/ztests/implied-nulls.yaml
+++ b/zson/ztests/implied-nulls.yaml
@@ -1,14 +1,12 @@
 script: |
-  zq -f zson -pretty=0 in.tzng
+  zq -z in.zson
 
 inputs:
-  - name: in.tzng
+  - name: in.zson
     data: |
-      #0:record[a:string,b:array[record[a:string,b:string]]]
-      0:[hello;[[a;b;][c;d;][e;f;]]]
-      0:[world;-;]
-      #1:record[a:string,b:array[union[record[a:string,b:string],record[a:string,b:null]]]]
-      1:[goodnight;[0:[a;b;]1:[c;-;]0:[e;f;]]]
+      {a:"hello",b:[{a:"a",b:"b"},{a:"c",b:"d"},{a:"e",b:"f"}]}
+      {a:"world",b:null (0=([1=({a:string,b:string})]))}
+      {a:"goodnight",b:[{a:"a",b:"b"} (2=((1,3=({a:string,b:null})))),{a:"c",b:null (null)} (3) (2),{a:"e",b:"f"} (2)] (=4)} (=5)
 
 outputs:
   - name: stdout
diff --git a/zson/ztests/inf.yaml b/zson/ztests/inf.yaml
index 630d0b23c..521b6db1c 100644
--- a/zson/ztests/inf.yaml
+++ b/zson/ztests/inf.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f zson -i zson -pretty=0 in.zson
+  zq -z in.zson
 
 inputs:
   - name: in.zson
diff --git a/zson/ztests/mixed-null-array.yaml b/zson/ztests/mixed-null-array.yaml
index 0208047b2..f4d246c4b 100644
--- a/zson/ztests/mixed-null-array.yaml
+++ b/zson/ztests/mixed-null-array.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson -pretty=0 in.zson
+  zq -z in.zson
 
 inputs:
   - name: in.zson
@@ -12,10 +12,7 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #0:record[version:array[int64]]
-      0:[[1;-;]]
-      0:[[-;2;]]
-      #1:record[version:array[null]]
-      1:[[-;-;]]
-      #2:record[version:array[union[null,string,int64]]]
-      2:[[-;1:foo;2:3;]]
+      {version:[1,null (int64)]}
+      {version:[null (int64),2]}
+      {version:[null (null),null (null)] (=0)} (=1)
+      {version:[null (2=((null,string,int64))),"foo" (2),3 (2)] (=3)} (=4)
diff --git a/zson/ztests/no-trailing-newline.yaml b/zson/ztests/no-trailing-newline.yaml
index df42149a9..31feb1bb6 100644
--- a/zson/ztests/no-trailing-newline.yaml
+++ b/zson/ztests/no-trailing-newline.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson "count()" in.zson
+  zq -z "count()" in.zson
 
 inputs:
   - name: in.zson
@@ -14,5 +14,4 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #0:record[count:uint64]
-      0:[2;]
+      {count:2 (uint64)} (=0)
diff --git a/zson/ztests/outer-schema.yaml b/zson/ztests/outer-schema.yaml
index 45a74adec..8d803edc8 100644
--- a/zson/ztests/outer-schema.yaml
+++ b/zson/ztests/outer-schema.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson -pretty=0 in.zson
+  zq -z in.zson
 
 inputs:
   - name: in.zson
@@ -11,7 +11,6 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #city_schema=record[city:string,state:string,population:uint32]
-      city_schema:[Berkeley;CA;121643;]
-      city_schema:[Broad Cove;ME;806;]
-      city_schema:[Baton Rouge;LA;221599;]
+      {city:"Berkeley",state:"CA",population:121643 (uint32)} (=city_schema)
+      {city:"Broad Cove",state:"ME",population:806} (city_schema)
+      {city:"Baton Rouge",state:"LA",population:221599} (city_schema)
diff --git a/zson/ztests/spec-example.yaml b/zson/ztests/spec-example.yaml
index 18f267568..e158491b9 100644
--- a/zson/ztests/spec-example.yaml
+++ b/zson/ztests/spec-example.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson in.zson
+  zq -z in.zson
 
 inputs:
   - name: in.zson
@@ -26,16 +26,10 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #socket=record[addr:ip,port:uint16]
-      #conn=record[info:string,src:socket,dst:socket]
-      conn:[Connection Example;[10.1.1.2;80;][10.0.1.2;20130;]]
-      conn:[Connection Example 2;[10.1.1.8;80;][10.1.2.88;19801;]]
-      #access_list=record[info:string,nets:array[net]]
-      access_list:[Access List Example;[10.1.1.0/24;10.1.2.0/24;]]
-      #2:record[metric:string,ts:time,value:int64]
-      2:[A;1606236249.586441;120;]
-      #3:record[metric:string,ts:time,value:float64]
-      3:[B;1606236260.726057;0.86;]
-      2:[A;1606236272.201458;126;]
-      #4:record[metric:string,ts:time,value:record[x:int64,y:int64]]
-      4:[C;1606236283.547506;[10;101;]]
+      {info:"Connection Example",src:{addr:10.1.1.2,port:80 (uint16)} (=socket),dst:{addr:10.0.1.2,port:20130} (socket)} (=conn)
+      {info:"Connection Example 2",src:{addr:10.1.1.8,port:80},dst:{addr:10.1.2.88,port:19801}} (conn)
+      {info:"Access List Example",nets:[10.1.1.0/24,10.1.2.0/24]} (=access_list)
+      {metric:"A",ts:2020-11-24T16:44:09.586441Z,value:120}
+      {metric:"B",ts:2020-11-24T16:44:20.726057Z,value:8.6e-01}
+      {metric:"A",ts:2020-11-24T16:44:32.201458Z,value:126}
+      {metric:"C",ts:2020-11-24T16:44:43.547506Z,value:{x:10,y:101}}
diff --git a/zson/ztests/typedef-binding.yaml b/zson/ztests/typedef-binding.yaml
index 91c6db730..a7928fbfa 100644
--- a/zson/ztests/typedef-binding.yaml
+++ b/zson/ztests/typedef-binding.yaml
@@ -4,17 +4,8 @@ zql: |
   is(r,type(rec))
 
 input: |
-  #port=uint16
-  #rec=record[p:port]
-  #0:record[r:rec]
-  0:[[80;]]
-  #1:record[s:string]
-  1:[hello;]
-
-output-flags: -f tzng
+  {r:{p:80 (port=(uint16))} (=rec)} (=0)
+  {s:"hello"}
 
 output: |
-  #port=uint16
-  #rec=record[p:port]
-  #0:record[r:rec]
-  0:[[80;]]
+  {r:{p:80 (port=(uint16))} (=rec)} (=0)
diff --git a/zson/ztests/typeof.yaml b/zson/ztests/typeof.yaml
index 7c940e595..676b47d94 100644
--- a/zson/ztests/typeof.yaml
+++ b/zson/ztests/typeof.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson "by typeof(.) | sort ." in.zson
+  zq -z "by typeof(.) | sort ." in.zson
 
 inputs:
   - name: in.zson
@@ -26,9 +26,8 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #0:record[typeof:type]
-      0:[{metric:string,ts:time,value:int64};]
-      0:[{metric:string,ts:time,value:float64};]
-      0:[access_list=({info:string,nets:[net]});]
-      0:[{metric:string,ts:time,value:{x:int64,y:int64}};]
-      0:[conn=({info:string,src:socket=({addr:ip,port:uint16}),dst:socket=({addr:ip,port:uint16})});]
+      {typeof:({metric:string,ts:time,value:int64})}
+      {typeof:({metric:string,ts:time,value:float64})}
+      {typeof:(access_list=({info:string,nets:[net]}))}
+      {typeof:({metric:string,ts:time,value:{x:int64,y:int64}})}
+      {typeof:(conn=({info:string,src:socket=({addr:ip,port:uint16}),dst:socket=({addr:ip,port:uint16})}))}
diff --git a/zson/ztests/union-cast.yaml b/zson/ztests/union-cast.yaml
index 603653f9b..87a47fb9f 100644
--- a/zson/ztests/union-cast.yaml
+++ b/zson/ztests/union-cast.yaml
@@ -1,5 +1,5 @@
 script: |
-  zq -f tzng -i zson "by typeof(.) | sort ." in.zson
+  zq -z "by typeof(.) | sort ." in.zson
 
 inputs:
   - name: in.zson
@@ -18,6 +18,5 @@ inputs:
 outputs:
   - name: stdout
     data: |
-      #0:record[typeof:type]
-      0:[{r:{u:sint=((int32,string))}};]
-      0:[{r:{v:sint=((int32,string))}};]
+      {typeof:({r:{u:sint=((int32,string))}})}
+      {typeof:({r:{v:sint=((int32,string))}})}
diff --git a/ztests/fixedbugs/2241.yaml b/ztests/fixedbugs/2241.yaml
new file mode 100644
index 000000000..2613878c3
--- /dev/null
+++ b/ztests/fixedbugs/2241.yaml
@@ -0,0 +1,15 @@
+script: |
+  zar import -R ./zartest -
+  zar index create -R ./zartest uri
+  zar find -R ./zartest -f table uri=/file
+
+inputs:
+  - name: stdin
+    data: |
+      {_path:"conn",ts:2018-03-24T17:15:21.255387Z,uid:"C8Tful1TvM3Zf5x8fl" (bstring),id:{orig_h:10.164.94.120,orig_p:39681 (port=(uint16)),resp_h:10.47.3.155,resp_p:3389 (port)} (=0),proto:"tcp" (=zenum),service:null (bstring),duration:4.266ms,orig_bytes:97 (uint64),resp_bytes:19 (uint64),conn_state:"RSTR" (bstring),local_orig:null (bool),local_resp:null (bool),missed_bytes:0 (uint64),history:"ShADTdtr" (bstring),orig_pkts:10 (uint64),orig_ip_bytes:730 (uint64),resp_pkts:6 (uint64),resp_ip_bytes:342 (uint64),tunnel_parents:null (1=(|[bstring]|))}
+
+outputs:
+  - name: stdout
+    data: ""
+  - name: stderr
+    data: ""