Class SparkSql
java.lang.Object
com.hw.langchain.utilities.spark.sql.SparkSql
- Author:
- HamaWhite
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SparkSql
Creating a remote Spark Session via Spark connect.getSampleSparkRows
(String table) getTableInfo
(Set<String> tableNames) getTableInfoNoThrow
(Set<String> tableNames) Get information about specified tables.Get names of tables available.init()
runNoThrow
(String command) runNoThrow
(String command, FetchType fetch) Execute a SQL command and return a string representing the results.
-
Constructor Details
-
SparkSql
public SparkSql()
-
-
Method Details
-
init
-
fromUri
Creating a remote Spark Session via Spark connect.- Parameters:
databaseUri
- The database URI, e.g., "sc://localhost:15002".- Returns:
- A SparkSql instance.
-
getUsableTableNames
Get names of tables available. -
getTableInfo
-
getSampleSparkRows
-
run
-
getTableInfoNoThrow
Get information about specified tables.Follows best practices as specified in: Rajkumar et al, 2022
If `sample_rows_in_table_info`, the specified number of sample rows will be appended to each table description. This can increase performance as demonstrated in the paper.
-
runNoThrow
Execute a SQL command and return a string representing the results.If the statement returns rows, a string of the results is returned. If the statement returns no rows, an empty string is returned. If the statement throws an error, the error message is returned.
-
runNoThrow
-