<?xml version="1.0" encoding="utf-8"?>

<!-- EngineVersion = Java version -->
<ApiConfig Name="Apache Druid"
           Slug="apache-druid-connector"
           Type="JDBC"
           Category="big-data"
           Id="EA22D43B-D65C-5756-BE96-5DDD8E0FB220"
           Version="1"
           EngineVersion="8"
           Desc="Query Apache Druid SQL through Avatica JDBC from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools -- almost no coding required."
           Logo="https://cdn.zappysys.com/api/Images/logos/apache-druid-connector.png"
           HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc">

    <VersionHistory>
      <Change Ver="1" Date="2026-09-14" Type="New">Initial JDBC Bridge catalog version. Hands-free Maven JAR download. Auth Notes and SQL examples for ODBC apps.</Change>
    </VersionHistory>
    <Template>
        <Param Name="DriverDownloadPageLink"
               Value="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
        <Param Name="MvnRepositoryDriverDownloadLink"
               Value="https://mvnrepository.com/artifact/org.apache.calcite.avatica/avatica" />
        <Param Name="DriverDownloadLinks"
               Hidden="True"
               Value="avatica-1.28.0-shadow.jar=https://repo1.maven.org/maven2/org/apache/calcite/avatica/avatica/1.28.0/avatica-1.28.0-shadow.jar" />
    </Template>

    <Auths>
        <Auth Name="Broker"
              Label="Broker SQL (Avatica)"
              ConnStr="jdbc:avatica:remote:url=http://[$HostName$]:[$Port$]/druid/v2/sql/avatica/"
              HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc">
            <Params>
                <Param Name="DriverClass" Label="Driver class" Required="False" Value="org.apache.calcite.avatica.remote.Driver" Desc="Optional. Leave blank to auto-detect from the JAR unless SPI is ambiguous (e.g. org.apache.calcite.avatica.remote.Driver)." HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
                <Param Name="DriverFilePaths" Editor="FileOpen" Label="JDBC driver file(s)" Required="True" Value="{DownloadFolder}\avatica-1.28.0-shadow.jar" Desc="Filled by the wizard after download. Separate multiple JARs with a semicolon (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)." HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
                <Param Name="Port" Label="TCP port" Required="True" Value="8888" Desc="JDBC port (e.g. 8888)." HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
                <Param Name="UserName" Label="User name" Required="False" Desc="Database user. Leave empty if the server allows anonymous JDBC." HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
                <Param Name="Password" Label="Password" Required="False" Secret="True" Desc="Database password. Leave empty if no password is required." HelpLink="https://druid.apache.org/docs/latest/querying/sql-jdbc" />
            </Params>
            <Notes>
                <![CDATA[<p>Apache Druid JDBC from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools.</p>
<ol>
  <li>Use the Router or Broker host. Default SQL Avatica path is <code>/druid/v2/sql/avatica/</code> on port <code>8888</code>.</li><li>If the cluster uses basic auth, fill user and password from the Druid coordinator.</li><li>Prefer HTTPS only when TLS is terminated on that endpoint (see Druid SQL JDBC docs).</li>
  <li>Finish the wizard. Then click <strong>Test Connection</strong> on the DSN Main UI (the wizard does not run Test Connection).</li><li>Done. You can query from C#, Python, PowerShell, and ODBC apps.</li>
</ol>]]>
            </Notes>
        </Auth>
    </Auths>

    <Examples>
        <Example Default="True" Group="ODBC" Slug="list-tables" Label="List tables" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Lists tables available to this connection. Use this in Power BI or a SQL Server Linked Server to confirm the catalog before building reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'druid' ORDER BY TABLE_NAME]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-rows" Label="Select rows" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Returns rows from <code>wikipedia</code>. Replace the identifier with your catalog object. Works in Excel, SSRS, and Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM wikipedia]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="filter-rows" Label="Filter with WHERE" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Returns matching rows from <code>wikipedia</code>. Swap the column and literal for your schema.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM wikipedia
WHERE id = 1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="join-tables" Label="Join tables" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Joins two tables on a key. Use in Azure Data Factory or SSIS when you need a combined extract.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT a.id, a.name, b.amount
FROM wikipedia AS a
JOIN my_other_table AS b ON a.id = b.parent_id]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="group-by" Label="Aggregate with GROUP BY" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Counts rows per group. Typical Power BI import pattern before a visual.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM wikipedia
GROUP BY status]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="having" Label="Filter groups with HAVING" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Keeps groups whose count is at least 10.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM wikipedia
GROUP BY status
HAVING COUNT(*) >= 10]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="order-limit" Label="Order and limit" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Returns the first 100 rows ordered by a column. Useful for preview in Excel or Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM wikipedia
ORDER BY id
LIMIT 100]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="count-all" Label="Count rows" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Returns the number of rows in <code>wikipedia</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT COUNT(*) AS row_count FROM wikipedia]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="case-expr" Label="CASE expression" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Maps a column to labels with <code>CASE</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id,
       CASE WHEN status = 'A' THEN 'Active' ELSE 'Other' END AS status_label
FROM wikipedia]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-list" Label="Select specific columns" HelpLink="https://druid.apache.org/docs/latest/querying/sql">
            <Desc><![CDATA[<p>Returns a column list instead of star. Prefer this in Linked Server views.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id, name, status
FROM wikipedia]]>
            </Code>
        </Example>
    </Examples>
</ApiConfig>
