This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 42e3f22a68a5103cfe21389546b34e5837245e97
Author: Steve Carlin <[email protected]>
AuthorDate: Mon Oct 7 12:01:13 2024 -0700

    IMPALA-13425: Iceberg tables crash server with Calcite planner
    
    This commit will prevent the server from crashing by catching Iceberg
    tables at compile time in the Calcite planner and failing the query.
    
    Change-Id: I4b7c889d4aa61888feeacb29366ec559000a943e
    Reviewed-on: http://gerrit.cloudera.org:8080/21902
    Reviewed-by: Michael Smith <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 .../main/java/org/apache/impala/calcite/schema/CalciteDb.java  |  3 ++-
 .../java/org/apache/impala/calcite/schema/CalciteTable.java    | 10 +++++++++-
 .../apache/impala/calcite/service/CalciteMetadataHandler.java  |  2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteDb.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteDb.java
index 9e4890a63..e0f5caf42 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteDb.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteDb.java
@@ -22,6 +22,7 @@ import org.apache.calcite.prepare.CalciteCatalogReader;
 import org.apache.calcite.schema.Table;
 import org.apache.calcite.schema.impl.AbstractSchema;
 import org.apache.impala.catalog.FeTable;
+import org.apache.impala.common.ImpalaException;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -48,7 +49,7 @@ public class CalciteDb extends AbstractSchema {
       this.reader_ = reader;
     }
 
-    public Builder addTable(String tableName, FeTable table) {
+    public Builder addTable(String tableName, FeTable table) throws 
ImpalaException {
       if (!tableMap_.containsKey(tableName)) {
         tableMap_.put(tableName.toLowerCase(), new CalciteTable(table, 
reader_));
       }
diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteTable.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteTable.java
index 0fa849f84..7fc45efdc 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteTable.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteTable.java
@@ -51,12 +51,14 @@ import org.apache.impala.catalog.Column;
 import org.apache.impala.catalog.FeFsPartition;
 import org.apache.impala.catalog.FeTable;
 import org.apache.impala.catalog.HdfsTable;
+import org.apache.impala.catalog.IcebergTable;
 import org.apache.impala.calcite.type.ImpalaTypeConverter;
 import org.apache.impala.calcite.type.ImpalaTypeSystemImpl;
 import org.apache.impala.planner.HdfsPartitionPruner;
 import org.apache.impala.common.AnalysisException;
 import org.apache.impala.common.ImpalaException;
 import org.apache.impala.common.Pair;
+import org.apache.impala.common.UnsupportedFeatureException;
 
 import com.google.common.collect.ImmutableList;
 
@@ -72,10 +74,16 @@ public class CalciteTable extends RelOptAbstractTable
 
   private final List<String> qualifiedTableName_;
 
-  public CalciteTable(FeTable table, CalciteCatalogReader reader) {
+  public CalciteTable(FeTable table, CalciteCatalogReader reader)
+      throws ImpalaException {
     super(reader, table.getName(), buildColumnsForRelDataType(table));
     this.table_ = (HdfsTable) table;
     this.qualifiedTableName_ = table.getTableName().toPath();
+
+    if (table instanceof IcebergTable) {
+      throw new UnsupportedFeatureException("Calcite parser does not support " 
+
+          "Iceberg tables yet.");
+    }
   }
 
   private static RelDataType buildColumnsForRelDataType(FeTable table) {
diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteMetadataHandler.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteMetadataHandler.java
index 6e24eb1a7..ed0969fc2 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteMetadataHandler.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteMetadataHandler.java
@@ -121,7 +121,7 @@ public class CalciteMetadataHandler implements CompilerStep 
{
    * Populate the CalciteSchema with tables being used by this query.
    */
   private void populateCalciteSchema(CalciteCatalogReader reader,
-      FeCatalog catalog, Set<TableName> tableNames) {
+      FeCatalog catalog, Set<TableName> tableNames) throws ImpalaException {
     CalciteSchema rootSchema = reader.getRootSchema();
     Map<String, CalciteDb.Builder> dbSchemas = new HashMap<>();
     for (TableName tableName : tableNames) {

Reply via email to