﻿<?xml version="1.0" encoding="utf-8"?>

<!-- EngineVersion = Java version -->
<ApiConfig Name="Apache Hive"
           Slug="apache-hive-connector"
           Type="JDBC"
           Category="big-data"
           Id="e7b8c2a1-3f4d-4a6b-8c9e-2d5f7a9b6c3d"
           Version="2"
           EngineVersion="8"
           Desc="Read and write Apache Hive data effortlessly. Query, integrate, and manage tables and SQL on big data 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-hive-connector.png"
           HelpLink="https://community.zappysys.com/search?q=hive">

    <VersionHistory>
      <Change Ver="2" Date="2026-09-14" Type="Modified">Hive 4 Auth with standalone JAR download, numbered Auth Notes, extra SQL examples.</Change>
      <Change Ver="1" Date="2025-05-08" Type="New">Initial version.</Change>
    </VersionHistory>

    <Template>
        <Param Name="DriverDownloadPageLink"
               Value="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients" />
        <Param Name="MvnRepositoryDriverDownloadLink"
               Value="https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc" />
        <Param Name="DriverDownloadLinks"
               Hidden="True"
               Value="hive-jdbc-4.2.0-standalone.jar=https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/hive-jdbc-4.2.0-standalone.jar" />

        <EndPoint Name="AdditionalDriverDownloadInstructions">
            <Body>
                <![CDATA[
        <li>
            <p>
                Download the <strong>standalone</strong> Hive JDBC JAR so you do not have to assemble Hadoop dependencies,
                e.g. <a href="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" target="_blank">hive-jdbc-4.2.0-standalone.jar</a>.
            </p>
        </li>
                ]]>
            </Body>
        </EndPoint>
    </Template>

    <Auths>
        <Auth Name="Default"
              Label="HiveServer2 (default)"
              ConnStr="jdbc:hive2://[$HostName$]:[$Port$]/[$Database$]"
              HelpLink="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC">
            <Params>
                <Param Name="DriverClass"
                       Label="Driver class"
                       Required="False"
                       Value="org.apache.hive.jdbc.HiveDriver"
                       Desc="Optional. Leave blank to auto-detect from the standalone JAR (e.g. org.apache.hive.jdbc.HiveDriver)."
                       HelpLink="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC" />
                <Param Name="DriverFilePaths" Editor="FileOpen"
                       Label="JDBC driver file(s)"
                       Required="True"
                       Value="{DownloadFolder}\hive-jdbc-4.2.0-standalone.jar"
                       Desc="Filled by the wizard after download. Use the standalone JAR only (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)."
                       HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="Port" Label="TCP port" Required="True" Value="10000" Desc="JDBC port (e.g. 10000)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="Database" Label="Database name" Required="False" Value="MyDatabase" Desc="Database, schema, or catalog name (e.g. MyDatabase)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="UserName"
                       Label="User name"
                       Required="False"
                       Desc="HiveServer2 user. Leave empty if the cluster allows anonymous JDBC."
                       HelpLink="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC" />
                <Param Name="Password"
                       Label="Password"
                       Required="False"
                       Secret="True"
                       Desc="HiveServer2 password or LDAP secret. Leave empty if none."
                       HelpLink="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC" />
            </Params>
            <Notes>
                <![CDATA[
<p>Connect to HiveServer2 with the standalone JDBC JAR. JDBC Bridge then exposes Hive SQL to Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools.</p>
<ol>
  <li>Note the HiveServer2 host and binary port (default <code>10000</code>) and the default database name.</li>
  <li>Create a Hive / LDAP user if the cluster requires authentication. Lab clusters sometimes allow empty user and password.</li>
  <li>Replace <code>hive-instance-host-name</code> and the database in the JDBC URL after Finish (the wizard hides the URL; edit it on the DSN Main UI).</li>
  <li>Prefer the standalone JAR the wizard downloads. Do not mix it with a partial Hadoop classpath.</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>
        <Auth Name="Hive4Ssl"
              Label="Hive 4 (SSL / LDAP)"
              ConnStr="jdbc:hive2://[$HostName$]:[$Port$]/[$Database$];ssl=[$Ssl$]"
              HelpLink="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC">
            <Params>
                <Param Name="DriverClass"
                       Label="Driver class"
                       Required="False"
                       Value="org.apache.hive.jdbc.HiveDriver"
                       Desc="Optional. Leave blank to auto-detect from the standalone JAR (e.g. org.apache.hive.jdbc.HiveDriver)."
                       HelpLink="https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC" />
                <Param Name="DriverFilePaths" Editor="FileOpen"
                       Label="JDBC driver file(s)"
                       Required="True"
                       Value="{DownloadFolder}\hive-jdbc-4.2.0-standalone.jar"
                       Desc="Hive 4 standalone JAR. Filled by the wizard after download (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)."
                       HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="Port" Label="TCP port" Required="True" Value="10000" Desc="JDBC port (e.g. 10000)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="Database" Label="Database name" Required="False" Value="MyDatabase" Desc="Database, schema, or catalog name (e.g. MyDatabase)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="Ssl" Label="SSL" Required="False" Options="Notset=;Yes=true;No=false" Value="true" Desc="SSL flag for this JDBC URL (e.g. Yes from the dropdown)." HelpLink="https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.2.0/" />
                <Param Name="UserName"
                       Label="User name"
                       Required="True"
                       Desc="LDAP or Hive user for HiveServer2."
                       HelpLink="https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2" />
                <Param Name="Password"
                       Label="Password"
                       Required="True"
                       Secret="True"
                       Desc="LDAP or Hive password."
                       HelpLink="https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2" />
            </Params>
            <Notes>
                <![CDATA[
<p>Hive 4 HiveServer2 with SSL and user/password (LDAP or custom). Power BI's old Hive LLAP ODBC path is being deprecated; this JDBC standalone JAR is the durable Excel / SSIS / Linked Server path.</p>
<ol>
  <li>Confirm Hive 4.x HiveServer2 host, port <code>10000</code> (or your HS2 port), and that SSL is enabled.</li>
  <li>Create or reuse an LDAP / Hive user. Paste user and password here. Do not use a personal employee login for unattended refresh.</li>
  <li>The wizard downloads <code>hive-jdbc-4.2.0-standalone.jar</code>. Keep SSL=true unless your lab is plaintext (then use Default Auth).</li>
  <li>After Finish, edit the JDBC URL on the DSN Main UI to replace the host (e.g. MyHostName) and database (e.g. MyDatabase).</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://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL">
            <Desc><![CDATA[<p>Lists tables in the current Hive database. Use this in Power BI or a SQL Server Linked Server to confirm the catalog.</p>]]></Desc>
            <Code>
                <![CDATA[SHOW TABLES]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="list-employees-in-a-department" Label="List employees in a department">
            <Desc><![CDATA[<p>Returns selected columns for employees in the Sales department. Use <code>WHERE department = 'Sales'</code> to filter by department. Works in Excel, SSRS, and Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT
    id,
    name,
    salary
FROM employees
WHERE department = 'Sales']]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="join-employees-departments" Label="Join employees and departments">
            <Desc><![CDATA[<p>Joins employees to departments. Typical Azure Data Factory or SSIS extract.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT e.id, e.name, d.dept_name
FROM employees e
JOIN departments d ON e.dept_id = d.id]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="group-salary-by-department" Label="Average salary by department">
            <Desc><![CDATA[<p>Aggregates salary per department. Use in Power BI before a visual.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT department, AVG(salary) AS avg_salary, COUNT(*) AS emp_count
FROM employees
GROUP BY department
HAVING COUNT(*) >= 1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="order-limit" Label="Order and limit">
            <Desc><![CDATA[<p>Returns the top 100 rows by salary. Useful as a preview in Crystal Reports or Excel.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id, name, salary
FROM employees
ORDER BY salary DESC
LIMIT 100]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="rank-employees-by-salary-window-function" Label="Rank employees by salary (window function)">
            <Desc><![CDATA[<p>Ranks employees by salary within each department (highest first). The result includes a salary rank per department.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT
    id,
    name,
    department,
    salary,
    ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) as salary_rank_in_dept
FROM employees]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="extract-field-from-json-string" Label="Extract field from JSON string">
            <Desc><![CDATA[<p>Extracts the city field from a JSON string in the user_data column. The column should contain JSON with an address and city (e.g. nested under address).</p>]]></Desc>
            <Code>
                <![CDATA[SELECT
    user_id,
    get_json_object(user_data, '$.address.city') AS city
FROM user_activity
WHERE user_data IS NOT NULL]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="explode-array-into-rows-lateral-view" Label="Explode array into rows (lateral view)">
            <Desc><![CDATA[<p>Turns array elements into separate rows and filters for users interested in hiking. Assumes a table with an array column for interests.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT DISTINCT
    up.user_id,
    up.name
FROM user_profiles up
LATERAL VIEW explode(interests) interest_table AS single_interest
WHERE single_interest = 'hiking']]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="extract-browser-from-user-agent-regex" Label="Extract browser from user agent (Regex)">
            <Desc><![CDATA[<p>Parses the browser name (e.g. Firefox, Chrome, Safari, MSIE) from the user_agent string. For large tables, you can limit the number of rows returned.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT
    user_agent,
    regexp_extract(user_agent, '(Firefox|Chrome|Safari|MSIE)', 1) AS browser
FROM web_logs
LIMIT 100]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="count-employees" Label="Count rows">
            <Desc><![CDATA[<p>Returns the number of employee rows. Use from Linked Server or ADF to sanity-check volume.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT COUNT(*) AS row_count FROM employees]]>
            </Code>
        </Example>
    </Examples>
</ApiConfig>
