I ran into a situation where drill created an empty metadata file (which is a separate issue and I will try to narrow it down. Suspicion is that this happens when "refresh table metada x" fails with "permission denied" error).
However, we need to guard against situation where metadata file is empty or corrupted. We probably should skip reading it if we encounter unexpected result and continue with query planning without that information. In the same fashion as partition pruning failure. It's also important to log this information somewhere, drillbit.log as a start. It would be really nice to have a flag in the query profile that tells a user if we used metadata file for planning or not. Will help in debugging performance issues.
Very confusing exception is thrown if you have zero length meta data file in the directory:
Workaround is trivial, remove the file. Marking it as critical, since we don't have any concurrency control in place and this file can get corrupted as well.