# SparkSQL

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL)

SparkSQL is a utility class for interacting with Spark SQL.

## Signature

```python
SparkSQL(
    self,
    spark_session: Optional[SparkSession] = None,
    catalog: Optional[str] = None,
    schema: Optional[str] = None,
    ignore_tables: Optional[List[str]] = None,
    include_tables: Optional[List[str]] = None,
    sample_rows_in_table_info: int = 3,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `spark_session` | `Optional[SparkSession]` | No | A SparkSession object. If not provided, one will be created. (default: `None`) |
| `catalog` | `Optional[str]` | No | The catalog to use. If not provided, the default catalog will be used. (default: `None`) |
| `schema` | `Optional[str]` | No | The schema to use. If not provided, the default schema will be used. (default: `None`) |
| `ignore_tables` | `Optional[List[str]]` | No | A list of tables to ignore. If not provided, all tables will be used. (default: `None`) |
| `include_tables` | `Optional[List[str]]` | No | A list of tables to include. If not provided, all tables will be used. (default: `None`) |
| `sample_rows_in_table_info` | `int` | No | The number of rows to include in the table info. Defaults to 3. (default: `3`) |

## Constructors

```python
__init__(
    self,
    spark_session: Optional[SparkSession] = None,
    catalog: Optional[str] = None,
    schema: Optional[str] = None,
    ignore_tables: Optional[List[str]] = None,
    include_tables: Optional[List[str]] = None,
    sample_rows_in_table_info: int = 3,
)
```

| Name | Type |
|------|------|
| `spark_session` | `Optional[SparkSession]` |
| `catalog` | `Optional[str]` |
| `schema` | `Optional[str]` |
| `ignore_tables` | `Optional[List[str]]` |
| `include_tables` | `Optional[List[str]]` |
| `sample_rows_in_table_info` | `int` |


## Methods

- [`from_uri()`](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL/from_uri)
- [`get_usable_table_names()`](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL/get_usable_table_names)
- [`get_table_info()`](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL/get_table_info)
- [`run()`](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL/run)
- [`get_table_info_no_throw()`](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL/get_table_info_no_throw)
- [`run_no_throw()`](https://reference.langchain.com/python/langchain-community/utilities/spark_sql/SparkSQL/run_no_throw)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/utilities/spark_sql.py#L9)