apache/iceberg · error

showCreateTableNotSupportedOnMetricViewError(quotedName)

Error message

showCreateTableNotSupportedOnMetricViewError(quotedName)

What it means

SHOW CREATE TABLE is implemented for Iceberg v2 views via IcebergShowCreateV2ViewExec, but metric views (views whose properties carry PROP_TABLE_TYPE = metric-view / TableSummary.METRIC_VIEW_TABLE_TYPE) have no CREATE representation, so the strategy throws showCreateTableNotSupportedOnMetricViewError with the quoted view name. Metric views are system-generated summaries and cannot round-trip through SHOW CREATE TABLE.

Solutions

  1. Don't run SHOW CREATE TABLE on metric views — query the view's metadata/properties instead (DESCRIBE VIEW EXTENDED, SHOW TBLPROPERTIES)
  2. Filter metric views out of catalog-inspection scripts (skip views where table.type = 'metric-view')
  3. Recreate the metric view through the API/engine that owns it rather than copying DDL

Example fix

// before
spark.sql(s"SHOW CREATE TABLE $ident") // throws for metric views
// after
val props = spark.sql(s"SHOW TBLPROPERTIES $ident")
val isMetric = props.collect().exists(r => r.getString(0) == "table.type" && r.getString(1) == "metric-view")
if (!isMetric) spark.sql(s"SHOW CREATE TABLE $ident")
Defensive patterns

Strategy: validation

Validate before calling

val props = spark.sql(s"SHOW TBLPROPERTIES $ident").collect()
val isMetricView = props.exists(r => r.getString(0) == "table.type" &&
  r.getString(1) == "metric-view")
if (isMetricView) skipShowCreateTable(ident)

Type guard

def isMetricView(viewProps: Map[String, String]): Boolean =
  viewProps.get("table.type").contains("metric-view")

Try / catch

try {
  spark.sql(s"SHOW CREATE TABLE $ident")
} catch {
  case e: AnalysisException if e.getMessage.contains("SHOW CREATE TABLE") && e.getMessage.contains("metric") =>
    // metric views have no DDL representation; read properties instead
    spark.sql(s"SHOW TBLPROPERTIES $ident")
}

Prevention

When it happens

Trigger: Running `SHOW CREATE TABLE <metric_view>` (parsed as ShowCreateTable over a ResolvedV2View) where the view's properties contain table.type = metric-view in ExtendedDataSourceV2Strategy.

Common situations: Inspecting system/metric views created by engines or tooling that auto-creates them; attempting to clone or migrate a metric view by copying its DDL; scripts that SHOW CREATE TABLE all views in a namespace.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/6dc28480b6abfd9b. Report an issue: GitHub.

Appendix: source

Thrown at spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ExtendedDataSourceV2Strategy.scala:178

        query,
        allowExisting,
        replace,
        viewSchemaMode) :: Nil

    case DescribeRelation(ResolvedV2View(catalog, ident, view), isExtended, output) =>
      IcebergDescribeV2ViewExec(output, catalog.name(), ident, view, isExtended) :: Nil

    case ShowTableProperties(ResolvedV2View(catalog, ident, view), propertyKey, output) =>
      IcebergShowV2ViewPropertiesExec(output, catalog.name(), ident, view, propertyKey) :: Nil

    case ShowIcebergViews(ResolvedNamespace(catalog: ViewCatalog, namespace, _), pattern, output) =>
      ShowV2ViewsExec(output, catalog, namespace, pattern) :: Nil

    case ShowCreateTable(ResolvedV2View(catalog, ident, view), _, output) =>
      val quotedName = (catalog.name() +: ident.asMultipartIdentifier).quoted
      if (view.properties.get(TableCatalog.PROP_TABLE_TYPE) ==
          TableSummary.METRIC_VIEW_TABLE_TYPE) {
        throw QueryCompilationErrors.showCreateTableNotSupportedOnMetricViewError(quotedName)
      }

      IcebergShowCreateV2ViewExec(output, quotedName, view) :: Nil

    case SetViewProperties(ResolvedV2View(catalog, ident, _), properties) =>
      IcebergAlterV2ViewSetPropertiesExec(catalog, ident, properties) :: Nil

    case UnsetViewProperties(ResolvedV2View(catalog, ident, _), propertyKeys, ifExists) =>
      IcebergAlterV2ViewUnsetPropertiesExec(catalog, ident, propertyKeys, ifExists) :: Nil

    case _ => Nil
  }

  private object IcebergCatalogAndIdentifier {
    def unapply(identifier: Seq[String]): Option[(TableCatalog, Identifier)] = {
      val catalogAndIdentifier = Spark3Util.catalogAndIdentifier(spark, identifier.asJava)
      catalogAndIdentifier.catalog match {
        case icebergCatalog: SparkCatalog =>

View on GitHub (pinned to 86d9c8fc54)