cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a column on the fly which would have same value for all rows in spark sql query

haseebkhan1421
New Contributor

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 table

Now, 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

1 REPLY 1

Ryan_Chynoweth
Esteemed Contributor

The correct syntax would be:

SELECT 'Goal' AS Type, Value 
FROM table

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now