> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Result To Scalar

export const ComponentMetadata = ({warehouses, unsupportedWarehouses = [], componentType, connectionInputs, connectionOutputs}) => {
  const allWarehouses = [...warehouses.map(w => ({
    name: w,
    supported: true
  })), ...unsupportedWarehouses.map(w => ({
    name: w,
    supported: false
  }))];
  return <div style={{
    background: 'var(--colors-background-light, #f9fafb)',
    border: '1px solid var(--colors-border-default, #e5e7eb)',
    borderRadius: '12px',
    padding: '20px 28px',
    marginBottom: '28px',
    boxShadow: '0 1px 4px rgba(0,0,0,0.10)'
  }}>
      <table style={{
    width: '100%',
    borderCollapse: 'collapse'
  }}>
        <tbody>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle',
    width: '180px'
  }}>Project Availability</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>
              <div style={{
    display: 'flex',
    flexWrap: 'wrap',
    gap: '8px'
  }}>
                {allWarehouses.map((w, i) => <span key={i} style={{
    background: w.supported ? '#dcfce7' : '#fee2e2',
    color: w.supported ? '#15803d' : '#b91c1c',
    border: `1px solid ${w.supported ? '#bbf7d0' : '#fca5a5'}`,
    borderRadius: '9999px',
    padding: '3px 12px',
    fontSize: '0.85rem',
    fontWeight: '500',
    whiteSpace: 'nowrap'
  }}>
                    {w.name} {w.supported ? '✅' : '❌'}
                  </span>)}
              </div>
            </td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Component Type</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{componentType}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Inputs</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{connectionInputs}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Outputs</td>
            <td style={{
    verticalAlign: 'middle'
  }}>{connectionOutputs}</td>
          </tr>
        </tbody>
      </table>
    </div>;
};

<ComponentMetadata warehouses={["Snowflake", "Databricks", "Amazon Redshift", "Google BigQuery"]} componentType="Orchestration, Test" connectionInputs="One" connectionOutputs="Unlimited" />

The Query Result To Scalar orchestration component allows you to query a table and return a scalar value. This value can then be mapped to a project or pipeline [variable](/docs/guides/variables) for use in other pipeline components.

This component is the scalar equivalent of the [Query Result To Grid](/docs/components/query-result-to-grid) component.

***

## Properties

