brimdata / zed

A novel data lake based on super-structured data
https://zed.brimdata.io/
BSD 3-Clause "New" or "Revised" License
1.38k stars 67 forks source link

zq "rare surprise" when Zed query clashes with filename #5084

Open philrz opened 6 months ago

philrz commented 6 months ago

At the time this issue is being filed, Zed is at commit 08c04de.

As divulged in the zq usage docs (emphasis added):

To determine whether the first argument is a query or an input, zq checks the local file system for the existence of a file by that name or whether the name is an URL. If no such file or URL exists, it attempts to parse the text as a Zed program. If both checks fail, then an error is reported and zq exits. This heuristic is convenient but can result in a rare surprise when a simple Zed query (like a keyword search) happens to correspond with a file of the same name in the local directory.

As described in #5052, at one time we envisioned a -query flag that could help here. It was described at one time as:

To avoid this [surprise], you can provide the query with the -query flag, which specifies the Zed program to run and forces all arguments to be interpreted as inputs.

Of course, there may be other ways to address this.

In any case, this issue can remain open as a reminder that we're currently accepting our users' exposure to this "rare surprise", so comments can be added here if users bump into it and help determine if/when we might want to revisit the topic.