Search code examples
javaapache-drill

Apache Drill check structure of files in directory


I'm working with Apache Drill from java code. Drill have ability to query directory with a bunch of files as one table. But if files in directory have different structure query will fail. I understand that it's not very common use case query directory with files of different structure, but is there any build in function or query which allow me to check that all files in directory have same structure before making any real queries to directory?

I understand that I can do simple

select * from path.to.directory limit 1;

and catch exception, but I'm searching for Drill built in function. I search in documentation, but did not find anything.


Solution

  • There does not seem to be an out of the box feature for checking the data store before use it. This is not surprising for me. For example, if you consider relational databases, you do not explicitly check the connection to a database or check if it is data is not corrupted every time you execute a select.

    However, if you really need this, you may consider coding an ad-hoc check on the files or writing a custom drill function for that as described here.