{"record":{"id":"4bcef24c795aba20","repo":"apache/beam","slug":"error-in-computing-splits-getsplits-returns-a-empty-list","errorCode":null,"errorMessage":"Error in computing splits, getSplits() returns a empty list","messagePattern":"Error in computing splits, getSplits\\(\\) returns a empty list","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java","lineNumber":798,"sourceCode":"    }\n\n    /**\n     * This is a helper function to compute splits. This method will also calculate size of the data\n     * being read. Note: This method is executed exactly once and the splits are retrieved and\n     * cached in this. These splits are further used by split() and getEstimatedSizeBytes().\n     */\n    @VisibleForTesting\n    void computeSplitsIfNecessary() throws IOException, InterruptedException {\n      if (inputSplits != null) {\n        return;\n      }\n      createInputFormatInstance();\n      List<InputSplit> splits = inputFormatObj.getSplits(Job.getInstance(conf.get()));\n      if (splits == null) {\n        throw new IOException(\"Error in computing splits, getSplits() returns null.\");\n      }\n      if (splits.isEmpty()) {\n        throw new IOException(\"Error in computing splits, getSplits() returns a empty list\");\n      }\n      boundedSourceEstimatedSize = 0;\n      inputSplits = new ArrayList<>();\n      for (InputSplit inputSplit : splits) {\n        if (inputSplit == null) {\n          throw new IOException(\n              \"Error in computing splits, split is null in InputSplits list \"\n                  + \"populated by getSplits() : \");\n        }\n        boundedSourceEstimatedSize += inputSplit.getLength();\n        inputSplits.add(new SerializableSplit(inputSplit));\n      }\n    }\n\n    /**\n     * Creates instance of InputFormat class. The InputFormat class name is specified in the Hadoop\n     * configuration.\n     */","sourceCodeStart":780,"sourceCodeEnd":816,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java#L780-L816","documentation":"computeSplitsIfNecessary() throws IOException(\"Error in computing splits, getSplits() returns a empty list\") when the Hadoop InputFormat returns zero input splits. Beam cannot build a BoundedSource from an InputFormat that yields no splits, as there would be nothing to read.","triggerScenarios":"split() or getEstimatedSizeBytes() triggering computeSplitsIfNecessary where inputFormatObj.getSplits(Job) returns an empty list — e.g. the configured input path is empty, doesn't exist, or all files are filtered out.","commonSituations":"Pointing the job at an empty or wrong input directory; input files hidden by the format's path filter (e.g. _-prefixed files); time-partitioned datasets where the requested window has no data; misconfigured table/database for formats like DBInputFormat with a query matching no rows.","solutions":["Verify the input path exists and contains readable data files (hdfs dfs -ls <path>).","Check format-specific filters/configs (e.g. mapreduce.input.fileinputformat.inputdir, file name filters) that might exclude all files.","If empty input is legitimate, skip the HadoopFormatIO read for that run or wrap the expand in a check on data availability.","Fix the InputFormat so it surfaces an actionable error or the job supplies correct configuration before Beam expansion."],"exampleFix":"// before\nconf.set(\"mapreduce.input.fileinputformat.inputdir\", \"hdfs://cluster/data/\"); // empty dir\n// after\nconf.set(\"mapreduce.input.fileinputformat.inputdir\", \"hdfs://cluster/data/2026/09/12/\");","handlingStrategy":"validation","validationCode":"Path in = new Path(conf.get(\"mapreduce.input.fileinputformat.inputdir\"));\nFileSystem fs = in.getFileSystem(conf);\nif (!fs.exists(in) || fs.listStatus(in, p -> !p.getName().startsWith(\"_\")).length == 0) { throw new IllegalStateException(\"No input data at \" + in); }","typeGuard":"null","tryCatchPattern":"try { p.apply(read); } catch (IOException e) { if (e.getMessage().contains(\"returns a empty list\")) { LOG.warn(\"No input splits; skipping HadoopFormatIO read\"); return; } throw e; }","preventionTips":["Check the input path for data before launching the pipeline","Beware filter rules (e.g. files starting with _) that hide all inputs","Handle legitimately empty datasets upstream by skipping the read"],"tags":["java","hadoop","inputformat","empty-input"],"backgroundTag":"empty-result-set","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}