Apache Spark (with Python or Scala) - Import - 8.0

Talend Data Catalog Bridges

Version
8.0
Language
English
Product
Talend Cloud
Module
Talend Data Catalog
Last publication date
2024-02-18

Bridge Requirements

This bridge:
  • requires Internet access to https://repo.maven.apache.org/maven2/ and/or other tool sites to download drivers into <TDC_HOME>/data/download/MIMB/.

Bridge Specifications

Vendor Apache
Tool Name Spark (with Python or Scala)
Tool Version Spark 2.x to 3.x
Tool Web Site http://spark.apache.org/
Supported Methodology [Data Integration] Multi-Model, Data Store (Physical Data Model), (Source and Target Data Stores, Transformation Lineage, Expression Parsing) via Spark with Python or Scala File
Data Profiling
Incremental Harvesting
Multi-Model Harvesting
Remote Repository Browsing for Model Selection

SPECIFICATIONS
Tool: Apache / Spark (with Python or Scala) version Spark 2.x to 3.x via Spark with Python or Scala File
See http://spark.apache.org/
Metadata: [Data Integration] Multi-Model, Data Store (Physical Data Model), (Source and Target Data Stores, Transformation Lineage, Expression Parsing)
Component: ApacheSpark version 11.2.0

DISCLAIMER
This import bridge requires internet access to download third-party libraries:
- such as https://repo.maven.apache.org/maven2/ to download open source third-party libraries,
- and more sites for other third-party software such as database specific JDBC drivers.

The downloaded third-party libraries are stored into $HOME/data/download/MIMB/
- If HTTPS fails, the import bridge then tries with HTTP.
- If a proxy is used to access internet, you must configure that proxy in the JRE (see the -j option in the Miscellaneous parameter).
- If the import bridge does not have full access to internet, that $HOME/data/download/MIMB/ directory can be copied from another server with internet access where the command $HOME/bin/MIMB.sh (or .bat) -d can be used to download all third-party libraries used by all bridges at once.

By running this import bridge, you hereby acknowledge responsibility for the license terms and any potential security vulnerabilities from these downloaded third-party software libraries.

OVERVIEW
The purpose of this Apache Spark import bridge is to detect and parse all Spark statements from Python or Scala scripts
in order to generate the exact scope (data models) of the involved source and target data stores,
as well as the data flow lineage and impact analysis (data integration ETL/ELT model) between them.

REQUIREMENTS
n/a

FREQUENTLY ASKED QUESTIONS
Q: Do I need to run the sas-metabridge-relationship-loader per source code or per source code function?
A: You may enable ("uncomment") and import multiple entry points at once.
Q: Is it recommended to import with all files from a folder at once or should they run against each file separately?
A: They will get a more complete lineage if they import the scripts together as a single program or library. This way all the internal dependencies between the modules must be resolved by the bridge automatically.
Q: Is it required to add parameters?
A: It is not required, but in some cases it may improve the final lineage.
Q: What is the purpose of override?
A: Section override is implemented for the complex from the bridge perspective of view use-cases. Here are some of the examples:
- Utility function must be overridden if it accesses configuration files or gets the values (e.g. table/column names) from a database table for further processing.
- Function changes data flow based on the conditions or in the loops. Since the bridge processes only the declarative portion of the script there might be a need to override the function in the declarative manner to attain better lineage.
Q: What is an entry point for the script, as mentioned under the -p option in the Miscellaneous parameter?
A: The Apache Spark bridge tries to mimic the native Python or Scala engine in an attempt to find where to start processing the input set of files that can be scripts, modules, etc. For more information, please refer to: https://realpython.com/lessons/scripts-modules-packages-and-libraries/. For example, one may define a number of functions, but without the entry point it will neither be imported by the bridge nor executed by the Python engine. In order to execute this script, you need to define a Python special entry points function main() or initiate the function calls from some script. For more information, please refer to: https://realpython.com/python-main-function/#a-basic-python-main or as an alternative our bridge allows to explicitly specify some of the existing functions as entry points.
Q: How is the new template generated automatically if the file does not exist?
A: You may run the bridge and specify the -p option under the Miscellaneous parameter, with a file path that does not exist. The bridge will attempt to read from this non-existent file, and will the proceed to generate a new template for you to customize and then perform a follow up import.

LIMITATIONS
Refer to the current general known limitations at http://metaintegration.com/Products/MIMB/MIMBKnownLimitations.html or bundled in Documentation/ReadMe/MIMBKnownLimitations.html

SUPPORT
Provide a troubleshooting package with:
- the debug log (can be set in the UI or in conf/conf.properties with MIR_LOG_LEVEL=6)
- the metadata backup if available (can be set in the Miscellaneous parameter with -backup option, although this common option is not implemented on all bridges for technical reasons).


