{"record":{"id":"6dc28480b6abfd9b","repo":"apache/iceberg","slug":"showcreatetablenotsupportedonmetricviewerror-quote","errorCode":null,"errorMessage":"showCreateTableNotSupportedOnMetricViewError(quotedName)","messagePattern":"showCreateTableNotSupportedOnMetricViewError\\(quotedName\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ExtendedDataSourceV2Strategy.scala","lineNumber":178,"sourceCode":"        query,\n        allowExisting,\n        replace,\n        viewSchemaMode) :: Nil\n\n    case DescribeRelation(ResolvedV2View(catalog, ident, view), isExtended, output) =>\n      IcebergDescribeV2ViewExec(output, catalog.name(), ident, view, isExtended) :: Nil\n\n    case ShowTableProperties(ResolvedV2View(catalog, ident, view), propertyKey, output) =>\n      IcebergShowV2ViewPropertiesExec(output, catalog.name(), ident, view, propertyKey) :: Nil\n\n    case ShowIcebergViews(ResolvedNamespace(catalog: ViewCatalog, namespace, _), pattern, output) =>\n      ShowV2ViewsExec(output, catalog, namespace, pattern) :: Nil\n\n    case ShowCreateTable(ResolvedV2View(catalog, ident, view), _, output) =>\n      val quotedName = (catalog.name() +: ident.asMultipartIdentifier).quoted\n      if (view.properties.get(TableCatalog.PROP_TABLE_TYPE) ==\n          TableSummary.METRIC_VIEW_TABLE_TYPE) {\n        throw QueryCompilationErrors.showCreateTableNotSupportedOnMetricViewError(quotedName)\n      }\n\n      IcebergShowCreateV2ViewExec(output, quotedName, view) :: Nil\n\n    case SetViewProperties(ResolvedV2View(catalog, ident, _), properties) =>\n      IcebergAlterV2ViewSetPropertiesExec(catalog, ident, properties) :: Nil\n\n    case UnsetViewProperties(ResolvedV2View(catalog, ident, _), propertyKeys, ifExists) =>\n      IcebergAlterV2ViewUnsetPropertiesExec(catalog, ident, propertyKeys, ifExists) :: Nil\n\n    case _ => Nil\n  }\n\n  private object IcebergCatalogAndIdentifier {\n    def unapply(identifier: Seq[String]): Option[(TableCatalog, Identifier)] = {\n      val catalogAndIdentifier = Spark3Util.catalogAndIdentifier(spark, identifier.asJava)\n      catalogAndIdentifier.catalog match {\n        case icebergCatalog: SparkCatalog =>","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ExtendedDataSourceV2Strategy.scala#L160-L196","documentation":"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.","triggerScenarios":"Running `SHOW CREATE TABLE <metric_view>` (parsed as ShowCreateTable over a ResolvedV2View) where the view's properties contain table.type = metric-view in ExtendedDataSourceV2Strategy.","commonSituations":"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.","solutions":["Don't run SHOW CREATE TABLE on metric views — query the view's metadata/properties instead (DESCRIBE VIEW EXTENDED, SHOW TBLPROPERTIES)","Filter metric views out of catalog-inspection scripts (skip views where table.type = 'metric-view')","Recreate the metric view through the API/engine that owns it rather than copying DDL"],"exampleFix":"// before\nspark.sql(s\"SHOW CREATE TABLE $ident\") // throws for metric views\n// after\nval props = spark.sql(s\"SHOW TBLPROPERTIES $ident\")\nval isMetric = props.collect().exists(r => r.getString(0) == \"table.type\" && r.getString(1) == \"metric-view\")\nif (!isMetric) spark.sql(s\"SHOW CREATE TABLE $ident\")","handlingStrategy":"validation","validationCode":"val props = spark.sql(s\"SHOW TBLPROPERTIES $ident\").collect()\nval isMetricView = props.exists(r => r.getString(0) == \"table.type\" &&\n  r.getString(1) == \"metric-view\")\nif (isMetricView) skipShowCreateTable(ident)","typeGuard":"def isMetricView(viewProps: Map[String, String]): Boolean =\n  viewProps.get(\"table.type\").contains(\"metric-view\")","tryCatchPattern":"try {\n  spark.sql(s\"SHOW CREATE TABLE $ident\")\n} catch {\n  case e: AnalysisException if e.getMessage.contains(\"SHOW CREATE TABLE\") && e.getMessage.contains(\"metric\") =>\n    // metric views have no DDL representation; read properties instead\n    spark.sql(s\"SHOW TBLPROPERTIES $ident\")\n}","preventionTips":["Filter out metric views (table.type = metric-view) in scripts that iterate all views","Use SHOW TBLPROPERTIES / DESCRIBE VIEW for inspecting metric views"],"tags":["spark","views","metric-view","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}