---
title: inline table-valued generator function
description: Learn the syntax of the inline function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/inline
---

# `inline` table-valued generator function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Explodes an array of structs into a table.

In Databricks SQL and Databricks Runtime 16.1 and above this function supports [named parameter invocation](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-function-invocation.md#named-parameter-invocation).

## Syntax

```
inline(input)
```

## Arguments

* `input`: An `ARRAY<STRUCT>` expression.

## Returns

A set of rows composed of the fields in the struct elements of the array `input`.
The columns produced by `inline` are the names of the fields.

If `input` is `NULL` no rows are produced.

* **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.1 and earlier:

  `inline` can only be placed in the `SELECT` list as the root of an expression or following a [LATERAL VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-lateral-view.md).
  When placing the function in the `SELECT` list there must be no other generator function in the same `SELECT` list or [UNSUPPORTED\_GENERATOR.MULTI\_GENERATOR](https://docs.databricks.com/aws/en/error-messages/unsupported-generator-error-class.md#multi_generator) is raised.

* **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.2 LTS and above:

  Invocation from the [LATERAL VIEW clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-lateral-view.md) or the `SELECT` list is deprecated.
  Instead, invoke `inline` as a [table\_reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-table-reference.md).

## Examples

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.1 and earlier:

```sql
> SELECT inline(array(struct(1, 'a'), struct(2, 'b'))), 'Spark SQL';
 1  a Spark SQL
 2  b Spark SQL

> SELECT inline(array(struct(1, 'a'), struct(1, 'b'))),
         inline(array(struct('c', 1.0), struct('d', 2.0))),
         'Spark SQL';
 1  a Spark SQL
 2  b Spark SQL
Error: UNSUPPORTED_GENERATOR.MULTI_GENERATOR
```

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.2 LTS and above:

```sql
> SELECT i.*, 'Spark SQL'
    FROM inline(array(struct(1, 'a'), struct(2, 'b'))) AS i;
 1  a Spark SQL
 2  b Spark SQL

> SELECT i1.*, i2.*, 'Spark SQL'
   FROM  inline(array(struct(1, 'a'), struct(1, 'b'))) AS i1,
         inline(array(struct('c', 1.0), struct('d', 2.0))) AS i2;
 1      a       c       1.0     Spark SQL
 1      b       c       1.0     Spark SQL
 1      a       d       2.0     Spark SQL
 1      b       d       2.0     Spark SQL
```

## Related functions

* [`explode` table-valued generator function](https://docs.databricks.com/aws/en/sql/language-manual/functions/explode.md)
* [`explode_outer` table-valued generator function](https://docs.databricks.com/aws/en/sql/language-manual/functions/explode_outer.md)
* [`posexplode` table-valued generator function](https://docs.databricks.com/aws/en/sql/language-manual/functions/posexplode.md)
* [`posexplode_outer` table-valued generator function](https://docs.databricks.com/aws/en/sql/language-manual/functions/posexplode_outer.md)
* [`inline_outer` table-valued generator function](https://docs.databricks.com/aws/en/sql/language-manual/functions/inline_outer.md)