Bridge Parameters

Parameter Name Description Type Values Default Scope
Directory Select a directory with the textual files that contain the code to import. DIRECTORY     Mandatory
Code Language Select the language. ENUMERATED
Python
Scala
Python  
Directory Filter Specify a search filter for the sub directories. Use regular expressions in Java format if needed (e.g. '.*_script'). Multiple conditions can be defined by using a space as a separator (e.g. 'directory1 directory2'). The condition must be escaped with double quotes if it contains any spaces inside (e.g. \"my directory\"). Negation can be defined with the preceding dash character (e.g. '-bin'). STRING      
File Filter Specify a search filter for files. Use regular expressions in Java format if needed (e.g. '.*\\.py'). Multiple conditions can be defined by using a space as a separator (e.g. 'file1 file2'). The condition must be escaped with double quotes if it contains any spaces inside (e.g. \"my file.py\"). Negation can be defined with the preceding dash character (e.g. '-\\.tar\\.gz'). STRING      
Miscellaneous INTRODUCTION
Specify miscellaneous options starting with a dash and optionally followed by parameters, e.g.
-connection.cast MyDatabase1="MICROSOFT SQL SERVER"
Some options can be used multiple times if applicable, e.g.
-connection.rename NewConnection1=OldConnection1 -connection.rename NewConnection2=OldConnection2;
As the list of options can become a long string, it is possible to load it from a file which must be located in ${MODEL_BRIDGE_HOME}\data\MIMB\parameters and have the extension .txt. In such case, all options must be defined within that file as the only value of this parameter, e.g.
ETL/Miscellaneous.txt

JAVA ENVIRONMENT OPTIONS
-java.memory <Java Memory's maximum size> (previously -m)

1G by default on 64bits JRE or as set in conf/conf.properties, e.g.
-java.memory 8G
-java.memory 8000M

-java.parameters <Java Runtime Environment command line options> (previously -j)

This option must be the last one in the Miscellaneous parameter as all the text after -java.parameters is passed "as is" to the JRE, e.g.
-java.parameters -Dname=value -Xms1G
The following option must be set when a proxy is used to access internet (this is critical to access https://repo.maven.apache.org/maven2/ and exceptionally a few other tool sites) in order to download the necessary third-party software libraries.
Note: The majority of proxies are concerned with encrypting (HTTPS) the outside (of the company) traffic and trust the inside traffic that can access proxy over HTTP. In this case, an HTTPS request reaches the proxy over HTTP where the proxy HTTPS-encrypts it.
-java.parameters -java.parameters -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass

MODEL IMPORT OPTIONS
-model.name <model name>

Override the model name, e.g.
-model.name "My Model Name"

-prescript <script name>

This option allows running a script before the bridge execution.
The script must be located in the bin directory (or as specified with M_SCRIPT_PATH in conf/conf.properties), and have .bat or .sh extension.
The script path must not include any parent directory symbol (..).
The script should return exit code 0 to indicate success, or another value to indicate failure.
For example:
-prescript "script.bat arg1 arg2"

-postscript <script name>

This option allows running a script after successful execution of the bridge.
The script must be located in the bin directory (or as specified with M_SCRIPT_PATH in conf/conf.properties), and have .bat or .sh extension.
The script path must not include any parent directory symbol (..).
The script should return exit code 0 to indicate success, or another value to indicate failure.
For example:
-postscript "script.bat arg1 arg2"

-cache.clear

Clears the cache before the import, and therefore will run a full import without incremental harvesting.

If the model was not changed and the -cache.clear parameter is not used (incremental harvesting), then a new version will not be created.
If the model was not changed and the -cache.clear parameter is set (full source import instead of incremental), then a new version will be created.

-backup <directory>

This option allows to save the bridge input metadata for further troubleshooting. The provided <directory> must be empty.

The primary use of this option is for data store import bridges, in particular JDBC based database import bridges.

Note that this option is not operational on some bridges including:
- File based import bridges (as such input files can be used instead)
- DI/BI repository import bridges (as the tool's repository native backup can be used instead)
- Some API based import bridges (e.g. COM based) for technical reasons.

DATA CONNECTION OPTIONS
Data Connections are produced by the import bridges typically from ETL/DI and BI tools to refer to the source and target data stores they use. These data connections are then used by metadata management tools to connect them (metadata stitching) to their actual data stores (e.g. databases, file system, etc.) in order to produce the full end to end data flow lineage and impact analysis. The name of each data connection is unique by import model. The data connection names used within DI/BI design tools are used when possible, otherwise connection names are generated to be short but meaningful such as the database / schema name, the file system path, or Uniform Resource Identifier (URI). The following option allows to manipulate connections. These options replaces the legacy options -c, -cd, and -cs.

-connection.cast ConnectionName=ConnectionType

Casts a generic database connection (e.g. ODBC/JDBC) to a precise database type (e.g. ORACLE) for SQL Parsing, e.g.
-connection.cast "My Database"="MICROSOFT SQL SERVER".
The list of supported data store connection types includes:
ACCESS
APACHE CASSANDRA
DB2/UDB
DENODO
GOOGLE BIGQUERY
HIVE
MYSQL
NETEZZA
ORACLE
POSTGRESQL
PRESTO
REDSHIFT
SALESFORCE
SAP HANA
SNOWFLAKE
MICROSOFT SQL AZURE
MICROSOFT SQL SERVER
SYBASE SQL SERVER
SYBASE AS ENTERPRISE
TERADATA
VECTORWISE
HP VERTICA

-connection.rename OldConnection=NewConnection

Renames an existing connection to a new name, e.g.
-connection.rename OldConnectionName=NewConnectionName
Multiple existing database connections can be renamed and merged into one new database connection, e.g.
-connection.rename MySchema1=MyDatabase -connection.rename MySchema2=MyDatabase

-connection.split oldConnection.Schema1=newConnection

Splits a database connection into one or multiple database connections.
A single database connection can be split into one connection per schema, e.g.
-connection.split MyDatabase
All database connections can be split into one connection per schema, e.g.
-connection.split *
A database connection can be explicitly split creating a new database connection by appending a schema name to a database, e.g.
-connection.split MyDatabase.schema1=MySchema1

-connection.map SourcePath=DestinationPath

Maps a source path to destination path. This is useful for file system connections when different paths points to the same object (directory or file).
On Hadoop, a process can write into a CSV file specified with the HDFS full path, but another process reads from a Hive table implemented (external) by the same file specified using a relative path with default file name and extension, e.g.
-connection.map /user1/folder=hdfs://host:8020/users/user1/folder/file.csv
On Linux, a given directory (or file) like /data can be referred to by multiple symbolic links like /users/john and /users/paul, e.g.
-connection.map /data=/users/John -connection.map /data=/users/paul
On Windows, a given directory like C:\data can be referred to by multiple network drives like M: and N:, e.g.
-connection.map C:\data=M:\ -connection.map C:\data=N:\

-connection.casesensitive ConnectionName

Overrides the default case insensitive matching rules for the object identifiers inside the specified connection, provided the detected type of the data store by itself supports this configuration (e.g. Microsoft SQL Server, MySql etc.), e.g.
-connection.casesensitive "My Database"

-connection.level AggregationLevel

Specifies the aggregation level for the external connections, e.g.-connection.level catalog
The list of the supported values:
server
catalog
schema (default)

ETL OPTIONS
These options are available on all ETL/DI tools and scripting import bridges in order to:
- Process all SQL parsing
- Build runtime models from design models and runtime variables
- Calculate runtime summary lineage

-etl.summary.add.ultimate (previously -ppus)

Adds the ultimate runtime lineage summary (may generate a very large model).

-etl.summary.only.ultimate (previously -ppsp)

Only produces the ultimate runtime lineage summary (may generate a very large model).

-etl.connections.add.internal.design (previously -pppd)

Adds the internal ETL design data connectors (needed for ETL conversion).

-etl.connections.remove.input (previously -ri)

Removes all input (source) data connections (to reduce the size of the generated model).

-etl.transformations.enable.xml

This option enables the parsing and support of XML transformations in DI/ETL import bridges such as Informatica PowerCenter, Informatica Developer, Microsoft SSIS, IBM DataStage, and Talend Data Integration.
In case of Informatica, such XML transformations corresponds to the following PowerCenter features
https://docs.informatica.com/data-integration/powercenter/10-5/xml-guide/midstream-xml-transformations.html
https://docs.informatica.com/data-integration/powercenter/10-5/xml-guide/xml-source-qualifier-transformation.html
Note that this option may significantly slow down the import.

APACHE SPARK OPTIONS
-e <encoding>

This value will be used to load text from the specified script files. By default, UTF-8 will be used. E.g.
-e UTF-16
-e UTF-16BE
-e US-ASCII

-p <path name>

Full path to the YAML file that defines all the entry points for the scripts to parse as well as their input parameters. The new template will be generated automatically if the file doesn't exist. Use double quotes in order to escape the path that contains spaces.
STRING      

 

Bridge Mapping

Mapping information is not available