Forum Discussion

dbeavon3's avatar
dbeavon3
Icon for Memorable Member rankMemorable Member
1 year ago
Solved

Cannot use spark.catalog.listTables in notebook

I have errors when calling spark.catalog.listTables() in fabic, with a default lakehouse connected.   The error is like so:   [PARSE_SYNTAX_ERROR] Syntax error at or near end of input.(line 1, p...
  • v-pnaroju-msft's avatar
    1 year ago

    Thankyou, BhaveshPatel, for your response.

    Hi dbeavon3,

    We appreciate your inquiry submitted through the Microsoft Fabric Community Forum.

    As per my understanding, the error “[PARSE_SYNTAX_ERROR] Syntax error at or near end of input” may occur if the default Lakehouse is not attached, if the Lakehouse is schema enabled which is a known limitation with certain Spark catalog APIs or due to the parsing behavior of Python 3.11 and Delta 3.2 generating invalid SQL for spark.catalog.listTables().

    Kindly follow the steps below to resolve the issue:

    1. Check the default database using spark.catalog.currentDatabase(). If this returns an error or shows default with no tables, you will need to specify your Lakehouse name explicitly.
    2. List the available databases using spark.catalog.listDatabases(). Confirm that your Lakehouse name is present in the list.
    3. Explicitly list tables from the Lakehouse by using spark.catalog.listTables("YourLakehouseName"). Please replace YourLakehouseName with the actual name of your Lakehouse.
    4. Ensure that the notebook has the correct default Lakehouse attached.

    Please find the attached screenshot regarding the schema enabled Lakehouse limitation:

    Additionally, kindly refer to the following link for more information:
    Lakehouse schemas (Preview) - Microsoft Fabric | Microsoft Learn

    We hope that the above information will assist in resolving the issue. Should you have any further queries, please feel free to contact the Microsoft Fabric Community.

    Thank you.