0|     3|Andersson, Mr. An...|  male|39.0|    1|    5|          347082| 31.275| null|       S|    |         15|       0|     3|Vestrom, Miss. Hu...|female|14.0|    0|    0|          350406| 7.8542| null|       S|    |         16|       1|     2|Hewlett, Mrs. (Ma...|female|55.0|    0|    0|          248706|   16.0| null|       S|    |         17|       0|     3|Rice, Master. Eugene|  male| 2.0|    4|    1|          382652| 29.125| null|       Q|    |         18|       1|     2|Williams, Mr. Cha...|  male|null|    0|    0|          244373|   13.0| null|       S|    |         19|       0|     3|Vander Planke, Mr...|female|31.0|    1|    0|          345763|   18.0| null|       S|    |         20|       1|     3|Masselmani, Mrs. ...|female|null|    0|    0|            2649|  7.225| null|       C|    +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+    only showing top 20 rows    # Note, you can also connect to Spark via Spark connect. For example:# db = SparkSQL.from_uri("sc://localhost:15002", schema=schema)spark_sql = SparkSQL(schema=schema)llm = ChatOpenAI(temperature=0)toolkit = SparkSQLToolkit(db=spark_sql, llm=llm)agent_executor = create_spark_sql_agent(llm=llm, toolkit=toolkit, verbose=True)Example: describing a table‚Äãagent_executor.run("Describe the titanic table")            > Entering new AgentExecutor chain...    Action: list_tables_sql_db    Action Input:     Observation: titanic    Thought:I found the titanic table. Now I need to get the schema and sample rows for the titanic table.    Action: schema_sql_db    Action Input: titanic    Observation: CREATE TABLE langchain_example.titanic (      PassengerId INT,      Survived INT,      Pclass INT,      Name STRING,      Sex STRING,      Age DOUBLE,      SibSp INT,      Parch INT,      Ticket STRING,      Fare DOUBLE,      Cabin STRING,      Embarked STRING)    ;        /*    3 rows from titanic table:    PassengerId Survived    Pclass
This notebook shows how to use agents to interact with Spark SQL. Similar to SQL Database Agent, it is designed to address general inquiries about Spark SQL and facilitate error recovery.
This notebook shows how to use agents to interact with Spark SQL. Similar to SQL Database Agent, it is designed to address general inquiries about Spark SQL and facilitate error recovery. ->: 0|     3|Andersson, Mr. An...|  male|39.0|    1|    5|          347082| 31.275| null|       S|    |         15|       0|     3|Vestrom, Miss. Hu...|female|14.0|    0|    0|          350406| 7.8542| null|       S|    |         16|       1|     2|Hewlett, Mrs. (Ma...|female|55.0|    0|    0|          248706|   16.0| null|       S|    |         17|       0|     3|Rice, Master. Eugene|  male| 2.0|    4|    1|          382652| 29.125| null|       Q|    |         18|       1|     2|Williams, Mr. Cha...|  male|null|    0|    0|          244373|   13.0| null|       S|    |         19|       0|     3|Vander Planke, Mr...|female|31.0|    1|    0|          345763|   18.0| null|       S|    |         20|       1|     3|Masselmani, Mrs. ...|female|null|    0|    0|            2649|  7.225| null|       C|    +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+    only showing top 20 rows    # Note, you can also connect to Spark via Spark connect. For example:# db = SparkSQL.from_uri("sc://localhost:15002", schema=schema)spark_sql = SparkSQL(schema=schema)llm = ChatOpenAI(temperature=0)toolkit = SparkSQLToolkit(db=spark_sql, llm=llm)agent_executor = create_spark_sql_agent(llm=llm, toolkit=toolkit, verbose=True)Example: describing a table‚Äãagent_executor.run("Describe the titanic table")            > Entering new AgentExecutor chain...    Action: list_tables_sql_db    Action Input:     Observation: titanic    Thought:I found the titanic table. Now I need to get the schema and sample rows for the titanic table.    Action: schema_sql_db    Action Input: titanic    Observation: CREATE TABLE langchain_example.titanic (      PassengerId INT,      Survived INT,      Pclass INT,      Name STRING,      Sex STRING,      Age DOUBLE,      SibSp INT,      Parch INT,      Ticket STRING,      Fare DOUBLE,      Cabin STRING,      Embarked STRING)    ;        /*    3 rows from titanic table:    PassengerId Survived    Pclass