Automate Impala Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Impala data from PowerShell? This article demonstrates how to utilize the Impala Cmdlets for tasks like connecting to Impala data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Impala is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Impala.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Impala; this tutorial shows how to use the Provider to create, retrieve, update, and delete Impala data.

Once you have acquired the necessary connection properties, accessing Impala data in PowerShell can be enabled in three steps.

In order to connect to Apache Impala, set the Server, Port, and ProtocolVersion. You may optionally specify a default Database. To connect using alternative methods, such as NOSASL, LDAP, or Kerberos, refer to the online Help documentation.

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Impala\lib\System.Data.CData.ApacheImpala.dll")
  2. Connect to Impala:

    $conn= New-Object System.Data.CData.ApacheImpala.ApacheImpalaConnection("Server=127.0.0.1;Port=21050;")
    $conn.Open()
  3. Instantiate the ApacheImpalaDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT City, CompanyName from Customers"
    
    $da= New-Object System.Data.CData.ApacheImpala.ApacheImpalaDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
        Write-Host $_.city $_.companyname
    }

Update Impala Data

$cmd =  New-Object System.Data.CData.ApacheImpala.ApacheImpalaCommand("UPDATE Customers SET Country='US' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ApacheImpala.ApacheImpalaParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Impala Data

$cmd =  New-Object System.Data.CData.ApacheImpala.ApacheImpalaCommand("INSERT INTO Customers (Country) VALUES (@myCountry)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ApacheImpala.ApacheImpalaParameter("@myCountry","US")))
$cmd.ExecuteNonQuery()

Delete Impala Data

$cmd =  New-Object System.Data.CData.ApacheImpala.ApacheImpalaCommand("DELETE FROM Customers WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ApacheImpala.ApacheImpalaParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the Impala Data Provider to get started:

 Download Now

Learn more:

Apache Impala Icon Impala ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Impala.