apache/druid · error · IllegalArgumentException

Only one directory argument is supported!

Error message

Only one directory argument is supported!

What it means

ParquetToJson is a CLI utility that converts a single Parquet directory to JSON. getInputFiles() validates that exactly one directory argument was supplied; zero or multiple directories, or a non-directory path, throw IllegalArgumentException.

Solutions

  1. Invoke the tool with exactly one directory argument containing the parquet files
  2. Run the tool once per directory instead of passing multiple directories
  3. Verify the argument points to a directory (not a single parquet file)

Example fix

// before
ParquetToJson dir1 dir2
// after
ParquetToJson dir1
ParquetToJson dir2
Defensive patterns

Strategy: validation

Validate before calling

if (args.length != 1 || !new File(args[0]).isDirectory()) { throw new IllegalArgumentException("Usage: ParquetToJson <single-directory>"); }

Try / catch

try { tool.run(args); } catch (IAE e) { if (e.getMessage().contains("Only one directory")) { System.err.println("Usage: ParquetToJson <dir>"); System.exit(2); } throw e; }

Prevention

When it happens

Trigger: Running the ParquetToJson tool with no directory argument, with more than one directory argument, or with a path that is not a directory.

Common situations: Passing multiple parquet dirs expecting batch conversion; quoting mistakes splitting one path into two args; passing a file path instead of the directory containing parquet files.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/768dbb1e44e8fcff. Report an issue: GitHub.

Appendix: source

Thrown at extensions-core/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/ParquetToJson.java:68

  @Option(name = "--convert-corrupt-dates")
  public boolean convertCorruptDates = false;

  @Arguments(description = "directory")
  public List<String> directories;


  public static void main(String[] args) throws Exception
  {
    CliBuilder<Callable> builder = Cli.builder("ParquetToJson");
    builder.withDefaultCommand(ParquetToJson.class);
    builder.build().parse(args).call();
  }

  private File[] getInputFiles()
  {
    if (directories == null || directories.size() != 1) {
      throw new IAE("Only one directory argument is supported!");
    }

    File dir = new File(directories.get(0));
    if (!dir.isDirectory()) {
      throw new IAE("Not a directory [%s]", dir);
    }
    File[] inputFiles = dir.listFiles(
        pathname -> pathname.getName().endsWith(".parquet"));
    if (inputFiles == null || inputFiles.length == 0) {
      throw new IAE("No parquet files in directory [%s]", dir);
    }
    return inputFiles;
  }

  @Override
  public Void call() throws Exception
  {
    ObjectMapper mapper = new DefaultObjectMapper();

View on GitHub (pinned to 9b90983fd2)