Forum Discussion

PraveenVeli's avatar
PraveenVeli
Advocate I
1 year ago
Solved

Max iterations (100) reached for batch Resolution, please set 'spark.sql.analyzer.maxIterations' to

Hi, I'm encountering the error 'Max iterations (100) reached for batch Resolution, please set 'spark.sql.analyzer.maxIterations' to a larger value.' while executing a Spark SQL script from the noteb...
  • nilendraFabric's avatar
    1 year ago

    Hello PraveenVeli 


    In Spark SQL’s context, “iterations” refer to the number of passes the query analyzer makes through the logical query plan to resolve references, infer types, and apply optimizations

     

     

    Why This Applies to Your Fabric Scenario
    1. Workspace Boundary Resolution
    3. Fabric treats Lakehouses in different workspaces as separate catalogs, forcing Spark to:
    • Verify table existence in both environments
    • Reconcile schemas across workspaces
    • Handle potential credential handoffs

     

    Even for 1k rows comparison 

     

    -- Implicitly creates nested plans for:
    1) Data fetch from Lakehouse A
    2) Data fetch from Lakehouse B
    3) Join operation
    4) Delta transaction log checks
    5) Insert operation

     

    Try

    spark.conf.set("spark.sql.analyzer.maxIterations", "200")

     

    And do df.explain(mode="extended")

    Look for Cartesian products or complex subquery patterns

    Try

     

    OPTIMIZE delta_table ZORDER BY primary_key;

     

    please give a try and let me know if this works