ala commented on PR #58282: URL: https://github.com/apache/spark/pull/58282#issuecomment-5440403157
Sure! I work most often with Delta, which uses Spark's error message infra, so here's two recent examples from that project: ### DELTA_NON_PARTITION_COLUMN_ABSENT.ALL_PARTITION_COLUMNS https://github.com/delta-io/delta/pull/7416/changes We had to settle on an awkwardly redundant message, because the we couldn't raise the main error class without a subclass: > "Data written into Delta needs to contain at least one non-partitioned column. All of the provided columns are partition columns." ```json "DELTA_NON_PARTITION_COLUMN_ABSENT" : { "message" : [ "Data written into Delta needs to contain at least one non-partitioned column." ], "subClass" : { "ALL_PARTITION_COLUMNS" : { "message" : [ "All of the provided columns are partition columns." ] }, "NULL_TYPE_COLUMNS_DROPPED" : { "message" : [ "Columns which are of NullType have been dropped." ] } }, "sqlState" : "KD005" }, ``` ### DELTA_UNSUPPORTED_DROP_COLUMN Right now a complex message is hard-coded in the Scala code. We would like to move it into a subclass in JSON, but we don't want to create an awkward "no advice" default. Hence, we're blocked by this change. ```scala protected def columnMappingAdviceMessage( requiredProtocol: Protocol = ColumnMappingTableFeature.minProtocolVersion): String = { val readerVersion = requiredProtocol.minReaderVersion val writerVersion = requiredProtocol.minWriterVersion s""" |Please enable Column Mapping on your Delta table with mapping mode 'name'. |You can use one of the following commands. | |ALTER TABLE table_name SET TBLPROPERTIES ('delta.columnMapping.mode' = 'name') | |Note, if your table is not on the required protocol version it will be upgraded. |Column mapping requires at least protocol ($readerVersion, $writerVersion) |""".stripMargin } ``` ```scala def dropColumnNotSupported(suggestUpgrade: Boolean): Throwable = { val adviceMsg = if (suggestUpgrade) columnMappingAdviceMessage() else "" new DeltaAnalysisException("DELTA_UNSUPPORTED_DROP_COLUMN", Array(adviceMsg)) } ``` ```json "DELTA_UNSUPPORTED_DROP_COLUMN" : { "message" : [ "DROP COLUMN is not supported for your Delta table. <advice>" ], "sqlState" : "0AKDC" }, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