<Tabs>
  <Tab title="Snowflake">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[mode] | warehouses: [snowflake] --> */}

    <ResponseField name="Mode" type="drop-down" required>
      * **Basic:** This mode will build a query for you using settings from the **Data Source**, **Data Selection**, and **Data Source Filter** parameters. In most cases, this mode will be sufficient.
      * **Advanced:** This mode will require you to write an SQL-like query to call data from Snowflake. The available fields and their descriptions are documented in the data model.
    </ResponseField>

    {/* <!-- param-start:[database] | warehouses: [snowflake] --> */}

    <ResponseField name="Database" type="string" required>
      The Snowflake database. The special value `[Environment Default]` uses the database defined in the environment. Read [Databases, Tables and Views - Overview](https://docs.snowflake.com/en/guides-overview-db) to learn more.
    </ResponseField>

    {/* <!-- param-start:[schema] | warehouses: [snowflake] --> */}

    <ResponseField name="Schema" type="drop-down" required>
      The Snowflake schema. The special value `[Environment Default]` uses the schema defined in the environment. Read [Database, Schema, and Share DDL](https://docs.snowflake.com/en/sql-reference/ddl-database.html) to learn more.
    </ResponseField>

    {/* <!-- param-start:[table] | warehouses: [snowflake] --> */}

    <ResponseField name="Table" type="string" required>
      The name of the table to be queried.
    </ResponseField>

    {/* <!-- param-start:[tableColumns] | warehouses: [snowflake] --> */}

    <ResponseField name="Table Columns" type="dual listbox" required>
      Select which columns to take from the table as part of the query.
    </ResponseField>

    {/* <!-- param-start:[orderBy] | warehouses: [snowflake] --> */}

    <ResponseField name="Order By" type="dual listbox">
      Choose the columns by which to sort rows. If multiple columns are selected, rows are sorted by the first-listed column first, then by the next listed column, and so on.
    </ResponseField>

    {/* <!-- param-start:[sort] | warehouses: [snowflake] --> */}

    <ResponseField name="Sort" type="drop-down" required>
      Select whether rows are sorted in **Ascending** or **Descending** order.
    </ResponseField>

    {/* <!-- param-start:[limit] | warehouses: [snowflake] --> */}

    <ResponseField name="Limit" type="integer" required>
      Set the limit of returned rows.
    </ResponseField>

    {/* <!-- param-start:[filterConditions] | warehouses: [snowflake] --> */}

    <ResponseField name="Filter Conditions" type="column editor">
      * **Input Column Name:** Select an input column. The available input columns vary depending upon the data source.
      * **Qualifier:**
        * **Is:** Compares the column to the value using the comparator.
        * **Not:** Reverses the effect of the comparison, so "Equals" becomes "Not equals", "Less than" becomes "Greater than or equal to", etc.
      * **Comparator:** Choose a method of comparing the column to the value. Possible comparators include: "Equal to", "Greater than", "Less than", "Greater than or equal to", "Less than or equal to", "Like", "Null". "Equal to" can match exact strings and numeric values, while other comparators, such as "Greater than" and "Less than", will work only with numerics. The "Like" operator allows the wildcard character `%` to be used at the start and end of a string value to match a column. The Null operator matches only null values, ignoring whatever the value is set to. Not all data sources support all comparators, meaning that it is likely that only a subset of the above comparators will be available to choose from.
      * **Value:** The value to be compared.

      To use [grid variables](/docs/guides/grid-variables), select the **Use Grid Variable** checkbox at the bottom of the **Filter Conditions** dialog.
    </ResponseField>

    {/* <!-- param-start:[combineCondition] | warehouses: [snowflake] --> */}

    <ResponseField name="Combine Condition" type="drop-down" required>
      Select whether to use the defined filters in combination with one another according to either And or Or.
    </ResponseField>

    {/* <!-- param-start:[query] | warehouses: [snowflake] --> */}

    <ResponseField name="Query" type="code editor" required>
      This property opens an editor. On the left, users can explore tables and their metadata from environments. Both project and pipeline variables are also listed in the bottom-left.

      SQL queries can be written in the main panel and tested using the **Sample** button, which will display results below.

      This property is only available when **Mode** is set to **Advanced**.

      <Warning>
        Do not end SQL statements with a semicolon in this component.
      </Warning>
    </ResponseField>

    {/* <!-- param-start:[scalarVariableMapping] | warehouses: [snowflake] --> */}

    <ResponseField name="Scalar Variable Mapping" type="column editor" required>
      Scalar results from the SQL query can be mapped to project and pipeline variables.

      Use the **Input Column Name** drop-down to select a scalar returned by the query. Use the **Scalar Variable Name** drop-down to select a variable to map the scalar to. Click **+** to add more mappings.

      <Note>
        Variables used in the mapping must be created before this component runs. Read [Project and pipeline variables](/docs/guides/variables) for details of how to create variables.
      </Note>

      To use [grid variables](/docs/guides/grid-variables), select the **Use Grid Variable** checkbox at the bottom of the **Scalar Variable Mapping** dialog.
    </ResponseField>
  </Tab>

  <Tab title="Databricks">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[mode] | warehouses: [databricks] --> */}

    <ResponseField name="Mode" type="drop-down" required>
      * **Basic:** This mode will build a query for you using settings from the **Data Source**, **Data Selection**, and **Data Source Filter** parameters. In most cases, this mode will be sufficient.
      * **Advanced:** This mode will require you to write an SQL-like query to call data from Databricks. The available fields and their descriptions are documented in the data model.
    </ResponseField>

    {/* <!-- param-start:[catalog] | warehouses: [databricks] --> */}

    <ResponseField name="Catalog" type="drop-down" required>
      Select a [Databricks Unity Catalog](https://docs.databricks.com/en/data-governance/unity-catalog/index.html). The special value `[Environment Default]` uses the catalog defined in the environment. Selecting a catalog will determine which databases are available in the next parameter.
    </ResponseField>

    {/* <!-- param-start:[schema] | warehouses: [databricks] --> */}

    <ResponseField name="Schema (Database)" type="drop-down" required>
      The Databricks schema. The special value `[Environment Default]` uses the schema defined in the environment. Read [Create and manage schemas](https://docs.databricks.com/en/data-governance/unity-catalog/create-schemas.html) to learn more.
    </ResponseField>

    {/* <!-- param-start:[table] | warehouses: [databricks] --> */}

    <ResponseField name="Table" type="drop-down" required>
      The name of the table to be queried.
    </ResponseField>

    {/* <!-- param-start:[tableColumns] | warehouses: [databricks] --> */}

    <ResponseField name="Table Columns" type="dual listbox" required>
      Select which columns to take from the table as part of the query.
    </ResponseField>

    {/* <!-- param-start:[orderBy] | warehouses: [databricks] --> */}

    <ResponseField name="Order By" type="dual listbox">
      Choose the columns by which to sort rows. If multiple columns are selected, rows are sorted by the first-listed column first, then by the next listed column, and so on.
    </ResponseField>

    {/* <!-- param-start:[sort] | warehouses: [databricks] --> */}

    <ResponseField name="Sort" type="drop-down" required>
      Select whether rows are sorted in **Ascending** or **Descending** order.
    </ResponseField>

    {/* <!-- param-start:[limit] | warehouses: [databricks] --> */}

    <ResponseField name="Limit" type="integer" required>
      Set the limit of returned rows.
    </ResponseField>

    {/* <!-- param-start:[filterConditions] | warehouses: [databricks] --> */}

    <ResponseField name="Filter Conditions" type="column editor">
      * **Input Column Name:** Select an input column. The available input columns vary depending upon the data source.
      * **Qualifier:**
        * **Is:** Compares the column to the value using the comparator.
        * **Not:** Reverses the effect of the comparison, so "Equals" becomes "Not equals", "Less than" becomes "Greater than or equal to", etc.
      * **Comparator:** Choose a method of comparing the column to the value. Possible comparators include: "Equal to", "Greater than", "Less than", "Greater than or equal to", "Less than or equal to", "Like", "Null". "Equal to" can match exact strings and numeric values, while other comparators, such as "Greater than" and "Less than", will work only with numerics. The "Like" operator allows the wildcard character `%` to be used at the start and end of a string value to match a column. The Null operator matches only null values, ignoring whatever the value is set to. Not all data sources support all comparators, meaning that it is likely that only a subset of the above comparators will be available to choose from.
      * **Value:** The value to be compared.

      To use [grid variables](/docs/guides/grid-variables), select the **Use Grid Variable** checkbox at the bottom of the **Filter Conditions** dialog.
    </ResponseField>

    {/* <!-- param-start:[combineCondition] | warehouses: [databricks] --> */}

    <ResponseField name="Combine Condition" type="drop-down" required>
      Select whether to use the defined filters in combination with one another according to either And or Or.
    </ResponseField>

    {/* <!-- param-start:[query] | warehouses: [databricks] --> */}

    <ResponseField name="Query" type="code editor" required>
      This property opens an editor. On the left, users can explore tables and their metadata from environments. Both project and pipeline variables are also listed in the bottom-left.

      SQL queries can be written in the main panel and tested using the **Sample** button, which will display results below.

      This property is only available when **Mode** is set to **Advanced**.

      <Warning>
        Do not end SQL statements with a semicolon in this component.
      </Warning>
    </ResponseField>

    {/* <!-- param-start:[scalarVariableMapping] | warehouses: [databricks] --> */}

    <ResponseField name="Scalar Variable Mapping" type="column editor" required>
      Scalar results from the SQL query can be mapped to project and pipeline variables.

      Use the **Input Column Name** drop-down to select a scalar returned by the query. Use the **Scalar Variable Name** drop-down to select a variable to map the scalar to. Click **+** to add more mappings.

      <Note>
        Variables used in the mapping must be created before this component runs. Read [Project and pipeline variables](/docs/guides/variables) for details of how to create variables.
      </Note>

      To use [grid variables](/docs/guides/grid-variables), select the **Use Grid Variable** checkbox at the bottom of the **Scalar Variable Mapping** dialog.
    </ResponseField>
  </Tab>

  <Tab title="Amazon Redshift">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[mode] | warehouses: [redshift] --> */}

    <ResponseField name="Mode" type="drop-down" required>
      * **Basic:** This mode will build a query for you using settings from the **Data Source**, **Data Selection**, and **Data Source Filter** parameters. In most cases, this mode will be sufficient.
      * **Advanced:** This mode will require you to write an SQL-like query to call data from Redshift. The available fields and their descriptions are documented in the data model.
    </ResponseField>

    {/* <!-- param-start:[schema] | warehouses: [redshift] --> */}

    <ResponseField name="Schema" type="drop-down" required>
      Select the table schema. The special value `[Environment Default]` uses the schema defined in the environment. For more information on using multiple schemas, read [Schemas](https://docs.aws.amazon.com/redshift/latest/dg/r_Schemas_and_tables.html).
    </ResponseField>

    {/* <!-- param-start:[table] | warehouses: [redshift] --> */}

    <ResponseField name="Table" type="string" required>
      The name of the table to be queried.
    </ResponseField>

    {/* <!-- param-start:[tableColumns] | warehouses: [redshift] --> */}

    <ResponseField name="Table Columns" type="dual listbox" required>
      Select which columns to take from the table as part of the query.
    </ResponseField>

    {/* <!-- param-start:[orderBy] | warehouses: [redshift] --> */}

    <ResponseField name="Order By" type="dual listbox">
      Choose the columns by which to sort rows. If multiple columns are selected, rows are sorted by the first-listed column first, then by the next listed column, and so on.
    </ResponseField>

    {/* <!-- param-start:[sort] | warehouses: [redshift] --> */}

    <ResponseField name="Sort" type="drop-down" required>
      Select whether rows are sorted in **Ascending** or **Descending** order.
    </ResponseField>

    {/* <!-- param-start:[limit] | warehouses: [redshift] --> */}

    <ResponseField name="Limit" type="integer" required>
      Set the limit of returned rows.
    </ResponseField>

    {/* <!-- param-start:[filterConditions] | warehouses: [redshift] --> */}

    <ResponseField name="Filter Conditions" type="column editor">
      * **Input Column Name:** Select an input column. The available input columns vary depending upon the data source.
      * **Qualifier:**
        * **Is:** Compares the column to the value using the comparator.
        * **Not:** Reverses the effect of the comparison, so "Equals" becomes "Not equals", "Less than" becomes "Greater than or equal to", etc.
      * **Comparator:** Choose a method of comparing the column to the value. Possible comparators include: "Equal to", "Greater than", "Less than", "Greater than or equal to", "Less than or equal to", "Like", "Null". "Equal to" can match exact strings and numeric values, while other comparators, such as "Greater than" and "Less than", will work only with numerics. The "Like" operator allows the wildcard character `%` to be used at the start and end of a string value to match a column. The Null operator matches only null values, ignoring whatever the value is set to. Not all data sources support all comparators, meaning that it is likely that only a subset of the above comparators will be available to choose from.
      * **Value:** The value to be compared.

      To use [grid variables](/docs/guides/grid-variables), select the **Use Grid Variable** checkbox at the bottom of the **Filter Conditions** dialog.
    </ResponseField>

    {/* <!-- param-start:[combineCondition] | warehouses: [redshift] --> */}

    <ResponseField name="Combine Condition" type="drop-down" required>
      Select whether to use the defined filters in combination with one another according to either And or Or.
    </ResponseField>

    {/* <!-- param-start:[query] | warehouses: [redshift] --> */}

    <ResponseField name="Query" type="code editor" required>
      This property opens an editor. On the left, users can explore tables and their metadata from environments. Both project and pipeline variables are also listed in the bottom-left.

      SQL queries can be written in the main panel and tested using the **Sample** button, which will display results below.

      This property is only available when **Mode** is set to **Advanced**.

      <Warning>
        Do not end SQL statements with a semicolon in this component.
      </Warning>
    </ResponseField>

    {/* <!-- param-start:[scalarVariableMapping] | warehouses: [redshift] --> */}

    <ResponseField name="Scalar Variable Mapping" type="column editor" required>
      Scalar results from the SQL query can be mapped to project and pipeline variables.

      Use the **Input Column Name** drop-down to select a scalar returned by the query. Use the **Scalar Variable Name** drop-down to select a variable to map the scalar to. Click **+** to add more mappings.

      <Note>
        Variables used in the mapping must be created before this component runs. Read [Project and pipeline variables](/docs/guides/variables) for details of how to create variables.
      </Note>

      To use [grid variables](/docs/guides/grid-variables), select the **Use Grid Variable** checkbox at the bottom of the **Scalar Variable Mapping** dialog.
    </ResponseField>
  </Tab>

  <Tab title="Google BigQuery">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[mode] | warehouses: [bigquery] --> */}

    <ResponseField name="Mode" type="drop-down" required>
      * **Basic:** This mode will build a query for you using settings from the **Data Source**, **Data Selection**, and **Data Source Filter** parameters. In most cases, this mode will be sufficient.
      * **Advanced:** This mode will require you to write an SQL-like query to call data from BigQuery. The available fields and their descriptions are documented in the data model.
    </ResponseField>

    {/* <!-- param-start:[gcpProjectId] | warehouses: [bigquery] --> */}

    <ResponseField name="GCP Project ID" type="drop-down" required>
      The Google Cloud project that owns the BigQuery dataset. The special value `[Environment Default]` uses the Google Cloud project defined in the environment. For more information, read [Creating projects](https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects).
    </ResponseField>

    {/* <!-- param-start:[dataset] | warehouses: [bigquery] --> */}

    <ResponseField name="Dataset" type="drop-down" required>
      The Google BigQuery dataset containing the table to query. The special value `[Environment Default]` uses the dataset defined in the environment.
    </ResponseField>

    {/* <!-- param-start:[table] | warehouses: [bigquery] --> */}

    <ResponseField name="Table" type="string" required>
      The name of the table to be queried. Type a name, or select from the drop-down.
    </ResponseField>

    {/* <!-- param-start:[tableColumns] | warehouses: [bigquery] --> */}

    <ResponseField name="Table columns" type="dual listbox" required>
      Select which columns to take from the table as part of the query.
    </ResponseField>

    {/* <!-- param-start:[orderBy] | warehouses: [bigquery] --> */}

    <ResponseField name="Order by" type="dual listbox">
      Choose the columns by which to sort rows. If multiple columns are selected, rows are sorted by the first-listed column first, then by the next listed column, and so on.
    </ResponseField>

    {/* <!-- param-start:[sort] | warehouses: [bigquery] --> */}

    <ResponseField name="Sort" type="drop-down" required>
      Select whether rows are sorted in **Ascending** or **Descending** order.
    </ResponseField>

    {/* <!-- param-start:[limit] | warehouses: [bigquery] --> */}

    <ResponseField name="Limit" type="integer" required>
      Set the limit of returned rows.
    </ResponseField>

    {/* <!-- param-start:[filterConditions] | warehouses: [bigquery] --> */}

    <ResponseField name="Filter conditions" type="column editor">
      * **Input Column Name:** Select an input column. The available input columns vary depending upon the data source.

      * **Qualifier:**
        * **Is:** Compares the column to the value using the comparator.
        * **Not:** Reverses the effect of the comparison, so "Equals" becomes "Not equals", "Less than" becomes "Greater than or equal to", etc.

      * **Comparator:** Choose a method of comparing the column to the value. Possible comparators include:

        * **Less than**
        * **Less than or equal to**
        * **Equal to**
        * **Greater than**
        * **Greater than or equal to**
        * **Like**
        * **Ilike**
        * **Similar to**
        * **Null**
        * **Blank**
        * **Null or blank**

        "Equal to" can match exact strings and numeric values, while other comparators, such as "Greater than" and "Less than", will work only with numerics. The "Like" operator allows the wildcard character `%` to be used at the start and end of a string value to match a column. The Null operator matches only null values, ignoring whatever the value is set to. Not all data sources support all comparators, meaning that it is likely that only a subset of the above comparators will be available to choose from.

      * **Value:** The value to be compared.

      To use grid variables, toggle **Use Grid Variable** on at the bottom of the dialog. For more information, read [Grid variables](/docs/guides/grid-variables).

      Click the **Text mode** toggle at the bottom of the dialog to open a multi-line editor that lets you add items in a single block. For more information, read [Text mode](/docs/guides/components-overview#text-mode).
    </ResponseField>

    {/* <!-- param-start:[combineCondition] | warehouses: [bigquery] --> */}

    <ResponseField name="Combine Condition" type="drop-down" required>
      Select whether to use the defined filters in combination with one another according to either And or Or.
    </ResponseField>

    {/* <!-- param-start:[query] | warehouses: [bigquery] --> */}

    <ResponseField name="Query" type="code editor" required>
      This is an SQL-like SELECT query, written in the SQL accepted by your cloud data warehouse. Treat collections as table names, and fields as columns. Only available in **Advanced** mode.

      You can use [Maia AI Agent](/docs/guides/maia-ai-agents-overview) to help you write the query, or you can write the SQL yourself in the code editor box.

      <Warning>
        Do not end SQL statements with a semicolon in this component.
      </Warning>
    </ResponseField>

    {/* <!-- param-start:[scalarVariableMapping] | warehouses: [bigquery] --> */}

    <ResponseField name="Scalar variable mapping" type="column editor" required>
      Scalar results from the SQL query can be mapped to project and pipeline variables.

      Use the **Input Column Name** drop-down to select a scalar returned by the query. Use the **Scalar Variable Name** drop-down to select a variable to map the scalar to. Click **+** to add more mappings.

      <Note>
        Variables used in the mapping must be created before this component runs. Read [variables](/docs/guides/variables) for details of how to create variables.
      </Note>

      To use grid variables, toggle **Use Grid Variable** on at the bottom of the dialog. For more information, read [Grid variables](/docs/guides/grid-variables).

      Click the **Text mode** toggle at the bottom of the dialog to open a multi-line editor that lets you add items in a single block. For more information, read [Text mode](/docs/guides/components-overview#text-mode).
    </ResponseField>
  </Tab>
</Tabs>
