Help Center/ MapReduce Service/ Component Operation Guide (LTS)/ Using Spark/Spark2x/ Common Issues About Spark/ Why Does Spark Fail to Query Data Written by the Union Statement Running on Tez?
Updated on 2026-06-27 GMT+08:00

Why Does Spark Fail to Query Data Written by the Union Statement Running on Tez?

Symptom

Hive uses the Tez engine to execute union-related statements to write data. After Hive is switched to the Spark engine for query, no data is found.

Solution

When Hive uses the Tez engine to execute the union-related statement, the generated output file is stored in the HIVE_UNION_SUBDIR directory. After Hive is switched back to the Spark engine, files in the directory are not read by default. Therefore, data in the HIVE_UNION_SUBDIR directory is not queried.

In this case, you can set set mapreduce.input.fileinputformat.input.dir.recursive to true to enable union optimization and determine whether to read data in the directory.

  • The ORC table needs to be configured as follows:

    set spark.sql.hive.convertMetastoreOrc=false

  • The Parquet table needs to be configured as follows:

    set spark.sql.hive.convertMetastoreParquet=false