Package org.apache.calcite.piglet
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 TypeMethodDescriptionstatic PigConverter
create
(FrameworkConfig config) Creates a PigConverter using default property settings.static PigConverter
create
(FrameworkConfig config, Properties properties) Creates a PigConverter using the given property settings.getPigScript
(InputStream in, Map<String, String> params) 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
-
Method Details
-
create
Creates a PigConverter using the given property settings.- Throws:
Exception
-
create
Creates a PigConverter using default property settings.- Throws:
Exception
-
getBuilder
-
pigQuery2Rel
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 scriptplanRewrite
- Whether to rewrite the translated planvalidate
- Whether to validate the Pig logical plan before doing translationusePigRules
- 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
Gets a Pig script string from a file after doing param substitution.- Parameters:
in
- Pig script fileparams
- Param sub map- Throws:
IOException
-
pigScript2Rel
public List<RelNode> pigScript2Rel(String fileName, Map<String, String> params, boolean planRewrite) throws IOExceptionParses a Pig script and converts it into relational algebra plans.- Parameters:
fileName
- File nameparams
- Param substitution mapplanRewrite
- 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
Converts a Pig script to a list of SQL statements.- Parameters:
pigQuery
- Pig scriptsqlDialect
- Dialect of SQL language- Throws:
IOException
- Exception during parsing or translating Pig
-