Adding a JSON File to a Function Archive

Teradata® Vantage User Guide

brand
Teradata Vantage
prodname
Teradata Vantage
vrm_release
1.0
category
User Guide
featnum
B700-4002-098K
To add a JSON file into a function archive, provide the JSON file as part of the build process to be included in the function archive. If you already have an archive file, you can add the JSON file into the archive zip or jar file using the Java Archive (jar) tool and zip utility. The following example shows the step-by-step process of adding a JSON file, DTW.json, into a function zip file, DTW.zip, on a Linux-based system. If your function archive is a jar file into which you want to add the JSON file, you need only steps 4 through 8.
  1. Verify the contents of DTW.zip: $ jar tf DTW.zip
    DTW.jar
    FastDTW-1.1.0 jar
    sql-mr_utilities.jar
  2. Unzip DTW.zip to extract the three jar files listed in the previous step: $ unzip DTW.zip
    Archive:  DTW.zip
      inflating: DTW.jar
      inflating: FastDTW-1.1.0.jar 
      inflating: sql-mr_utilities.jar
  3. Verify the contents of DTW.jar to which you want to add DTW.json: $ jar tf DTW.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/asterdata/
    com/asterdata/sqlmr/
    com/asterdata/sqlmr/functions/
    com/asterdata/sqlmr/functions/analytics/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTW.class
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTWArgs.class
  4. Extract DTW.jar and list the directory: $ jar xf DTW.jar The jar file gives you compiled code in a directory structure (which in this example is under com/) and a manifest directory under META-INF/.
    $ ls com DTW.jar DTW.json DTW.zip FastDTW-1.1.0.jar META-INF sql-mr_utilities.jar
  5. Delete the DTW.jar and DTW.zip files (because you will create new jar and zip files): $ rm DTW.jar $ rm DTW.zip
  6. Delete the META-INF directory (because the jar tool generates it when you create a jar file): $ rm -r META-INF/
  7. Copy DTW.json into the source code directory structure at the same sub-directory level where the function class resides: $ cp DTW.json com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/
  8. Create a new archive DTW.jar file from the source code: $ jar cf DTW.jar com/
  9. Verify that the contents of the jar file match the contents of the old jar file, except the JSON file: $ jar tf DTW.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/asterdata/
    com/asterdata/sqlmr/
    com/asterdata/sqlmr/functions/
    com/asterdata/sqlmr/functions/analytics/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTW.class
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTWArgs.class
  10. Create a new zip file from the newly created DTW.jar and other libraries in the zip file: $ zip -r DTW.zip DTW.jar FastDTW-1.1.0.jar sql-mr_utilities.jar
    adding: DTW.jar (deflated 11%)
      adding: FastDTW-1.1.0.jar (deflated 8%)
      adding: sql-mr_utilities.jar (deflated 11%)
    
  11. Verify the contents of DTW.zip: $ jar tf DTW.zip
    DTW.jar
    FastDTW-1.1.0.jar
    sql-mr_utilities.jar
    The archive file DTW.zip is ready to installed on Teradata ML Engine.