Translating SQL Value Function For XML To Databricks SQL
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 09:04 AM
Trying to translate this line of a SQL query that evaluates XML to Databricks SQL.
SELECT
MyColumn.value('(/XMLData/Values/ValueDefinition[@colID="10"]/@Value)[1]', 'VARCHAR(max)') as Color
The XML looks like this:
<XMLData><Values><ValueDefinition colID="10" Value="Red"/><ValueDefinition colID="20" Value="Square"/><ValueDefinition colID="3" Value=""/></Values></XMLData>
Databricks SQL doesn't seem to support this function ("AnalysisException: Undefined function: MyColumn.value").
Is there anything I can substitute within the query line that will work?