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
New Contributor III
New Contributor III

@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;

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!