Search code examples
apache-drill

Querying subdirectories using drill


I have a parent Folder called Job_1 and i have different subdirectories from 0 -10 and in each of 0 to 10 folders i have different file called property and address.

  SELECT
  COUNT(LOCID)
  FROM dfs.`/Desktop/DataValidation/outputfiles/Job_1/`
  WHERE NUMBLDGS > 1

Job_1 has folders 0 -10 and the file is property.txt but the folder has other text files as well called accounts and so on... for a single folder the query looks like

  SELECT
  COUNT(LOCID)
  FROM dfs.`/Desktop/DataValidation/outputfiles/Job_1/0/property.txt`
  WHERE NUMBLDGS > 1

How can I run one single query against all sub directories 0 -10 and against property.txt?


Solution

  • you can use wildcards:

    SELECT COUNT(LOCID) FROM dfs.`/Desktop/DataValidation/outputfiles/Job_1/*/property.txt` WHERE NUMBLDGS > 1