Skip to content

Commit

Permalink
introduce basic execution plan processor and more stabilization (#248)
Browse files Browse the repository at this point in the history
* properly disable plugin compatibility check

* fix freezing issue with relational property mapping

* minor improvement to connection editor and add cloudType to Snowflake datasource specification

* Add models for simple execution plan processing

* support using graphFetch and graphFetchChecked in query builder

* add changeset
  • Loading branch information
akphi committed Jun 11, 2021
1 parent 658efe0 commit a35e4d2
Show file tree
Hide file tree
Showing 41 changed files with 947 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-lemons-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-studio': patch
'@finos/legend-studio-components': patch
'@finos/legend-studio-plugin-query-builder': patch
---
5 changes: 5 additions & 0 deletions .changeset/six-llamas-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-studio': patch
---

Fix a bug that prevents graph freezer to work properly with relational property mapping (related to the changes in #207).
5 changes: 5 additions & 0 deletions .changeset/tidy-icons-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-studio': patch
---

Introduce plan execution processor (#249).
5 changes: 5 additions & 0 deletions .changeset/weak-spiders-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-studio-plugin-query-builder': patch
---

Default to use `graphFetch` function instead of `graphFetchChecked` as the latter does not work out-of-the-box for relational mapping.
4 changes: 1 addition & 3 deletions .github/workflows/check-plugin-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ on:
jobs:
check-plugin-compatibility:
name: Run Plugin Compatibility Checks
# NOTE: there is currently an issue that makes the following job condition not working as expected
# See https://github.com/actions/runner/issues/1145
if: ${{ github.context.payload.pull_request.title != 'New Release' }} # avoid running this in `New Release` PR
if: ${{ github.event.pull_request.title != 'New Release' }} # avoid running this in `New Release` PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
7 changes: 7 additions & 0 deletions packages/legend-studio-components/style/base/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@
}
}

&__section__text-editor {
width: 100%;
height: 15rem;
position: relative;
border: 0.1rem solid var(--color-dark-grey-100);
}

&__section__number-input {
width: 20rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
ChevronDownIcon,
ChevronRightIcon,
TimesIcon,
CheckSquareIcon,
SquareIcon,
} from '@finos/legend-studio-components';
import type { TreeNodeContainerProps } from '@finos/legend-studio-components';
import type { QueryBuilderState } from '../stores/QueryBuilderState';
Expand All @@ -41,6 +43,7 @@ import {
} from '../stores/QueryBuilderGraphFetchTreeUtil';
import type { QueryBuilderExplorerTreeDragSource } from '../stores/QueryBuilderExplorerState';
import { QUERY_BUILDER_EXPLORER_TREE_DND_TYPE } from '../stores/QueryBuilderExplorerState';
import type { QueryBuilderGraphFetchTreeState } from '../stores/QueryBuilderGraphFetchTreeState';

const QueryBuilderGraphFetchTreeNodeContainer: React.FC<
TreeNodeContainerProps<
Expand Down Expand Up @@ -131,11 +134,12 @@ const QueryBuilderGraphFetchTreeNodeContainer: React.FC<

export const QueryBuilderGraphFetchTreeExplorer = observer(
(props: {
graphFetchState: QueryBuilderGraphFetchTreeState;
treeData: QueryBuilderGraphFetchTreeData;
updateTreeData: (data: QueryBuilderGraphFetchTreeData) => void;
isReadOnly: boolean;
}) => {
const { treeData, updateTreeData, isReadOnly } = props;
const { graphFetchState, treeData, updateTreeData, isReadOnly } = props;

const onNodeSelect = (node: QueryBuilderGraphFetchTreeNodeData): void => {
if (node.childrenIds.length) {
Expand All @@ -156,20 +160,43 @@ export const QueryBuilderGraphFetchTreeExplorer = observer(
updateTreeData({ ...treeData });
};

const toggleChecked = (): void =>
graphFetchState.setChecked(!graphFetchState.isChecked);

return (
<div className="query-builder-graph-fetch-tree__container">
<TreeView
components={{
TreeNodeContainer: QueryBuilderGraphFetchTreeNodeContainer,
}}
treeData={treeData}
onNodeSelect={onNodeSelect}
getChildNodes={getChildNodes}
innerProps={{
isReadOnly,
removeNode,
}}
/>
<div className="query-builder-graph-fetch-tree">
<div className="query-builder-graph-fetch-tree__settings">
<div
className={clsx('panel__content__form__section__toggler')}
onClick={toggleChecked}
>
<button
className={clsx('panel__content__form__section__toggler__btn', {
'panel__content__form__section__toggler__btn--toggled':
graphFetchState.isChecked,
})}
>
{graphFetchState.isChecked ? <CheckSquareIcon /> : <SquareIcon />}
</button>
<div className="panel__content__form__section__toggler__prompt">
Check graph fetch
</div>
</div>
</div>
<div className="query-builder-graph-fetch-tree__container">
<TreeView
components={{
TreeNodeContainer: QueryBuilderGraphFetchTreeNodeContainer,
}}
treeData={treeData}
onNodeSelect={onNodeSelect}
getChildNodes={getChildNodes}
innerProps={{
isReadOnly,
removeNode,
}}
/>
</div>
</div>
);
},
Expand Down Expand Up @@ -230,6 +257,7 @@ export const QueryBuilderGraphFetchTreePanel = observer(
)}
{treeData && !isGraphFetchTreeDataEmpty(treeData) && (
<QueryBuilderGraphFetchTreeExplorer
graphFetchState={graphFetchState}
treeData={treeData}
isReadOnly={false}
updateTreeData={updateTreeData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ export class QueryBuilderGraphFetchTreeState {
editorStore: EditorStore;
queryBuilderState: QueryBuilderState;
treeData?: QueryBuilderGraphFetchTreeData;
/**
* If set to `true` we will use `graphFetchChecked` function instead of `graphFetch`.
* `graphFetchChecked` will do extra checks on constraints and only work on M2M use case for now.
* Hence we default this to `false` for graph fetch to work universally.
*/
isChecked = false;

constructor(editorStore: EditorStore, queryBuilderState: QueryBuilderState) {
makeAutoObservable(this, {
editorStore: false,
queryBuilderState: false,
setGraphFetchTree: action,
setChecked: action,
});

this.editorStore = editorStore;
Expand All @@ -48,6 +55,10 @@ export class QueryBuilderGraphFetchTreeState {
this.treeData = val;
}

setChecked(val: boolean): void {
this.isChecked = val;
}

init(tree?: RootGraphFetchTree): void {
if (this.queryBuilderState.fetchStructureState.isGraphFetchMode()) {
if (tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,13 @@ export class QueryBuilderLambdaProcessor
}
}
} else if (
functionName === SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED &&
(functionName === SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED ||
functionName === SUPPORTED_FUNCTIONS.GRAPH_FETCH) &&
this.getParentSimpleFunctionName() === SUPPORTED_FUNCTIONS.SERIALIZE
) {
this.queryBuilderState.fetchStructureState.graphFetchTreeState.setChecked(
functionName === SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
);
if (valueSpecification.parametersValues.length === 2) {
valueSpecification.parametersValues[0].accept_ValueSpecificationVisitor(
new QueryBuilderLambdaProcessor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,15 @@ export class QueryBuilderState extends EditorExtensionState {
SUPPORTED_FUNCTIONS.SERIALIZE,
multiplicityOne,
);
const graphFetchCheckedFunc = new SimpleFunctionExpression(
SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
const graphFetchFunc = new SimpleFunctionExpression(
this.fetchStructureState.graphFetchTreeState.isChecked
? SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED
: SUPPORTED_FUNCTIONS.GRAPH_FETCH,
multiplicityOne,
);
const expression = lambdaFunction.expressionSequence[0];
graphFetchCheckedFunc.parametersValues = [expression, graphFetchInstance];
serializeFunction.parametersValues = [
graphFetchCheckedFunc,
graphFetchInstance,
];
graphFetchFunc.parametersValues = [expression, graphFetchInstance];
serializeFunction.parametersValues = [graphFetchFunc, graphFetchInstance];
lambdaFunction.expressionSequence[0] = serializeFunction;
}
// apply result set modifier options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,22 @@
@use './mixins' as *;

.query-builder-graph-fetch-tree {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;

&__settings {
@include flexVCenter;

justify-content: flex-end;
height: 3.4rem;
background: var(--color-dark-grey-85);
padding: 0 1rem;
}

&__container {
height: 100%;
height: calc(100% - 3.4rem);
width: 100%;
padding: 0.5rem 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const PackageableConnectionEditor = observer(() => {
PackageableConnectionEditorState,
);
const isReadOnly = editorState.isReadOnly;

return (
<ConnectionEditor
connectionEditorState={editorState.connectionState}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,40 @@ export const ConnectionEditor_StringEditor = observer(
},
);

// TODO: consider to move this to shared
export const ConnectionEditor_TextEditor = observer(
(props: {
propertyName: string;
description?: string;
value: string | undefined;
isReadOnly: boolean;
language: EDITOR_LANGUAGE;
update: (value: string | undefined) => void;
}) => {
const { value, propertyName, description, isReadOnly, language, update } =
props;

return (
<div className="panel__content__form__section">
<div className="panel__content__form__section__header__label">
{capitalize(propertyName)}
</div>
<div className="panel__content__form__section__header__prompt">
{description}
</div>
<div className="panel__content__form__section__text-editor">
<TextInputEditor
inputValue={value ?? ''}
updateInput={update}
isReadOnly={isReadOnly}
language={language}
/>
</div>
</div>
);
},
);

// TODO: consider to move this to shared
export const ConnectionEditor_ArrayEditor = observer(
(props: {
Expand Down Expand Up @@ -343,14 +377,17 @@ const LocalH2DatasourceSpecificationEditor = observer(
isReadOnly: boolean;
}) => {
const { sourceSpec, isReadOnly } = props;
const SQLValue = sourceSpec.testDataSetupSqls.join('\n');
// TODO: support CSV and toggler to go to CSV mode
return (
<>
<ConnectionEditor_StringEditor
<ConnectionEditor_TextEditor
isReadOnly={isReadOnly}
value={sourceSpec.testDataSetupCsv}
propertyName={'test data setup csv'}
value={SQLValue}
propertyName={'test data setup SQL'}
language={EDITOR_LANGUAGE.SQL}
update={(value: string | undefined): void =>
sourceSpec.setTestDataSetupCsv(value)
sourceSpec.setTestDataSetupSqls(value ? [value] : [])
}
/>
</>
Expand Down Expand Up @@ -483,6 +520,23 @@ const SnowflakeDatasourceSpecificationEditor = observer(
sourceSpec.setDatabaseName(value ?? '')
}
/>
<ConnectionEditor_StringEditor
isReadOnly={isReadOnly}
value={sourceSpec.cloudType}
propertyName={'cloud type'}
update={(value: string | undefined): void =>
sourceSpec.setCloudType(value)
}
/>
{/* TODO: we should reconsider adding this field, it's an optional boolean, should we default it to `undefined` when it's `false`?*/}
{/* <ConnectionEditor_BooleanEditor
isReadOnly={isReadOnly}
value={sourceSpec.quotedIdentifiersIgnoreCase}
propertyName={'cloud type'}
update={(value: string | undefined): void =>
sourceSpec.setCloudType(value)
}
/> */}
</>
);
},
Expand Down Expand Up @@ -542,7 +596,7 @@ const SnowflakePublicAuthenticationStrategyEditor = observer(
<ConnectionEditor_StringEditor
isReadOnly={isReadOnly}
value={authSpec.publicUserName}
propertyName={'pass phrase vault reference'}
propertyName={'public user name'}
update={(value: string | undefined): void =>
authSpec.setPublicUserName(value ?? '')
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { ExecutionNode } from './nodes/ExecutionNode';

export class ExecutionPlan {
// TODO: Populate fields when required
// func : FunctionDefinition<Any>[1];
// mapping : Mapping[1];
// runtime : Runtime[1];

rootExecutionNode!: ExecutionNode;
processingTemplateFunctions: string[] = [];
authDependent!: boolean;
kerberos?: string;
// globalImplementationSupport: PlatformImplementation[0..1];
}
Loading

0 comments on commit a35e4d2

Please sign in to comment.