{"id":2649,"date":"2023-02-10T10:15:36","date_gmt":"2023-02-10T15:15:36","guid":{"rendered":"https:\/\/www.dpriver.com\/blog\/?p=2649"},"modified":"2023-02-23T10:07:52","modified_gmt":"2023-02-23T15:07:52","slug":"generate-data-lineage-with-sqlflow-ingester","status":"publish","type":"post","link":"https:\/\/www.dpriver.com\/blog\/2023\/02\/generate-data-lineage-with-sqlflow-ingester\/","title":{"rendered":"Generate data lineage with SQLFlow-Ingester"},"content":{"rendered":"\n

### Why SQLFlow-Ingester?<\/h3>\n\n\n\n

Gudu SQLFlow<\/a> supports two kinds of file as the input:<\/p>\n\n\n\n

- SQL file, including comments. DDL file for an example, sql such as create table can be used as metadata.<\/li><\/ul>\n\n\n\n
  - Json files which contain the database metadata<\/li><\/ul>\n\n\n\n

    All other kinds of the input will be no longer supported and users shall convert the inputs to the above two formats. As a result, an out-of-box tool is needed to complete that conversion and automatically submit SQLFlow task.<\/p>\n\n\n\n

    ### SQLFlow-Ingester Basic<\/h3>\n\n\n\n

    SQLFlow-Ingester is a tool that helps you to extract metadata from various databases and create SQLFlow job based on your database. The extracted metadata file can also be used by dlineage tool<\/a> to generate data lineage.<\/p>\n\n\n\n

    <\/figure>\n\n\n\n

    SQLFlow-Ingester download address: https:\/\/github.com\/sqlparser\/sqlflow_public\/releases<\/a><\/p>\n\n\n\n

    SQLFlow-Ingester has three different parts:<\/p>\n\n\n\n

    - sqlflow-exporter: getting metadata from database<\/li>
    - sqlflow-extractor: processing raw data files such as log files, various script files (from which SQL statements and metadata to be processed are extracted), CSV files containing SQL statements, etc.<\/li>
    - sqlflow-submitter: submitting sql and metadata to the sqlflow server, creating jobs, generating data lineage, and having the results in the UI.<\/li><\/ul>\n\n\n\n

      ### SQLFlow-Exporter<\/h3>\n\n\n\n

      SQLFlow-exporter is the main functionality of the SQLFlow-Ingester. It can be used to get the metadata from different databases.<\/p>\n\n\n\n

      #### SQLFlow-Exporter Usage<\/h4>\n\n\n\n

      Under Linux & Mac<\/strong>:<\/p>\n\n\n\n

      ####

      - ###

        ####

        ####

          .\/exporter.sh -host 127.0.0.1 -port 1521 -db orcl -user scott -pwd tiger -save \/tmp\/sqlflow-ingester -dbVendor dbvoracle<\/code><\/pre>\n\n\n\nUnder windows<\/strong>:<\/p>\n\n\n\nexporter.bat -host 127.0.0.1 -port 1521 -db orcl -user scott -pwd tiger -save c:\\tmp\\sqlflow-ingester -dbVendor dbvoracle<\/code><\/pre>\n\n\n\nOr you can directly execute the .jar package, the jar packages are under the .\/lib<\/code> folder:<\/p>\n\n\n\njava -jar sqlflow-exporter-1.0.jar  -host 106.54.xx.xx -port 1521 -db orcl -user username -pwd password -save d:\/ -dbVendor dbvoracle<\/code><\/pre>\n\n\n\nA metadata.json file will be generated after the success export of metadta from the database.<\/p>\n\n\n\nExample for the success output:<\/p>\n\n\n\nexporter metadata success: <-save>\/metadata.json<\/code><\/pre>\n\n\n\n<\/figure>\n\n\n\nParameters<\/strong>
          -dbVendor: Database type. Use colon to split dbVendor and version if specific version is required. (:, such as dbvmysql:5.7)
          -host: Database host name (ip address or domain name)
          -port: Port number
          -db: Database name
          -user: User name
          -pwd: User password
          -save: Destination folder path where we put the exported metadata json file. The exported file will be in name as metadata.json.
          -extractedDbsSchemas: Export metadata under the specific schema. Use comma to split if multiple schema required (such as ,). We can use this flag to improve the export performance.
          -excludedDbsSchemas: Exclude metadata under the specific schema during the export. Use comma to split if multiple schema required (such as ,). We can use this flag to improve the export performance.
          -extractedViews: Export metadata under the specific view. Use comma to split if multiple views required (such as ,). We can use this flag to improve the export performance.
          -merge: Merge the metadata results which are exported in different process. Use comma to split files to merge.<\/p>\n\n\n\nImprove Export Performance<\/h4>\n\n\n\nTime consumed during the export from database could be very long if the data volume is huge. Following actions are made to improve the Ingester export performance:<\/p>\n\n\n\nJDBC fetchsize<\/code> is set to 1000 for table and view. For sql of view and process the fetchsize<\/code> is set to 500. (check this oracle doc for what is jdbc fetchsize<\/code>: https:\/\/docs.oracle.com\/middleware\/1212\/toplink\/TLJPA\/q_jdbc_fetch_size.htm#TLJPA647<\/a>)<\/li>Parameters extractedDbsSchemas<\/code>, excludedDbsSchemas<\/code> and extractedViews<\/code> are improved for oracle and postgresql. A plan has already been made to improve the implementation of these parameters for other databases.<\/li><\/ul>\n\n\n\n-merge<\/code> can be used to merge the metadata results. Use comma to split files to merge. All files under the folder will be merged if the given value is the folder path.<\/p>\n\n\n\nexporter.bat -dbVendor dbvpostgresql -extractedDbsSchemas kingland.dbt%,kingland.pub%  -host 115.159.225.38 -port 5432 -db kingland -user bigking -pwd Cat_*** -save D:\/out\/1.json\nexporter.bat -dbVendor dbvpostgresql -extractedDbsSchemas kingland.sqlflow  -host 115.159.225.38 -port 5432 -db kingland -user bigking -pwd Cat_*** -save D:\/out\/2.json\nexporter.bat -merge  D:\/out\/1.json,D:\/out\/2.json    -save D:\/out\/merge.json\nor\nexporter.bat -merge  D:\/out\/   -save D:\/out\/merge.json<\/code><\/pre>\n\n\n\nSQLFlow-Submitter<\/h3>\n\n\n\nAfter decompressing the package, you will find submitter.bat<\/code> for Windows and submitter.sh<\/code> for Linux & Mac.<\/p>\n\n\n\nUnder Linux & Mac<\/strong>:<\/figcaption><\/figure>\n\n\n\nbash submitter.sh -f <path_to_config_file>  \n\nnote: \n    path_to_config_file: the full path to the config file\n\neg: \n    bash submitter.sh -f \/home\/workspace\/gudu_ingester\/submitter_config.json<\/code><\/pre>\n\n\n\nUnder Windows<\/strong>:<\/p>\n\n\n\nsubmitter.bat -f D:\/mssql-winuser-config.json<\/code><\/pre>\n\n\n\n<\/figure>\n\n\n\nAfter successfully executing the Submitter, check the Job list on UI and you will find the job submitted by the Submitter, with the Job name configured in the configuration file.<\/p>\n\n\n\nCron Job<\/a><\/h4>\n\n\n\nIf you are on Linux or Mac, you can schedule the submitter with crontab<\/code> to create a cron job.<\/p>\n\n\n\ncrontab -e<\/code><\/pre>\n\n\n\nIn the editor opened by the above command, let’s say now we want to schedule a daily cron job, add the following code:<\/p>\n\n\n\n0 0 * * * bash submitter.sh -f <path_to_config_file> <lib_path>\n\nnote: \n    path_to_config_file: config file path \n    lib_path: lib directory absolute path<\/code><\/pre>\n\n\n\nPlease check this document<\/a> for more information about cron<\/code> and you can learn the cron<\/code> grammar with Wikipedia<\/a>.<\/p>\n\n\n\nSQLFlow-Submitter Log<\/a><\/h4>\n\n\n\nThe logs of the submitter are persisted under log<\/code> folder.<\/p>\n\n\n\n<\/figure>\n","protected":false},"excerpt":{"rendered":"Why SQLFlow-Ingester? Gudu SQLFlow supports two kinds of file as the input: SQL file, including comments. DDL file for an example, sql such as create table can be used as metadata. Json files which contain the database metadata All other kinds of the input will be no longer supported and users shall convert the inputs to the above two formats. As a result, an out-of-box tool is needed to complete that conversion and automatically submit SQLFlow task. SQLFlow-Ingester Basic SQLFlow-Ingester is a tool that helps you to extract metadata from various databases and create SQLFlow job based on your database.\u2026<\/p>\n","protected":false},"author":6,"featured_media":2436,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[66,93],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"yoast_head":"\nGenerate data lineage with SQLFlow-Ingester<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\n\t\n\t\n\t\n