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: 

Forum Posts

Christine
by • Contributor II
  • 20400 Views
  • 2 replies
  • 2 kudos

ADD COLUMN IF NOT EXISTS does not recognize "IF NOT EXIST". How do I add a column to an existing delta table with SQL if the column does not already exist?

How do I add a column to an existing delta table with SQL if the column does not already exist?I am using the following code: <%sqlALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name type; >but it prints the error: <[PARSE_SYNTAX_ERROR] Synta...

  • 20400 Views
  • 2 replies
  • 2 kudos
Latest Reply
Woldie
New Contributor II
  • 2 kudos

Here some SQL devilry that does not require SQL Scripting nor pythons.  It adds a my_extra_column FLOAT to the target table with null values. I'm as shocked as anyone that this works, (and if it's undocumented behavior, someone in Databricks Command ...

  • 2 kudos
1 More Replies
Gilg
by • Contributor II
  • 7964 Views
  • 2 replies
  • 0 kudos

Adding column as StructType

Hi Team,Just wondering, how can I add a column to an existing table.I'd tried the below script but giving me an error:ParseException: [PARSE_SYNTAX_ERROR] Syntax error at or near '<'(line 1, pos 121)ALTER TABLE table_clone ADD COLUMNS col_name1 STRUC...

  • 7964 Views
  • 2 replies
  • 0 kudos
Latest Reply
sandeepmankikar
Databricks Partner
  • 0 kudos

To add a STRUCT column to an existing table, use the correct syntax without $ symbols, such as ALTER TABLE table_clone ADD COLUMNS (col_name1 STRUCT<type: STRING, values: ARRAY<STRING>>)

  • 0 kudos
1 More Replies
Labels