Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support Spark SQL Agent #53

Closed
HamaWhiteGG opened this issue Jul 22, 2023 · 1 comment
Closed

[Feature] Support Spark SQL Agent #53

HamaWhiteGG opened this issue Jul 22, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@HamaWhiteGG
Copy link
Owner

https://python.langchain.com/docs/modules/agents/toolkits/spark_sql

@HamaWhiteGG HamaWhiteGG added the enhancement New feature or request label Jul 22, 2023
@HamaWhiteGG HamaWhiteGG self-assigned this Jul 22, 2023
HamaWhiteGG added a commit that referenced this issue Jul 22, 2023
HamaWhiteGG added a commit that referenced this issue Jul 22, 2023
@HamaWhiteGG
Copy link
Owner Author

I have implemented a local version that allows you to view SparkSqlToolkitTest.

@Test
void testRunningQuery() {
    var sparkSql = SparkSql.builder()
            .spark(spark)
            .schema(SCHEMA)
            .build().init();

    var llm = ChatOpenAI.builder()
            .temperature(0)
            .build().init();

    var toolkit = new SparkSqlToolkit(sparkSql, llm);
    var agentExecutor = createSparkSqlAgent(llm, toolkit);

    // SELECT SQRT(AVG(Age)) FROM titanic
    var actual = agentExecutor.run("whats the square root of the average age?");
    // sometimes it's 'The square root of the average age is approximately 5.45.'
    assertEquals("5.45", actual);

    // SELECT Name FROM titanic WHERE Survived = 1 ORDER BY Age DESC LIMIT 1
    actual = agentExecutor.run("What's the name of the oldest survived passenger?");
    assertEquals("Barkworth, Mr. Algernon Henry Wilson", actual);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant