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:ย 

sql: how to convert datatype of column?

dan11
New Contributor II

Bricklayers,
I want to port this sql statement from sqlite to databricks:
select cast(myage as number) as my_integer_age from ages;
Does databricks allow me to do something like this?

1 REPLY 1

raela
Databricks Employee
Databricks Employee

@dan11

We don't support

number
in Spark SQL. Try using
int
,
double
,
float
, and your query should be fine. To run SQL in a notebook, just prepend any cell with %sql.

%sql
select cast(myage as double) as my_integer_age from ages;

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group