tablejsonl

package
v1.134.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tablejsonl inspects a JSON-lines file before a table is registered over it, and reads the columns that table declares (#1820). It knows nothing about registrations; tableregister asks it and acts on the answer, as it asks tablecsv about a CSV.

A JSON-lines table is read by Trino's Hive JSON reader, one object per line, and it is the format a table reads back exactly: every string a JSON string can hold, line breaks included, and a null that stays a null. What the reader cannot read is the shape of a line, not the text inside it, and it fails in one of two ways. Most defects fail every query on the table, which is loud but leaves a registration nobody can use. One is silent: a second object on the same line is dropped. Each was observed on Trino 453, and each is refused here, by line, before the DDL runs.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRecords = errors.New("the file holds no records, so there are no columns to declare; " +
	"a JSON-lines file names its columns only in its records")

ErrNoRecords means the file holds no record to take a column from. A table declares at least one column, and a JSON-lines file carries its columns only in its records.

Functions

func Columns

func Columns(body []byte) ([]tablecsv.Column, error)

Columns reads a JSON-lines file and returns the columns a table over it declares: every key any record carries, lowercased, in the order they are first seen. It refuses a file the reader would fail on or read wrongly, naming the line.

The names are the keys, lowercased and otherwise untouched, because the reader finds a value by matching its key to a column name without regard to case. A CSV column can be renamed (tablecsv.ColumnsFrom fills a blank one and drops a comma) because a CSV is read by position; a key renamed here would be a column the reader never fills.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL