How can I create a column on the fly which would have same value for all rows in spark sql query
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2021 11:46 AM
I have a SQL query which I am converting into spark sql in azure databricks running in my jupyter notebook. In my SQL query, a column named Type is created on the fly which has value 'Goal' for every row:
SELECT Type='Goal', Value FROM tableNow, when I am using the same syntax on the spark sql in my azure databricks notebook, it gives me an error: Error in SQL statement: AnalysisException: cannot resolve '`Type`' given input columns: How can I convert the same logic in azure databrick spark sql
Labels:
- Labels:
-
Azure databricks
-
Spark sql
-
SQL
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2021 02:24 PM
The correct syntax would be:
SELECT 'Goal' AS Type, Value
FROM table