From 1830b54f79d73e3de44d79750081a4f00f309924 Mon Sep 17 00:00:00 2001 From: jackylee Date: Mon, 10 Aug 2026 18:54:07 +0800 Subject: [PATCH] fix(spark): keep the cause when a path cannot be loaded as a table loadTable translates a failed schema inference into NoSuchTableException so SQL users see "table not found", but it discarded the original exception entirely. That threw away the message naming the offending path, and collapsed a credentials error or an unsupported Arrow type into the same "not found" as an empty directory. NoSuchTableException has no cause-accepting constructor common to the supported Spark versions, so carry the original as a suppressed exception and log it at warn. Signed-off-by: jackylee --- .../main/java/dev/vortex/spark/VortexCatalog.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/java/vortex-spark/src/main/java/dev/vortex/spark/VortexCatalog.java b/java/vortex-spark/src/main/java/dev/vortex/spark/VortexCatalog.java index 3d496a4cee0..2bd4fd3273d 100644 --- a/java/vortex-spark/src/main/java/dev/vortex/spark/VortexCatalog.java +++ b/java/vortex-spark/src/main/java/dev/vortex/spark/VortexCatalog.java @@ -12,6 +12,8 @@ import org.apache.spark.sql.connector.expressions.Transform; import org.apache.spark.sql.types.StructType; import org.apache.spark.sql.util.CaseInsensitiveStringMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A path-based Spark catalog for querying Vortex files directly from SQL. @@ -30,6 +32,8 @@ * vortex.`/path/to/data`}), and pushdown all behave identically. The catalog holds no state and supports no DDL. */ public final class VortexCatalog implements TableCatalog { + private static final Logger log = LoggerFactory.getLogger(VortexCatalog.class); + private static final String PATH_KEY = "path"; private String name = "vortex"; @@ -85,8 +89,14 @@ public Table loadTable(Identifier ident) throws NoSuchTableException { schema = provider.inferSchema(options); partitioning = provider.inferPartitioning(options); } catch (RuntimeException e) { - // Missing or unreadable paths surface as "table not found" to SQL users. - throw new NoSuchTableException(ident); + // Missing or unreadable paths surface as "table not found" to SQL users. NoSuchTableException + // has no cause-accepting constructor common to the supported Spark versions, so carry the + // original failure as a suppressed exception and log it: it names the offending path and + // distinguishes an empty directory from a credentials or unsupported-type error. + log.warn("Cannot load {} as a Vortex table, reporting it as not found", path, e); + NoSuchTableException notFound = new NoSuchTableException(ident); + notFound.addSuppressed(e); + throw notFound; } return provider.getTable(schema, partitioning, Map.of(PATH_KEY, path)); }