ADO.NET Provider for HDFS

Build 21.0.7930

Querying with the DataAdapter

The CData ADO.NET Provider for HDFS implements two ADO.NET interfaces you can use to retrieve data from HDFS: HDFSDataAdapter and HDFSDataReader objects. Whereas HDFSDataAdapter objects retrieve a single result set of all the data that matches a query, HDFSDataReader objects fetch data in subset increments as needed.

Using the HDFSDataAdapter

Use the adapter's Fill method to retrieve data from the data source. An empty DataTable instance is passed as an argument to the Fill method. When the method returns, the DataTable instance is populated with the queried data. Note that the HDFSDataAdapter is slower than the HDFSDataReader because the Fill method needs to retrieve all data from the data source before returning.

The following example selects the FileId and ChildrenNum columns of the Files table:


string connectionString = ";Port=50070;Path=/user/root;";

using (HDFSConnection connection = new HDFSConnection(connectionString)) {
  HDFSDataAdapter dataAdapter = new HDFSDataAdapter(
  "SELECT FileId, ChildrenNum FROM Files", connection);

  DataTable table = new DataTable();

  Console.WriteLine("Contents of Files.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["FileId"], row["ChildrenNum"]);


Dim connectionString As String = ";Port=50070;Path=/user/root;"

Using connection As New HDFSConnection(connectionString)
  Dim dataAdapter As New HDFSDataAdapter("SELECT FileId, ChildrenNum FROM Files", connection)

  Dim table As New DataTable()

  Console.WriteLine("Contents of Files.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("FileId"), row("ChildrenNum"))
End Using

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930