Skip to content
Permalink
Browse files
Coordinated change for CREATE FUNCTION w/ UDFs
Change-Id: I50cff0948dad342f0d2e5b5250e3247bfd6fcd0d
  • Loading branch information
parshimers committed Feb 3, 2020
1 parent 1414bb9 commit 80ab7db4d2f3451f08ed6bfc84507a09cbcf23ad
Showing 3 changed files with 22 additions and 13 deletions.
@@ -190,21 +190,26 @@ private Pair<JobSpecification, PrecompiledType> createProcedureJob(IStatementExe
getProcedureBodyStatement(), hcc, null, ResultDelivery.ASYNC, null, stats, true, null, null, null),
PrecompiledType.INSERT);
} else if (getProcedureBodyStatement().getKind() == Statement.Kind.QUERY) {
//TODO: Fix type dependency computation
SqlppRewriterFactory fact = new SqlppRewriterFactory();
dependencies.get(1).addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider).get(1));
dependencies.get(1)
.addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider, new ArrayList<>())
.get(1));
Pair<JobSpecification, PrecompiledType> pair = new Pair<>(BADJobService.compileQueryJob(statementExecutor,
metadataProvider, hcc, (Query) getProcedureBodyStatement()), PrecompiledType.QUERY);
dependencies.get(0).addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider).get(0));
dependencies.get(0)
.addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider, new ArrayList<>())
.get(0));
return pair;
} else if (getProcedureBodyStatement().getKind() == Statement.Kind.DELETE) {
getProcedureBodyStatement().accept(SqlppDeleteRewriteVisitor.INSTANCE, metadataProvider);
DeleteStatement delete = (DeleteStatement) getProcedureBodyStatement();

SqlppRewriterFactory fact = new SqlppRewriterFactory();
dependencies = FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(), delete.getQuery().getBody(),
metadataProvider);
metadataProvider, new ArrayList<>());
Pair<JobSpecification, PrecompiledType> pair =
new Pair<>(((QueryTranslator) statementExecutor).handleDeleteStatement(metadataProvider,
getProcedureBodyStatement(), hcc, true, null, null), PrecompiledType.DELETE);
@@ -120,7 +120,7 @@ CreateProcedureStatement CreateProcedureStatement() throws ParseException:
{
FunctionName fctName = null;
FunctionSignature signature;
List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
List<Pair<VarIdentifier,IndexedTypeExpression>> paramList = new ArrayList<Pair<VarIdentifier,IndexedTypeExpression>>();
List<Integer> paramIds = new ArrayList<Integer>();
String functionBody;
Token beginPos;
@@ -135,12 +135,12 @@ CreateProcedureStatement CreateProcedureStatement() throws ParseException:
{
defaultDataverse = fctName.dataverse;
}
paramList = ParameterList()
paramList = FunctionParameters()
<LEFTBRACE>
{
for (VarIdentifier param : paramList)
for (Pair<VarIdentifier,IndexedTypeExpression> param : paramList)
{
VarIdentifier v = new VarIdentifier(param.toString());
VarIdentifier v = new VarIdentifier(param.getFirst().toString());
getCurrentScope().addNewVarSymbolToScope(v);
paramIds.add(v.getId());
}
@@ -156,7 +156,11 @@ CreateProcedureStatement CreateProcedureStatement() throws ParseException:
}
("period" period = FunctionCallExpr())?
{
return new CreateProcedureStatement(signature, paramList, paramIds, functionBody, period);
List<VarIdentifier> paramListVariablesOnly = new ArrayList<VarIdentifier>();
for(Pair<VarIdentifier,IndexedTypeExpression> p: paramList){
paramListVariablesOnly.add(p.first);
}
return new CreateProcedureStatement(signature, paramListVariablesOnly, paramIds, functionBody, period);
}
}

@@ -1,6 +1,6 @@
{ "DataverseName": "two", "ProcedureName": "addMe", "Arity": "0", "Params": [ ], "Type": "INSERT", "Definition": "use `two`;\ninsert into channels.UserLocations([\n {\"timeStamp\":current_datetime(), \"roomNumber\":222}]\n );", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "channels", "UserLocations" ] ], [ ] ] }
{ "DataverseName": "two", "ProcedureName": "deleteSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "DELETE", "Definition": "use `two`;\ndelete from channels.UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand channels.really_contains(roomNumber,\"l\");", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "channels", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "channels", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ] ] }
{ "DataverseName": "two", "ProcedureName": "deleteSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "DELETE", "Definition": "use `two`;\ndelete from channels.UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand channels.really_contains(roomNumber,\"l\");", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "channels", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "channels", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ], [ ] ] }
{ "DataverseName": "two", "ProcedureName": "localAddMe", "Arity": "0", "Params": [ ], "Type": "INSERT", "Definition": "use `two`;\ninsert into UserLocations([\n {\"timeStamp\":current_datetime(), \"roomNumber\":222}]\n );", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "two", "UserLocations" ] ], [ ] ] }
{ "DataverseName": "two", "ProcedureName": "localDeleteSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "DELETE", "Definition": "use `two`;\ndelete from UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand really_contains(roomNumber,\"l\");", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "two", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "two", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ] ] }
{ "DataverseName": "two", "ProcedureName": "localDeleteSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "DELETE", "Definition": "use `two`;\ndelete from UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand really_contains(roomNumber,\"l\");", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "two", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "two", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ], [ ] ] }
{ "DataverseName": "two", "ProcedureName": "localSelectSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "QUERY", "Definition": "use `two`;\nselect roomNumber from UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand really_contains(roomNumber,\"l\")\norder by id;", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "two", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "two", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ] ] }
{ "DataverseName": "two", "ProcedureName": "selectSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "QUERY", "Definition": "use `two`;\nselect roomNumber from channels.UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand channels.really_contains(roomNumber,\"l\")\norder by id;", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "channels", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "channels", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ] ] }
{ "DataverseName": "two", "ProcedureName": "selectSome", "Arity": "2", "Params": [ "r", "otherRoom" ], "Type": "QUERY", "Definition": "use `two`;\nselect roomNumber from channels.UserLocations\nwhere roomNumber = get_job_param(\"r\")\nor roomNumber = get_job_param(\"otherRoom\")\nand channels.really_contains(roomNumber,\"l\")\norder by id;", "Language": "SQLPP", "Duration": "", "Dependencies": [ [ [ "channels", "UserLocations" ] ], [ [ "two", "get_job_param", "1" ], [ "channels", "really_contains", "2" ], [ "two", "get_job_param", "1" ] ] ] }

0 comments on commit 80ab7db

Please sign in to comment.