Class PigConverter

java.lang.Object
org.apache.pig.PigServer
org.apache.calcite.piglet.PigConverter

public class PigConverter extends org.apache.pig.PigServer
Extension from PigServer to convert Pig scripts into logical relational algebra plans and SQL statements.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.pig.PigServer

    org.apache.pig.PigServer.Graph
  • Field Summary

    Fields inherited from class org.apache.pig.PigServer

    graphs, log, pigContext, PRETTY_PRINT_SCHEMA_PROPERTY, scope
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a PigConverter using default property settings.
    create(FrameworkConfig config, Properties properties)
    Creates a PigConverter using the given property settings.
     
    Gets a Pig script string from a file after doing param substitution.
    pigQuery2Rel(String pigQuery)
    Parses a Pig script and converts it into relational algebra plans, optimizing the result.
    pigQuery2Rel(String pigQuery, boolean planRewrite, boolean validate, boolean usePigRules)
    Parses a Pig script and converts it into relational algebra plans.
    pigScript2Rel(String fileName, Map<String,String> params, boolean planRewrite)
    Parses a Pig script and converts it into relational algebra plans.
    pigToSql(String pigQuery, SqlDialect sqlDialect)
    Converts a Pig script to a list of SQL statements.

    Methods inherited from class org.apache.pig.PigServer

    addPathToSkip, capacity, debugOff, debugOn, deleteFile, discardBatch, dumpSchema, dumpSchemaNested, executeBatch, executeBatch, existsFile, explain, explain, fileSize, getAliases, getAliasKeySet, getClonedGraph, getCurrentDAG, getExamples, getJobs, getLastRel, getLogicalPlanData, getPigContext, isBatchEmpty, isBatchOn, launchPlan, listPaths, mkdirs, openIterator, paramMapToList, parseAndBuild, printAliases, printHistory, registerCode, registerFunction, registerJar, registerQuery, registerQuery, registerScript, registerScript, registerScript, registerScript, registerScript, registerScript, registerScript, registerScript, registerStreamingCommand, renameFile, resetScope, setBatchOn, setDefaultParallel, setJobName, setJobPriority, setSkipParseInRegisterForBatch, setValidateEachStatement, shutdown, store, store

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static PigConverter create(FrameworkConfig config, Properties properties) throws Exception
      Creates a PigConverter using the given property settings.
      Throws:
      Exception
    • create

      public static PigConverter create(FrameworkConfig config) throws Exception
      Creates a PigConverter using default property settings.
      Throws:
      Exception
    • getBuilder

      public PigRelBuilder getBuilder()
    • pigQuery2Rel

      public List<RelNode> pigQuery2Rel(String pigQuery) throws IOException
      Parses a Pig script and converts it into relational algebra plans, optimizing the result.

      Equivalent to pigQuery2Rel(pigQuery, true, true, true).

      Parameters:
      pigQuery - Pig script
      Returns:
      A list of root nodes of the translated relational plans. Each of these root corresponds to a sink operator (normally a STORE command) in the Pig plan
      Throws:
      IOException - Exception during parsing or translating Pig
    • pigQuery2Rel

      public List<RelNode> pigQuery2Rel(String pigQuery, boolean planRewrite, boolean validate, boolean usePigRules) throws IOException
      Parses a Pig script and converts it into relational algebra plans.
      Parameters:
      pigQuery - Pig script
      planRewrite - Whether to rewrite the translated plan
      validate - Whether to validate the Pig logical plan before doing translation
      usePigRules - Whether to use Pig Rules (see PigRelPlanner} to rewrite translated rel plan
      Returns:
      A list of root nodes of the translated relational plans. Each of these root corresponds to a sink operator (normally a STORE command) in the Pig plan
      Throws:
      IOException - Exception during parsing or translating Pig
    • getPigScript

      public String getPigScript(InputStream in, Map<String,String> params) throws IOException
      Gets a Pig script string from a file after doing param substitution.
      Parameters:
      in - Pig script file
      params - Param sub map
      Throws:
      IOException
    • pigScript2Rel

      public List<RelNode> pigScript2Rel(String fileName, Map<String,String> params, boolean planRewrite) throws IOException
      Parses a Pig script and converts it into relational algebra plans.
      Parameters:
      fileName - File name
      params - Param substitution map
      planRewrite - Whether to rewrite the translated plan
      Returns:
      A list of root nodes of the translated relational plans. Each of these root corresponds to a sink operator (normally a STORE command) in the Pig plan
      Throws:
      IOException - Exception during parsing or translating Pig
    • pigToSql

      public List<String> pigToSql(String pigQuery, SqlDialect sqlDialect) throws IOException
      Converts a Pig script to a list of SQL statements.
      Parameters:
      pigQuery - Pig script
      sqlDialect - Dialect of SQL language
      Throws:
      IOException - Exception during parsing or translating Pig