zed icon indicating copy to clipboard operation
zed copied to clipboard

zq read with "file" is silent on auto-detect failure

Open philrz opened this issue 2 years ago • 1 comments

When using file to read data from multiple files via zq, a failure to auto-detect the input format in one of the files caused my program to exit with success and return no output.

Details

Repro is with Zed commit 9f61b4e.

This is based on the same repro as shown in #5031 that uses input data results1.csv and results2.csv.

At first I didn't realize there was an auto-detect problem with one of my CSV input files. So when my program looked like this repro-no-format.zed:

file results1.csv
| inner join (
  file results2.csv
) on machine_name=machine_name zed_results:=this
| over this with zed_results => (
  switch (
    case true => yield zed_results
  )
)

It appeared to run successfully but produced no output.

$ zq -version
Version: v1.13.0-12-g9f61b4ea

$ zq -I repro-no-format.zed 

$ echo $?
0

After scratching my head for a bit, I saw the format problem.

$ zq results1.csv 
results1.csv: ZSON syntax error

Once I added the format directives as shown in #5031 the data could be read successfully and I could see the panic. But I'd have expected the auto-detect error to have been shown in the absence of the explicit format.

philrz avatar Feb 14 '24 00:02 philrz

I checked in on this one as of super commit cc68d89 and confirmed it's still with us. Here's the updated query with current syntax for future repro:

$ cat repro-no-format.spq 
from results1.csv
| inner join (
  from results2.csv
) on left.machine_name=right.machine_name
| values {...left, zed_results:right}
| over this with zed_results into (
  switch
    case true ( values zed_results )
)

$ super -version
Version: cc68d890f

$ super -I repro-no-format.spq 
[no output]

$ echo $?
0

philrz avatar Jul 07 '25 20:07 philrz