IBM Support

How to query Spark using Db2 Federation through ODBC driver?

Question & Answer


Question

How to query Spark using Db2 Federation through ODBC driver?

Answer

Before You Begin
 
Enable Federation feature and restart Db2 to make it effective.
$ db2 update dbm cfg using federated YES
Pre-Configuration on Linux, Unix
 
1. Make sure the required ODBC drivers are installed correctly.
$ ls ~/sqllib/federation/odbc/lib/FOspark*.so
 
2. Make sure the data source is accessible to Federation server.
$ telnet pastimes1.fyre.ibm.com 10016
Trying 9.30.215.134...
Connected to pastimes1.fyre.ibm.com.
Escape character is '^]'.
 
3. Create server, user mapping,  nickname and query the nickname.
$ create server SERVER1 type spark_odbc version 2.1 options (HOST 'pastimes1.fyre.ibm.com', PORT '10016', DBNAME 'default')

$ create user mapping for user server SERVER1 options (REMOTE_AUTHID 'spark', REMOTE_PASSWORD 'hadoop')

$ create nickname n1 for "SERVER1"."test_table1"

$ select count(*) from n1

1
-----------
          1

  1 record(s) selected.

[{"Type":"SW","Line of Business":{"code":"","label":""},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSCAVPX","label":"Federated Server"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Document Information

Modified date:
06 May 2021

UID

ibm16442829