Skip to content
Permalink
Browse files
Coordinated Change for CREATE OR REPLACE FUNCTION
Change-Id: I5d28fc67de8dc4016339dd75e07cb23b426dabf4
  • Loading branch information
idleft committed Aug 28, 2020
1 parent d1df64d commit 0bc1dfd8baae50b25740e9fc6c744b9de4c122cb
Showing 4 changed files with 11 additions and 15 deletions.
@@ -192,24 +192,20 @@ private Pair<JobSpecification, PrecompiledType> createProcedureJob(IStatementExe
} else if (getProcedureBodyStatement().getKind() == Statement.Kind.QUERY) {
//TODO: Fix type dependency computation
SqlppRewriterFactory fact = new SqlppRewriterFactory(new SqlppParserFactory());
dependencies.get(1)
.addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider, new ArrayList<>())
.get(1));
dependencies.get(1).addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider).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, new ArrayList<>())
.get(0));
dependencies.get(0).addAll(FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(),
((Query) getProcedureBodyStatement()).getBody(), metadataProvider).get(0));
return pair;
} else if (getProcedureBodyStatement().getKind() == Statement.Kind.DELETE) {
getProcedureBodyStatement().accept(SqlppDeleteRewriteVisitor.INSTANCE, metadataProvider);
DeleteStatement delete = (DeleteStatement) getProcedureBodyStatement();

SqlppRewriterFactory fact = new SqlppRewriterFactory(new SqlppParserFactory());
dependencies = FunctionUtil.getFunctionDependencies(fact.createQueryRewriter(), delete.getQuery().getBody(),
metadataProvider, new ArrayList<>());
metadataProvider);
Pair<JobSpecification, PrecompiledType> pair =
new Pair<>(((QueryTranslator) statementExecutor).handleDeleteStatement(metadataProvider,
getProcedureBodyStatement(), hcc, true, null, null), PrecompiledType.DELETE);
@@ -138,7 +138,7 @@ private void createChannelTimeAssignOps(Mutable<ILogicalOperator> opRef, Set<Log
if (needPrevDsSet.contains(dsVar) || needActiveDsSet.contains(dsVar)) {
LogicalVariable channelTimeVar = context.newVar();
ILogicalExpression previousChannelTimeExpr = new ScalarFunctionCallExpression(
BuiltinFunctions.getAsterixFunctionInfo(BADFunctions.PREVIOUS_CHANNEL_TIME),
BuiltinFunctions.getBuiltinFunctionInfo(BADFunctions.PREVIOUS_CHANNEL_TIME),
new MutableObject<>(
new ConstantExpression(new AsterixConstantValue(new AString(channelName)))));
AssignOperator assignOp =
@@ -151,7 +151,7 @@ private void createChannelTimeAssignOps(Mutable<ILogicalOperator> opRef, Set<Log
if (needCurrDsSet.contains(dsVar) || needActiveDsSet.contains(dsVar)) {
LogicalVariable channelTimeVar = context.newVar();
ILogicalExpression previousChannelTimeExpr = new ScalarFunctionCallExpression(
BuiltinFunctions.getAsterixFunctionInfo(BADFunctions.CURRENT_CHANNEL_TIME), new MutableObject<>(
BuiltinFunctions.getBuiltinFunctionInfo(BADFunctions.CURRENT_CHANNEL_TIME), new MutableObject<>(
new ConstantExpression(new AsterixConstantValue(new AString(channelName)))));
AssignOperator assignOp =
new AssignOperator(channelTimeVar, new MutableObject<>(previousChannelTimeExpr));
@@ -255,7 +255,7 @@ CreateContinuousChannelStatement CreateContinuousChannel(Token startStmtToken) t
removeCurrentScope();
defaultDataverse = currentDataverse;
ensureNoTypeDeclsInFunction(fctName.function, params, returnType, startStmtToken);
CreateFunctionStatement stmt = new CreateFunctionStatement(signature, params, functionBody, functionBodyExpr, false);
CreateFunctionStatement stmt = new CreateFunctionStatement(signature, params, functionBody, functionBodyExpr, true, false);
ccs = new CreateContinuousChannelStatement(fctName.dataverse, new Identifier(fctName.function), period, push, stmt);
return addSourceLocation(ccs, startStmtToken);
}
@@ -77,7 +77,7 @@
<test-case FilePath="procedure">
<compilation-unit name="delete_procedure_drop_function">
<output-dir compare="Text">delete_procedure_drop_function</output-dir>
<expected-error>Cannot drop function two.really_contains@2. two.deleteSome(Procedure) depends on it!</expected-error>
<expected-error>Cannot drop function two.really_contains</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="procedure">
@@ -95,7 +95,7 @@
<test-case FilePath="procedure">
<compilation-unit name="query_procedure_drop_function">
<output-dir compare="Text">query_procedure_drop_function</output-dir>
<expected-error>Cannot drop function channels.really_contains@2. two.selectSome(Procedure) depends on it!</expected-error>
<expected-error>Cannot drop function channels.really_contains</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="procedure">
@@ -133,7 +133,7 @@
<test-case FilePath="bad_rq">
<compilation-unit name="drop_function">
<output-dir compare="Text">drop_function</output-dir>
<expected-error>Cannot drop function channels.NearbyTweetsContainingText@2. two.nearbyTweetChannel(Channel) depends on it!</expected-error>
<expected-error>Cannot drop function channels.NearbyTweetsContainingText</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="bad_rq">

0 comments on commit 0bc1dfd

Please sign in to comment.