Skip to content
Permalink
Browse files
Coordinated change for external function improvements
Change-Id: Idc97376bc50281d786a9b8e648c922f00012d603
  • Loading branch information
Dmitry Lychagin committed Mar 5, 2020
1 parent 802964b commit dc3d1ae16fd306ce7778a250caee3ac951a7d79d
Showing 4 changed files with 8 additions and 20 deletions.
@@ -21,9 +21,9 @@
import java.io.Reader;

import org.apache.asterix.lang.common.base.IParser;
import org.apache.asterix.lang.common.base.IParserFactory;
import org.apache.asterix.lang.sqlpp.parser.SqlppParserFactory;

public class BADParserFactory implements IParserFactory {
public class BADParserFactory extends SqlppParserFactory {

@Override
public IParser createParser(String query) {
@@ -64,7 +64,6 @@
import org.apache.asterix.metadata.MetadataManager;
import org.apache.asterix.metadata.MetadataTransactionContext;
import org.apache.asterix.metadata.declared.MetadataProvider;
import org.apache.asterix.metadata.entities.Function;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.translator.IRequestParameters;
import org.apache.asterix.translator.IStatementExecutor;
@@ -273,7 +272,7 @@ public void handle(IHyracksClientConnection hcc, IStatementExecutor statementExe
stats);

procedure = new Procedure(dataverse, signature.getName(), signature.getArity(), getParamList(),
procedureJobSpec.second.toString(), getProcedureBody(), Function.FunctionLanguage.SQLPP, duration,
procedureJobSpec.second.toString(), getProcedureBody(), SqlppParserFactory.SQLPP, duration,
dependencies);

MetadataManager.INSTANCE.addEntity(mdTxnCtx, procedure);
@@ -26,7 +26,6 @@
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.metadata.api.ExtensionMetadataDatasetId;
import org.apache.asterix.metadata.api.IExtensionMetadataEntity;
import org.apache.asterix.metadata.entities.Function;
import org.apache.hyracks.algebricks.common.utils.Triple;

public class Procedure implements IExtensionMetadataEntity {
@@ -38,7 +37,7 @@ public class Procedure implements IExtensionMetadataEntity {
private final List<String> params;
private final String body;
private final String type;
private final Function.FunctionLanguage language;
private final String language;
private final String duration;
/*
Dependencies are stored as an array of size two:
@@ -50,7 +49,7 @@ public class Procedure implements IExtensionMetadataEntity {
private final List<List<Triple<DataverseName, String, String>>> dependencies;

public Procedure(DataverseName dataverseName, String functionName, int arity, List<String> params, String type,
String functionBody, Function.FunctionLanguage language, String duration,
String functionBody, String language, String duration,
List<List<Triple<DataverseName, String, String>>> dependencies) {
this.procedureId = new EntityId(BADConstants.PROCEDURE_KEYWORD, dataverseName, functionName);
this.params = params;
@@ -84,7 +83,7 @@ public String getType() {
return type;
}

public Function.FunctionLanguage getLanguage() {
public String getLanguage() {
return language;
}

@@ -23,11 +23,8 @@
import java.util.List;

import org.apache.asterix.builders.OrderedListBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.common.exceptions.MetadataException;
import org.apache.asterix.common.metadata.DataverseName;
import org.apache.asterix.metadata.entities.Function;
import org.apache.asterix.metadata.entitytupletranslators.AbstractTupleTranslator;
import org.apache.asterix.om.base.AOrderedList;
import org.apache.asterix.om.base.ARecord;
@@ -91,16 +88,9 @@ public Procedure createMetadataEntityFromARecord(ARecord procedureRecord) throws
String definition = ((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_DEFINITION_FIELD_INDEX))
.getStringValue();

String languageValue = ((AString) procedureRecord
String language = ((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_LANGUAGE_FIELD_INDEX))
.getStringValue();
Function.FunctionLanguage language;
try {
language = Function.FunctionLanguage.valueOf(languageValue);
} catch (IllegalArgumentException e) {
throw new AsterixException(ErrorCode.METADATA_ERROR, languageValue);
}

String duration = ((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_DURATION_FIELD_INDEX))
@@ -206,7 +196,7 @@ public ITupleReference getTupleFromMetadataEntity(Procedure procedure)

// write field 6
fieldValue.reset();
aString.setValue(procedure.getLanguage().name());
aString.setValue(procedure.getLanguage());
stringSerde.serialize(aString, fieldValue.getDataOutput());
recordBuilder.addField(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_LANGUAGE_FIELD_INDEX, fieldValue);

0 comments on commit dc3d1ae

Please sign in to comment.