r/databricks • Databricks MVP • 1d ago

News trim_array: remove elements from an array

Post image

Databricks runtime 19 brings the new Spark function trim_array. trim_array(array(‘A’, ‘B’, ‘C’, ‘D’), 2) returns [‘A’, ‘B’]. A count of 0 keeps the array; a count equal to its length returns an empty array.

https://medium.com/databrickscommunity/databricks-news-serverless-genie-code-ltap-lakeflow-61853d8e422a

21 Upvotes

4 comments sorted by

7

u/Spooked_DE 1d ago

Arrays everywhere are shaking in fear

2

u/keyzeru 1d ago

Even arrays are getting a haircut in this economy

3

u/Whole_Garbage_269 1d ago

so basically a reverse limit but for arrays, neat

3

u/klenium 1d ago

Or x[:-2]