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

using Spark SQL or particularly %SQL in a databricks notebook, is there a way to use pagination or offset or skip ?

User16783853501
New Contributor II

using Spark SQL or particularly %SQL in a databricks notebook, is there a way to use pagination or offset or skip ? 

2 REPLIES 2

aladda
Honored Contributor II

Can you clarify what are you looking for and what your use case is? Are you asking whether there's a preference for using Spark SQL or just direct SQL with %sql or something else?

sajith_appukutt
Honored Contributor II

There is no offset support yet. Here are a few possible workarounds

  • If you data is all in one partition ( rarely the case ๐Ÿ™‚ ) , you could create a column with monotonically_increasing_id and apply filter conditions. if there are multiple partitions, monotonically_increasing_id won't be consecutive

  • Use except ( in your case sql equivalent of code below) . This however would be an expensive operation
df1 = df.limit(10); 
df2 = df.except(df1); 
df2.limit(20);

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