-
Notifications
You must be signed in to change notification settings - Fork 1.3k
modifying execute API to get column nullability state #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
080216e
d9cf5bc
6ae414e
b1fa542
aa0e088
e4a3a43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.cdap.wrangler.proto.workspace.v2; | ||
|
||
/** | ||
* UserDefinedAction enum. | ||
*/ | ||
public enum UserDefinedAction { | ||
FILTER, | ||
SEND_TO_ERROR_COLLECTOR, | ||
ERROR, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
import io.cdap.wrangler.proto.workspace.v2.ServiceResponse; | ||
import io.cdap.wrangler.proto.workspace.v2.StageSpec; | ||
import io.cdap.wrangler.proto.workspace.v2.Workspace; | ||
import io.cdap.wrangler.proto.workspace.v2.UserDefinedAction; | ||
import io.cdap.wrangler.proto.workspace.v2.WorkspaceCreationRequest; | ||
import io.cdap.wrangler.proto.workspace.v2.WorkspaceDetail; | ||
import io.cdap.wrangler.proto.workspace.v2.WorkspaceId; | ||
|
@@ -169,7 +170,8 @@ public void createWorkspace(HttpServiceRequest request, HttpServiceResponder res | |
long now = System.currentTimeMillis(); | ||
Workspace workspace = Workspace.builder(generateWorkspaceName(wsId, creationRequest.getSampleRequest().getPath()), | ||
wsId.getWorkspaceId()) | ||
.setCreatedTimeMillis(now).setUpdatedTimeMillis(now).setSampleSpec(spec).build(); | ||
.setCreatedTimeMillis(now).setUpdatedTimeMillis(now) | ||
.setSampleSpec(spec).setNullabilityMap(new HashMap<>()).build(); | ||
wsStore.saveWorkspace(wsId, new WorkspaceDetail(workspace, rows)); | ||
responder.sendJson(wsId.getWorkspaceId()); | ||
}); | ||
|
@@ -472,6 +474,11 @@ private DirectiveExecutionResponse execute(NamespaceSummary ns, HttpServiceReque | |
|
||
WorkspaceDetail detail = wsStore.getWorkspaceDetail(workspaceId); | ||
UserDirectivesCollector userDirectivesCollector = new UserDirectivesCollector(); | ||
Map<String, UserDefinedAction> nullabilityMap = executionRequest.getNullabilityMap(); | ||
if (!nullabilityMap.isEmpty()) { | ||
//create new workspace object with the new nullabilityMap | ||
changeNullability(nullabilityMap, workspaceId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should update the workspace after executing the directives (this is already happening), not before. Otherwise the execution can fail and now there's a partially updated workspace. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need the updated nullabilityMap before directives are executed. |
||
} | ||
List<Row> result = executeDirectives(ns.getName(), directives, detail, | ||
userDirectivesCollector); | ||
DirectiveExecutionResponse response = generateExecutionResponse(result, | ||
|
@@ -484,6 +491,20 @@ private DirectiveExecutionResponse execute(NamespaceSummary ns, HttpServiceReque | |
return response; | ||
} | ||
|
||
private void changeNullability(Map<String, UserDefinedAction> nullabilityMap, | ||
WorkspaceId workspaceId) throws Exception { | ||
try { | ||
Workspace workspace = wsStore.getWorkspace(workspaceId); | ||
Workspace newWorkspace = Workspace.builder(workspace) | ||
.setUpdatedTimeMillis(System.currentTimeMillis()) | ||
.setNullabilityMap(nullabilityMap).build(); | ||
wsStore.updateWorkspace(workspaceId, newWorkspace); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Error in setting nullabilityMap of columns ", e); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Get source specs, contains some hacky way on dealing with the csv parser | ||
*/ | ||
|
@@ -580,7 +601,7 @@ private <E extends Exception> List<Row> executeLocally(String namespace, List<St | |
// load the udd | ||
composite.reload(namespace); | ||
return executeDirectives(namespace, directives, new ArrayList<>(detail.getSample()), | ||
grammarVisitor); | ||
grammarVisitor, detail.getWorkspace().getNullabilityMap()); | ||
} | ||
|
||
/** | ||
|
Uh oh!
There was an error while loading. Please reload this page.