This is an automated email from the ASF dual-hosted git repository. jhyde pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/calcite.git
commit 296b84cad4406be03f2db35ce6077ad8fed4fef6 Author: Mahesh Kumar Behera <[email protected]> AuthorDate: Fri Apr 9 18:03:04 2021 +0530 [CALCITE-4569] In piglet, allow creating a PigConverter with custom properties (Mahesh Kumar Behera) Close apache/calcite#2391 --- .../java/org/apache/calcite/piglet/PigConverter.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/piglet/src/main/java/org/apache/calcite/piglet/PigConverter.java b/piglet/src/main/java/org/apache/calcite/piglet/PigConverter.java index fdcc092..6219c96 100644 --- a/piglet/src/main/java/org/apache/calcite/piglet/PigConverter.java +++ b/piglet/src/main/java/org/apache/calcite/piglet/PigConverter.java @@ -40,6 +40,7 @@ import org.apache.calcite.tools.RuleSets; import org.apache.pig.ExecType; import org.apache.pig.PigServer; import org.apache.pig.impl.logicalLayer.FrontendException; +import org.apache.pig.impl.util.PropertiesUtil; import org.apache.pig.newplan.logical.relational.LogicalPlan; import com.google.common.collect.ImmutableList; @@ -49,6 +50,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Properties; /** * Extension from PigServer to convert Pig scripts into logical relational @@ -98,14 +100,22 @@ public class PigConverter extends PigServer { private final PigRelBuilder builder; - private PigConverter(FrameworkConfig config, ExecType execType) - throws Exception { - super(execType); + /** Private constructor. */ + private PigConverter(FrameworkConfig config, ExecType execType, + Properties properties) throws Exception { + super(execType, properties); this.builder = PigRelBuilder.create(config); } + /** Creates a PigConverter using the given property settings. */ + public static PigConverter create(FrameworkConfig config, + Properties properties) throws Exception { + return new PigConverter(config, ExecType.LOCAL, properties); + } + + /** Creates a PigConverter using default property settings. */ public static PigConverter create(FrameworkConfig config) throws Exception { - return new PigConverter(config, ExecType.LOCAL); + return create(config, PropertiesUtil.loadDefaultProperties()); } public PigRelBuilder getBuilder() {
